Announcement

Collapse
No announcement yet.

Using variables with gfx_button?

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

  • Using variables with gfx_button?

    I am having trouble using a string that is a variable with a button in gfx_button(). It works fine with constants, but displays no text when used with values built in a variable array.

    Example:
    HTML Code:
    var scratch[100];
    func main()
    txt_Set(FONT_SIZE, FONT3);
    gfx_Button(UP,50,190,BLUE,BLACK,FONT2,1,1,"Const");
    to(scratch),print("Variable");
    gfx_Button(UP,50,210,BLUE,BLACK,FONT2,1,1,scratch);
    repeat forever
    endfunc
    This example displays the "Const" button fine, but the "Variable" shows none of the text.

    I tried many, many variations on this (packed and unpacked strings). I have built the strings one char at time and using the str_*() functions. No improvement. I even tried modifying the constant area but that seems to be forbidden. All examples that I could find use static string constants. Searching on "gfx_button" in the forums returned every post with the word 'button' No luck there either.

    Any ideas? I am about to stop using gfx_button and build my own with images...

    Hardware: uOLED-32028-P1T.
    Pmmc: 1.08
    4DGL Workshop 2.4.0.0.

  • #2


    just a guess but have you tried making the array smaller - or is the an end ascii 0 to be added to show the end? - just started with 4DGL sorry.

    Comment


    • #3


      Try:

      gfx_Button(UP,50,210,BLUE,BLACK,FONT2,1,1,str_Ptr(scratch)) ;

      Maybe that will work....
      _______________
      Best Regards,
      Howard

      Comment


      • #4


        Thanks 4DSysFan . That worked in my simple case. Now to try it in my real program...

        gfx_Button(UP,50,210,BLUE,BLACK,FONT2,1,1,str_Ptr( scratch)) ;


        Now, I just need to figure out why it worked . I finally figured out normal ptrs and bytes vs. words. Looks like str_Ptrs are a little different...

        Comment

        Working...
        X