Announcement

Collapse
No announcement yet.

str_GetC and str_GetW ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • str_GetC and str_GetW ?

    I don't understand whats happening with the code below. Please read the comments for more information.

    [hr]#platform "uLCD-32PT_GFX2"

    /* Tested on Workshop 3.1.0.14
    Loaded into Ram (not flash).
    Picasso GFX2 Pmmc file "uLCD-32PTGFX-R25.PmmC".
    No SD card inserted.
    */
    #inherit "4DGL_16bitColours.fnc"
    #inherit "FONT4.fnt"

    var buffer[10];
    var p, gps;

    func main()

    gfx_Set(SCREEN_MODE,LANDSCAPE);
    txt_Set(FONT_ID, FONT4);

    to(buffer); putstr("0.5"); //If the first digit of this string is any number
    p := str_Ptr(buffer); // other than "0", the full code below works as expected.

    /* With the loop below compiled, display shows "0.553".
    The 53 at the end is the ASCII code (in 'gps') for the 5 after the
    decimal point. Comment out this loop and you get displayed what you should, "0".
    */

    while (str_GetC(&p, &gps))
    print ([CHR]gps);
    wend

    p := str_Ptr(buffer);
    str_GetW(&p, &gps);

    print (gps); //I'd expect to display "0" when the above 'while-wend' loop is compiled.

    repeat forever
    endfunc
Working...
X