Announcement

Collapse
No announcement yet.

Handle and Update String Objects

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

  • Handle and Update String Objects

    Hello,

    I try to generate an layout with ViSi to display incoming serial data. I got some problems using StaticText Objects, Strings and Fonts. For the following code i got while compiling these errors:

    Error: 'hfintn' not found
    Error: context error for unknown 'hfontn'
    Error: left side of expressionis not a pointer or variable
    Error: expected a semicolon following previous expresseion
    Error: syntax error in expression ? ':='
    Error: expected a semicolon following previous expresseion

    How can i get this code work? I want to display serial data in cycle, so i want to update some strings in cycle.

    Code:
    #platform "uLCD-70DT"
    
    // Program Skeleton 1.2 generated 10.12.2015 13:27:27
    
    #inherit "4DGL_16bitColours.fnc"
    
    #inherit "VisualConst.inc"
    
    #inherit "Display_EBIS_FinalConst.inc"
    
    
    func main()
        var hstrings ; // Handle to access uSD strings, uncomment if required
        var hFontx ;   // Handle to access uSD fonts, uncomment if required and change n to font number
    //  Uncomment the following if uSD images, fonts or strings used.
    
        putstr("Mounting...\n");
        if (!(file_Mount()))
            while(!(file_Mount()))
                putstr("Drive not mounted...");
                pause(200);
                gfx_Cls();
                pause(200);
            wend
        endif
    //    gfx_TransparentColour(0x0020);    // uncomment if transparency required
    //    gfx_Transparency(ON);             // uncomment if transparency required
    
        hFontn := file_LoadImageControl("DISPLA~1.dan", "DISPLA~1.gcn", 1); // Open handle to access uSD fonts, uncomment if required and change n to font number dropping a and c if > 9
        hstrings := file_Open("DISPLA~1.txf", 'r') ; // Open handle to access uSD strings, uncomment if required
        hndl := file_LoadImageControl("DISPLA~1.dat", "DISPLA~1.gci", 1);
    
    
        gfx_Set(SCREEN_MODE,LANDSCAPE) ;
    
    
        // Form1 1.1 generated 10.12.2015 13:39:45
        gfx_BGcolour(WHITE) ;
        gfx_Cls() ;
    
    
        // Statictext1 1.0 generated 10.12.2015 14:39:51
        img_Show(hndl,iStatictext1) ;
    
    
        // Strings1 1.1 generated 10.12.2015 14:40:05
        txt_FontID(FONT3) ;
        txt_FGcolour(BLACK) ;
        txt_BGcolour(WHITE) ;
        gfx_MoveTo(132 , 172) ;
        print("Your text goes here") ;
    
        repeat
            txt_FontID(FONT3) ;
            txt_FGcolour(BLACK) ;
            txt_BGcolour(WHITE) ;
            gfx_MoveTo(132 , 172) ;
            print("test") ;
        forever
    endfunc



  • #2
    The messages are from the compiler, you need to look at what the message says and figure out what you have done wrong.

    Eg the first message is (I believe)

    Error: 'hFontn' not found (line 29 filesss.4dg)

    So you can see from line 29 that you have used a variable named hFontn but you haven't declared it. You however have declared hFontx. Your variables dont match up.

    Perhaps have a read of the 4DGL Programmers Reference, or some other general guide to programming?
    Mark

    Comment


    • #3
      Hello,

      thank you for your answer. Yes, the variable was wrong declared, my fault. But i have also the question, how can i update the string object with a new value. When i use gfx_MoveTo() ; and write something new to this positin it will be writes over. But when the number of bytes is smaller then before, so some values are not overwritten. Is there a chance to clear the string objekt before?

      Code:
          #platform "uLCD-70DT"
      
          // Program Skeleton 1.2 generated 10.12.2015 13:27:27
      
          #inherit "4DGL_16bitColours.fnc"
      
          #inherit "VisualConst.inc"
      
          #inherit "Display_EBIS_FinalConst.inc"
      
      
          func main()
              var hstrings ; // Handle to access uSD strings, uncomment if required
              var hFontn ;   // Handle to access uSD fonts, uncomment if required and change n to font number
          //  Uncomment the following if uSD images, fonts or strings used.
      
              putstr("Mounting...\n");
              if (!(file_Mount()))
                  while(!(file_Mount()))
                      putstr("Drive not mounted...");
                      pause(200);
                      gfx_Cls();
                      pause(200);
                  wend
              endif
          //    gfx_TransparentColour(0x0020);    // uncomment if transparency required
          //    gfx_Transparency(ON);             // uncomment if transparency required
      
              hFontn := file_LoadImageControl("DISPLA~1.dan", "DISPLA~1.gcn", 1); // Open handle to access uSD fonts, uncomment if required and change n to font number dropping a and c if > 9
              hstrings := file_Open("DISPLA~1.txf", 'r') ; // Open handle to access uSD strings, uncomment if required
              hndl := file_LoadImageControl("DISPLA~1.dat", "DISPLA~1.gci", 1);
      
      
              gfx_Set(SCREEN_MODE,LANDSCAPE) ;
      
      
              // Form1 1.1 generated 10.12.2015 13:39:45
              gfx_BGcolour(WHITE) ;
              gfx_Cls() ;
      
              // Statictext1 1.0 generated 10.12.2015 14:39:51
              img_Show(hndl,iStatictext1) ;
      
      
              // Strings1 1.1 generated 10.12.2015 14:40:05
              txt_FontID(FONT3) ;
              txt_FGcolour(BLACK) ;
              txt_BGcolour(WHITE) ;
              gfx_MoveTo(132 , 172) ;
              print("Your text goes here") ;
      
              repeat
                  txt_FontID(FONT3) ;
                  txt_FGcolour(BLACK) ;
                  txt_BGcolour(WHITE) ;
                  gfx_MoveTo(132 , 172) ;
                  print("test") ;
              forever
          endfunc

      Comment


      • #4
        It's up to you to do that, you could use a filled Rectangle in the background colour to erase the screen area, you could format your string so it is always the same width, you could pad the string with spaces.

        Whatever you way you want, or need, nothing is removed from the screen until you cover it with something else, or do a gfx_Cls() (which is actually just a filled rectangle in the background colour for the full screen size
        Mark

        Comment


        • #5
          Okay, I understand what you mean. Can you give me an example for the filled rectangle method or an appnote?

          Comment


          • #6
            Hi,

            This application note should help you: http://www.4dsystems.com.au/appnote/4D-AN-00059/

            Designer or ViSi How to Draw Circles and Rectangles

            - This application note shows how to program a 4D display module in the Designer environment to make it draw circles and rectangles on the screen.
            Symon

            Comment

            Working...
            X