Get Values From Terminal - Propeller C - Start Simple
in Propeller 1
Hi
Need some assistance with one of the parallax tutorials.
I'm trying to replace scan and print functions with get and put functions, respectively.
The code below does not build, can somebody explain why and how to replace the sections of code that require the scan function with get commands. (I have marked the troubling code sections with "***" below).
Thanks
Code is below this line
#include "simpletools.h" // Include simple tools
int startVal;
int endVal;
int main() // Main function
{
putStr("Type values for startVal and \n");
putStr("endVal, separated by a space. \n");
putStr("Then, press Enter. \n");
getDec("%d%d", startVal);***
getDec("%d%d", endVal);***
putStr("\nCounting from ");
putDec(startVal);
putStr(" to ");
putDec(endVal);
putStr(".\n");
for(int n = startVal; n <= endVal; n++)
{
print("i = %d\n", n);***
}
putStr("\nDone!");
}
Need some assistance with one of the parallax tutorials.
I'm trying to replace scan and print functions with get and put functions, respectively.
The code below does not build, can somebody explain why and how to replace the sections of code that require the scan function with get commands. (I have marked the troubling code sections with "***" below).
Thanks
Code is below this line
#include "simpletools.h" // Include simple tools
int startVal;
int endVal;
int main() // Main function
{
putStr("Type values for startVal and \n");
putStr("endVal, separated by a space. \n");
putStr("Then, press Enter. \n");
getDec("%d%d", startVal);***
getDec("%d%d", endVal);***
putStr("\nCounting from ");
putDec(startVal);
putStr(" to ");
putDec(endVal);
putStr(".\n");
for(int n = startVal; n <= endVal; n++)
{
print("i = %d\n", n);***
}
putStr("\nDone!");
}

Comments
/** * @file getDec.c * Function to get decimal number from the terminal. * * Copyright (c) 2013, Parallax Inc. * Written by Steve Denson */ #include <limits.h> #include "simpletext.h" int getDec(void) { extern text_t *dport_ptr; return readDec(dport_ptr); } int readDec(text_t *text) { int rc = 0; char buf[40]; char *str = _safe_gets(text, buf, 39); if(*str) _scanf_getl(str, &rc, 10, 11, 1); /* signed */ return rc; } /*Mike