SimpleIDE Terminal. Clear Screen?
doggiedoc
Posts: 2,250
I'm trying to pragmatically clear the SimpleIDE Terminal screen and return the cursor to the home position.
I've resorted to this
I'm I missing something?
Thanks!
Paul
printf("\1");
This returns the cursor to the top left of the window but neither
printf("\0");
nor
printf("\16");
clear the screen as I would expect.I've resorted to this
printf("\1");
int i;
for (i = 0; i < 25; i++){
printf (" \n");
}
printf("\1");
but it's kind of sloppy and inconsistent depending on how the window is resized.I'm I missing something?
Thanks!
Paul

Comments
printf("\16") won't work - I think you need a preceding zero (octal) or a preceding x (hexidecimal), so try this:
printf( "\x10" );
Jason
And, you need to use the %c (character) format option in order to send the screen-affecting values
pause(1000); // Wait 1 s for terminal software printf("Hello!"); // Display test message pause(1000); // Wait 1 s for terminal software printf("%c",CLS); // works if you are including "simple tools.h" printf("Nice to see you!"); // Display test message pause(1000); // Wait 1 s for terminal software printf("%c",16); // should always work printf("Goodbye!"); // Display test messagedgately
printf("\x10");Worked.So, printf("%c",16); should work. also!
dgately
Only if the terminal option is set of course ;-)
printf("%c", CLS);You can also do things like:
printf("%cmyValue = %d, %c", HOME, myVariable, CLREOL) ;That'll send the cursor to the top-left home position, display the decimal character representation of the myValue variable, then clear to the end of the line. First %c flag displays HOME, then %d displays second thing (myVariable), and third flag (another %c) displays CLREOL, which clears to end of line.
This is useful for having a display that stays in the top-left instead of scrolling. The CLREOL is important, because if your measurement changes from 105 to 98, you wouldn't want it displaying 985 (with stray 5 from previous measurement).
For more info, click Help and select Simple Library Reference. Then, follow the libsimpletools link.
Anybody got ideas?
What does the Terminal -> Options button -> Function tab show?
What IDE version do you have?
It works if I use:
print("%c", CLS);but does not work with:
printf("%c", CLS);The printf output is buffered unless you do something special or send a "\n". It takes more work than necessary. Use putchar('\0') if you like.
The Learn library functions don't require special sauce. Use print("%c", CLS), printi("%c", CLS), or putChar(CLS).
Thanks again.