Announcement

Collapse
No announcement yet.

How do you comment out a function

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

  • How do you comment out a function

    I'm looking to comment out a function to test some code. Is there a simple way to do this. The function contains print statements with " in, which seems to cause putting /" [function] "/ to not work. Am i missing some simple way to do this?

  • #2
    Hi

    The best way to comment out a whole block or function would be

    /*
    func test(var a)

    endfunc
    */

    I hope this helps

    Best regards

    Paul

    Comment


    • #3
      I'm having an issue with a button press not being detected. It was originally a multi form program, but i've commented it down to the minimum and the problem still persists.

      Code here:

      func main()

      putstr("Mounting...\n");
      if (!(file_Mount()))
      while(!(file_Mount()))
      putstr("mount SD card to continue");
      pause(2000);
      gfx_Cls();
      pause(100);
      wend
      endif
      pause (500);
      gfx_Cls();

      hndl := file_LoadImageControl("LEDI_P~1.dat", "LEDI_P~1.gci", 1);

      touch_Set(TOUCH_ENABLE); // enable touch screen capabilities

      gfx_BGcolour(0x2A59) ;
      gfx_Cls() ;

      // Winbutton9 1.0 generated 2019-12-03 1:35:15 PM
      img_ClearAttributes(hndl, iWinbutton9, I_TOUCH_DISABLE); // set to enable touch, only need to do this once
      img_Show(hndl, iWinbutton9); // show button, only do this once
      img_SetWord(hndl, iWinbutton9, IMAGE_INDEX, 0); // where state is 0 for up and 1 for down
      img_Show(hndl,iWinbutton9) ;

      var _state, _n, _returnvalue ;
      var x, y;

      print([HEX4]iWinbutton9);

      repeat

      _state := touch_Get(TOUCH_STATUS);
      _n := img_Touched(hndl,-1);

      if(_state == TOUCH_PRESSED)

      print("\n you touched the screen at ");

      print([HEX4]_n);

      x:=touch_Get(TOUCH_GETX); //place pixel where screen touched
      y:=touch_Get(TOUCH_GETY);
      gfx_PutPixel(x,y,WHITE);

      if(_n == iWinbutton9)
      print("& the button");
      pause(1000);
      goto exit;
      endif

      print("\n");

      endif

      forever

      exit:
      print("exit reached");

      endfunc


      My results:

      - I get a value of 0040 for the iWinbutton9
      - I get successfully print "you touched the screen at" every touch
      - The value returned for _n is either 000D, 002A, or 002B. It returns 000D most of the time i press the button, but the values are not consistent with the boundary's of the button.
      - As a consequence of _n never matching 0040 I never get into the button if loop.
      - this is a peared down version, usually on exit i would also have a img_SetAttributes(hndl, iWinbutton9, I_TOUCH_DISABLE); but i never reach that point in the program anyway

      i wonder if i've corrupted my hndl files somehow


      Do you have any insight to what i'm doing wrong and how i can discover the issue. This is driving me insane.

      Comment


      • #4
        the entry in the .dat file for iWinbutton9 is:

        "Winbutton9" A000 00D4 C4 1B4

        i'm not sure how to interpret this though.

        Comment


        • #5
          Hi,

          I just tried this with one button iWinbutton1 and it gave the expected result of 0xFFFF (-1) every where else on the screen and 0x0000 for the button and then exit. It looks like your picking up other enabled widgets as the values given back indicate widget numbers.

          You could try adding

          img_SetAttributes(hndl, -1, I_TOUCH_DISABLE);

          after hndl := file_LoadImageControl("LEDI_P~1.dat", "LEDI_P~1.gci", 1);

          And that will disable all widgets, your code enables the iWinbutton9 before the repeat loop so it should be detected.

          The inc file that has the data for all the widgets has a name followed by address on the SD card followed by width then height. They are numbered from 0 so whatever the position Winbutton9 is in the list 0, 1, 2 .... 40 this is the value that will be returned

          Best regards

          Paul

          Comment


          • #6
            Thank you Paul, the img_SetAttributes(hndl, -1, I_TOUCH_DISABLE); worked. Does the -1 refer to the entire list instead of a specific item.

            Also why the difference between iWinbutton (in the program) and Winbutton (in the data file). is "i" a pointer or something?

            Comment


            • #7
              So it is working for 1 button press only. upon exiting to main form, and then returning to that form I get "FFFF" as the response where the button is.

              When entering the form i have the line: img_ClearAttributes(hndl, iWinbutton9, I_TOUCH_DISABLE); which i thought should activate touch response for Winbutton9


              code as follows:

              func blue_meter()

              gfx_BGcolour(0x2A59) ;
              gfx_Cls() ;

              // Winbutton9 1.0 generated 2019-12-03 1:35:15 PM
              img_ClearAttributes(hndl, iWinbutton9, I_TOUCH_DISABLE); // set to enable touch, only need to do this once
              img_Show(hndl, iWinbutton9); // show button, only do this once
              img_SetWord(hndl, iWinbutton9, IMAGE_INDEX, 0); // where state is 0 for up and 1 for down
              img_Show(hndl,iWinbutton9) ;

              var _state, _n, _returnValue ;
              var x, y;

              print([HEX4]iWinbutton9);

              repeat
              img_Show(hndl,iWinbutton9) ;
              _state := touch_Get(TOUCH_STATUS);
              _n := img_Touched(hndl,-1);

              if(_state == TOUCH_PRESSED)

              print("\n you touched the screen at ");

              print([HEX4]_n);

              x:=touch_Get(TOUCH_GETX); //place pixel where screen touched
              y:=touch_Get(TOUCH_GETY);
              gfx_PutPixel(x,y,WHITE);

              if(_n == iWinbutton9)

              print("& the button");
              _returnValue := iWinbutton9 ;
              goto exit;
              endif

              print("\n");

              endif

              forever

              exit:
              pause (100);
              img_SetAttributes(hndl,iWinbutton9, TOUCH_DISABLE);
              img_SetAttributes(hndl,blue_meter, TOUCH_DISABLE);
              return _returnValue;

              endfunc

              Comment


              • #8
                Paul is there any way i can privately email you the project to see if you can figure out what is going on with this. It is against my company's regulations to post it publicly.

                I have done a search for all instances of "Winbutton9" and couldn't find anything out of place

                Comment


                • #9
                  Hi,

                  Of course. You can email it to me - paul at 4dsystems dot com dot au

                  Best regards

                  Paul

                  Comment


                  • #10
                    email sent

                    Comment


                    • #11
                      Hi Paul,

                      Did you have any luck with the email I sent?

                      Thanks

                      Comment


                      • #12
                        Hi,

                        Yes, thank you for the code and you are exactly right. I haven't found the cause yet but still going through it. On paper it should do as you expect, I have a few more things to try and hope to have a solution today

                        Comment

                        Working...
                        X