Announcement

Collapse
No announcement yet.

gfx_Button() set text from string[]

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

  • gfx_Button() set text from string[]

    Hello all and thanks for reading me. There are four buttons (for the four segments of an IP address). I initialize the buttons like this:
    Code:
    #platform "uLCD-24PTU"
    #inherit "4DGL_16bitColours.fnc"
    #inherit "FONT4.fnt"
    #constant keyPadX 40
    #constant keyPadY 40
    #constant horSpace 30
    #constant verSpace 35
    #constant kpdTXTw 3
    #constant kpdTXTh 3
    #constant curIPxC 5
    #constant curIPyC 10
    #constant curIPwC 1
    #constant curIPhC 1
    
    
    var ip1[3], ip2[3],ip3[3], ip4[3];
    var *pip1, *pip2, *pip3, *pip4;
    
    
    func initializeIP()
    mem_Set(ip1, 0, sizeof(ip1));   // clear buffer ip1
    mem_Copy("192", ip1, 3);
    pip1 := str_Ptr(ip1);
    
    mem_Set(ip2, 0, sizeof(ip2));   // clear buffer ip2
    mem_Copy("168", ip2, 3);
    pip2 := str_Ptr(ip2);
    
    mem_Set(ip3, 0, sizeof(ip3));   // clear buffer ip3
    mem_Copy("000", ip3, 3);
    pip3 := str_Ptr(ip3);
    
    mem_Set(ip4, 0, sizeof(ip4));   // clear buffer ip4
    mem_Copy("170", ip4, 3);
    pip4 := str_Ptr(ip4);
    
    endfunc
    
    func drawCurrentIP (var curIPX, var curIPY, var curIPTXTW, var curIPTXTH)
         gfx_MoveTo(0,200);
        print([STR]ip1,[STR]ip2,[STR]ip3,[STR]ip4);
        gfx_ObjectColour(RED);
        gfx_Set(PEN_SIZE, 0);
        gfx_Button(1, curIPX, curIPY, GRAY, BLACK, FONT4, curIPTXTW, curIPTXTH, ip1);
        gfx_MoveTo(curIPX + 55,curIPY + 25);
        gfx_Bullet(3);
    
        gfx_Button(1, curIPX + 60, curIPY, GRAY, BLACK, FONT4, curIPTXTW, curIPTXTH, ip2);
        gfx_MoveTo(curIPX + 115,curIPY + 25);
        gfx_Bullet(3);
    
        gfx_Button(1, curIPX + 120, curIPY, GRAY, BLACK, FONT4, curIPTXTW, curIPTXTH, ip3);
        gfx_MoveTo(curIPX + 175,curIPY + 25);
        gfx_Bullet(3);
    
        gfx_Button(1, curIPX + 180, curIPY, GRAY, BLACK, FONT4, curIPTXTW, curIPTXTH, ip4);
    
    endfunc
    and later in main func I call both functions. Inside the drawCurrentIP function the first two lines are there for debug reasons. It prints 192168000170 on my screen as expected. However the buttons are all over the place. Ofc if I put something like gfx_Button(1, curIPX, curIPY, GRAY, BLACK, FONT4, curIPTXTW, curIPTXTH, "192"); works fine. So what am I doing wrong?
    Thanks again.

  • #2
    Try using your string pointers, eg
    gfx_Button(1, curIPX, curIPY, GRAY, BLACK, FONT4, curIPTXTW, curIPTXTH, pip1);
    Mark

    Comment

    Working...
    X