Announcement

Collapse
No announcement yet.

Smart Slider - Slide to unlock - set frame problem

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

  • Smart Slider - Slide to unlock - set frame problem

    Hi,

    played arround with slide to unlock sample app note 4DLS-AN-00050S_R_1_0.pdf.
    Make litte modifications like button0 on form0 switch to form1 and smartslider0 on form1 switch back to form0.
    Code in magicevent0 works fine.
    Adding button1 on form0 without any function causes that smartslider0 doesn't slide back to frame0 after sliding.
    The "WriteObject(tSmartSlider, iSmartSlider0, 0) ;" command doesn' work anymore.

    Have no idea why. Modify code in magicevent0?


    Best Regards
    Doms

  • #2
    Hi Doms, welcome to the forum.

    Can you provide me the code your working with in order for me to debug it?

    Best regards,

    - Vince -
    Vince_4D

    Comment


    • #3
      Hi Vince,

      thank you for your support.


      func MagicEvent0(var newval)
      var frame;

      frame := img_GetWord(hndl, iSmartSlider1, IMAGE_INDEX);

      if (img_GetWord(hndl, iSmartSlider1, IMAGE_INDEX) >= 40)
      ActivateForm(0) ;
      endif

      WriteObject(tSmartSlider, iSmartSlider1, 0) ;
      endfunc


      BR
      Doms

      Comment


      • #4
        Hi again Doms,

        To fix the error, kindly change the iSmartSlider1 parameter in WriteObject(tSmartSlider, iSmartSlider1, 0) function to the index of the SmartSlider.

        To know the index of the SmartSlider, go to its property and find the index number as shown in the image.

        Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	3.1 KB
ID:	63429 ​​​​​​​

        In this case, the changed command would be WriteObject(tSmartSlider, 0 ,0 ).

        Hope this helps.

        Best regards,

        Vince
        Vince_4D

        Comment


        • #5
          Sorry Vince, forgot to write....
          SmartSlider index is 1 because i removed my first try SmartSlider0.

          It works as long as i add a button or slider in form0.


          BR
          Axel

          Comment


          • #6
            After changing command to "WriteObject(tSmartSlider, 1, 0) ;" it works fine.

            Thank you for your support

            Comment


            • #7
              No worries Doms.
              You can always contact us if you needed support.

              Best regards,
              Vince
              Vince_4D

              Comment


              • #8
                Hi Vince,

                I have a question about how to change the max value of a trackbar depending on a button press. I am trying to use the same trackbar to change the value of several custom digits. I can do this without problem, however I want to limit the values that can be chosen based on which button was pressed. I understand that the scale of the trackbar won't be adjusted to reflect the max value. I just don't want an invalid input to be saved to that variable. How would you go about this?

                Thanks,

                Mark

                Comment


                • #9
                  Hi Mark,

                  To achieve your objective, a mapping function can give you a hand.


                  Code:
                  var map(var x, var in_min, var in_max, var out_min, var out_max)
                  {
                    return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
                  }
                  So if a button is pressed to change the max value of a certain custom digit, you will just have to map the output frame of the trackbar relative to the new max value.

                  For example,
                  new_max = 1000;
                  trackbar_val = 50,
                  (trackbar frame 0-100)
                  Custom digit value would be map(trackbar_val, 0, 100, 0, new_max) which is equal to 500.


                  BR,
                  Vince_4D

                  Comment

                  Working...
                  X