Shop OBEX P1 Docs P2 Docs Learn Events
SimpleIDE Terminal. Clear Screen? — Parallax Forums

SimpleIDE Terminal. Clear Screen?

doggiedocdoggiedoc Posts: 2,241
edited 2014-08-03 17:36 in Propeller 1
I'm trying to pragmatically clear the SimpleIDE Terminal screen and return the cursor to the home position.
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

  • JasonDorieJasonDorie Posts: 1,930
    edited 2013-05-07 16:07
    Standard string printing uses the character zero as a string terminator, so your printf statement sees it and stops. You could trying doing a putc( 0 ) to STDOUT instead. Not sure if they've supported that in PropGCC, but that's a pretty standard way to write binary values to the output stream.

    printf("\16") won't work - I think you need a preceding zero (octal) or a preceding x (hexidecimal), so try this:

    printf( "\x10" );

    Jason
  • jazzedjazzed Posts: 11,803
    edited 2013-05-07 16:23
    Try putchar('\0');
  • dgatelydgately Posts: 1,630
    edited 2013-05-07 16:24
    Are you using SimpleIDE that includes the simpletools library? CLS is defined there as 16...
    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 message
    
    
    

    dgately
  • doggiedocdoggiedoc Posts: 2,241
    edited 2013-05-07 16:43
    Thanks!
    printf("\x10");
    
    Worked.
  • doggiedocdoggiedoc Posts: 2,241
    edited 2013-05-07 16:45
    jazzed wrote: »
    Try putchar('\0');
    Thanks Steve, that works too.
  • doggiedocdoggiedoc Posts: 2,241
    edited 2013-05-07 16:46
    dgately - I am not using simpletools.h on this project. I started it before it was released.
  • dgatelydgately Posts: 1,630
    edited 2013-05-07 17:11
    doggiedoc wrote: »
    dgately - I am not using simpletools.h on this project. I started it before it was released.

    So, printf("%c",16); should work. also!


    dgately
  • doggiedocdoggiedoc Posts: 2,241
    edited 2013-05-07 17:14
    dgately wrote: »
    So, printf("%c",16); should work. also!


    dgately
    ... and it does. :D Thanks!
  • jazzedjazzed Posts: 11,803
    edited 2013-05-07 17:19
    dgately wrote: »
    So, printf("%c",16); should work. also!

    Only if the terminal option is set of course ;-)
  • doggiedocdoggiedoc Posts: 2,241
    edited 2013-05-07 17:38
    jazzed wrote: »
    Only if the terminal option is set of course ;-)
    The terminal option menu was my first hint at how to do it. Thanks Steve!
  • jazzedjazzed Posts: 11,803
    edited 2013-05-07 20:24
    Did you happen to find the User Guide?
  • doggiedocdoggiedoc Posts: 2,241
    edited 2013-05-08 10:48
    jazzed wrote: »
    Did you happen to find the User Guide?
    What? Where?
  • jazzedjazzed Posts: 11,803
    edited 2013-05-08 10:58
  • doggiedocdoggiedoc Posts: 2,241
    edited 2013-05-08 13:23
    Thanks! But I thought User Guides were for people that don't know what they're doing. :D Oh wait, that's me.
  • mindrobotsmindrobots Posts: 6,506
    edited 2013-05-08 15:05
    I've actually read several SimpleIDE user guides.....usually though they are the last bastion of refuge before facing the fact that you aren't as smart as you thought you were!
  • edited 2013-05-08 19:38
    Another option:
    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.
  • doggiedocdoggiedoc Posts: 2,241
    edited 2013-05-08 21:15
    Thanks Andy that is a very useful tip!
  • doggiedocdoggiedoc Posts: 2,241
    edited 2014-08-03 15:57
    Sorry to revive my own thread but has something changed? I can't get SimpleIDE terminal to send the cursor to the home position and clear the screen?

    Anybody got ideas?
  • jazzedjazzed Posts: 11,803
    edited 2014-08-03 16:59
    doggiedoc wrote: »
    Sorry to revive my own thread but has something changed? I can't get SimpleIDE terminal to send the cursor to the home position and clear the screen?

    Anybody got ideas?


    What does the Terminal -> Options button -> Function tab show?

    What IDE version do you have?
  • doggiedocdoggiedoc Posts: 2,241
    edited 2014-08-03 17:05
    All functions have a check mark. SimpleIDE v 0.9.66 on MacOS 0.9.4 -

    It works if I use:
    print("%c", CLS);
    

    but does not work with:
    printf("%c", CLS);
    
  • jazzedjazzed Posts: 11,803
    edited 2014-08-03 17:18
    doggiedoc wrote: »
    All functions have a check mark. SimpleIDE v 0.9.66 on MacOS 0.9.4 -

    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).
  • doggiedocdoggiedoc Posts: 2,241
    edited 2014-08-03 17:36
    Thanks Steve - print("%c", CLS) is working fine for me now. I thought I had tried it earlier but I think I had typos or something.

    Thanks again.
Sign In or Register to comment.