Announcement

Collapse
No announcement yet.

Problem with str_Find when I use mem_Alloc

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

  • Problem with str_Find when I use mem_Alloc

    Hi,

    If I use global Texte, str_Find works without problem. It display i=6, i=9, i=11, i=0
    But if I use mem_Alloc and comment global Texte, It display i=32538, i=32541, i=32543, i=0.

    What is the problem ? I don't understand ! mem_Alloc is word aligned ?


    Code:
    #platform "uLCD-43DT"
    
    #inherit "4DGL_16bitColours.fnc"
    
    var Texte[20];
    
    func main()
    
        var ptr, i;
        //var Texte;
    
        //Texte := mem_Alloc(40);
        to(Texte); print("THIS IS A TEST");
    
        gfx_ScreenMode(LANDSCAPE);
        txt_FontID(FONT_2);
    
        print("Texte=", [STR] Texte, "\n\n");
    
        ptr := str_Ptr(Texte);
        repeat
            // Recherche la taille max possible
            i := str_Find(&ptr, " ");
            print("i=", i, "\n");
            ptr := i + 1;
        until (i == 0);
    
        repeat
        forever
    
    endfunc

  • #2
    There is no problem, i is a pointer, global text is allocated low, mem_alloc'd memory is allocated high.

    The deltas of the I's give 3 and 2 in both cases, which is the differences between the position of the 2nd and 3rd blanks
    Mark

    Comment


    • #3
      OK Thank you

      Comment

      Working...
      X