Announcement

Collapse
No announcement yet.

I am having a problem calling a function

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

  • I am having a problem calling a function

    I am using the GEN4-uLCD-35DT and I am trying to create a subroutine called "showHomePage" which displays my home page that contains static text and one winbutton. When I call this function in the main function nothing will display on the screen. However, if I copy and paste all the lines that are in my showHomePage subroutine into the main function, it will work just fine. What is the correct way to call a sub function in the main function? My code is posted below.




    #platform "Gen4-uLCD-35DT"


    // Program Skeleton 1.4 generated 7/26/2021 9:57:22 AM

    #inherit "4DGL_16bitColours.fnc"

    #inherit "VisualConst.inc"

    // var gradientRAM[29+xxx*2] := [-1,-1,-9999,0,0,xxx] ; // uncomment and replace xxx with maximum of all inherent 'media' widgets

    #inherit "Visie TestConst.inc"


    func main()
    // Uncomment the following if uSD and uSD based GCI images, fonts or strings used.
    var hndl;
    //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
    //putstr("Mounting...\n");
    if (!(file_Mount()))
    while(!(file_Mount()))
    putstr("Drive not mounted...");
    pause(500);
    gfx_Cls();
    pause(500);
    wend
    endif
    // gfx_TransparentColour(0x0020); // uncomment if transparency required, please understand why and when you need to use this
    // gfx_Transparency(ON); // uncomment if transparency required, as generally there is a performance hit when using it

    //hFontn := file_LoadImageControl("VISIET~1.dan", "VISIET~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("VISIET~1.txf", 'r') ; // Open handle to access uSD strings, uncomment if required
    hndl := file_LoadImageControl("VISIET~1.dat", "VISIET~1.gci", 1);
    touch_Set(TOUCH_ENABLE);
    var currentform;

    showHomePage();

    repeat
    forever

    endfunc


    func showHomePage()

    gfx_Cls();
    img_Show(hndl,iStatictext1);

    img_ClearAttributes(hndl, iWinbutton1, I_TOUCH_DISABLE); // set to enable touch, only need to do this once
    img_Show(hndl, iWinbutton1); // show button, only do this once
    img_SetWord(hndl, iWinbutton1, IMAGE_INDEX, 0); // where state is 0 for up and 1 for down

    endfunc

  • #2
    I had figured it out. I had removed "var hndl" and now it works

    Comment


    • #3
      var hndl, should only be required if you have modified your project away from the standard ViSi template, and you are no longer loading the Const.inc file at the top of your project, or you have renamed your project externally some how.

      I can see you have:
      #inherit "Visie TestConst.inc"
      Is "Visie Test" the current name of your project?

      The ViSi project should be able to maintain project saves to different file names, automatically, unless something external happens which it does not see.

      I would suggest you check that inherit file, and check what the Const file is in your project's .4DWork folder, and make sure they match, as that is what would typically have the 'var hdnl' in it automatically, you should not need to type it in manually.

      If you open up that Const file, you will see its contents.

      I hope that helps.

      Regards
      James

      Comment

      Working...
      X