Announcement

Collapse
No announcement yet.

what the hey? code works "sometimes"

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

  • what the hey? code works "sometimes"

    here is a patch of code (that compiles and works). The function is to parse a string.
    I noticed the "book" says that str_catN(&ptr, str, count) is the proper format it and does not work, Per this post:
    https://forum.4dsystems.com.au/forum...at-not-working
    the 4D staff memeber, ESPsupport listed str_catN(ptr, str, count) ....this works, after a fashion.

    After several hours of tweaking this code, it seems to work. However something is not right. If I simply comment out var n22 (it's not used) the code fails and str_catN() no longer works. Makes no difference whether in RAM of FLASH. When it works, my_f prints "way, "
    Any ideas?

    Code:
    #platform "Gen4-uLCD-32PT"
    //#MODE RUNFLASH
    #STACK 1000
    var buffer[100];
    var p;
    var dd;
    var n22;
    var char;
    var field_no;
    var dex;
    var seperator := '|';                      
    var my_f[100];
    var char_str[5];
    
    
    
    
    func main()
    to(buffer); print ( "and| by the|way, |the string| class| is| rather| useful| " );
    p := str_Ptr(buffer);
    print( "p=" , [STR]p , "\n" );
    
    field_no := 3;
    dex := 1;
    repeat
    mem_Set(my_f, 0, sizeof(my_f));
      str_GetC(&p, &char);
      while( char != seperator)
        to(char_str); print([CHR]char);
        str_CatN(str_Ptr(my_f), char_str,1);
        str_GetC(&p, &char);
        print("my_f=",[STR]my_f,"  char=",[STR]char_str,"\n");
        pause(1000);
      wend
    until(dex++ == field_no);
    gfx_Cls();
    print("my_f=",[STR]my_f,"\n");
    pause(10000);
    endfunc

  • #2
    anyone have any thoughts on this?

    Comment


    • #3
      What happens if you change
      Code:
                  str_CatN(str_Ptr(my_f), char_str,1);
      to
      Code:
                  str_CatN(str_Ptr(my_f), str_Ptr(char_str),1);
      Mark

      Comment

      Working...
      X