Pass variable into form

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

  • Pass variable into form

    I want to declare a variable in my PC-DMIS program and pass its value into a PC-DMIS form. Is there any way to do this directly?

    The best I could come up with was this:

    Code:
                ASSIGN/V1=value
    CS1       =FORM/FILENAME= PATH+"PROBE_MENU.FORM"
                PARAM/TEXT1.TEXT=V1
                PARAM/=
                ENDFORM/
    This sets the text property of a text object to the value of V1, but it's best to set the .VISIBLE property to FALSE. I can then refer to the value by using TEXT1.TEXT. It works, but it's a little cumbersome.

  • #2
    In the form object's text property:

    =variable("V1")

    Comment


    • #3
      Nailed it! Thanks a bunch!


      Gee, you don't know a way to pass a variable back to the program from the form, do you?

      Comment


      • #4
        Originally posted by TheBradish View Post
        Gee, you don't know a way to pass a variable back to the program from the form, do you?
        I used something like this:

        Code:
                        ASSIGN/SERNUM="66####-"
                        ASSIGN/OPRNAM=""
                        ASSIGN/FORM_OK=0
            USERFORM   =FORM/FILENAME= N:\PC-DMIS CONTROLLED\FORMS\OPERINPUT.FORM
                        PARAM/TBXPARTNUM.TEXT=SERNUM
                        PARAM/TBXOPER.TEXT=OPRNAM
                        PARAM/LBLOK.TEXT=FORM_OK
                        PARAM/=
                        ENDFORM/
        The "PARAM" statement sets the form control's value when the form is shown, and when the from is closed it pulls the control's value and inserts it into the variable. It's kind of a swapping back and forth. The "FORM_OK" value is set by code in the form to make sure it was filled out properly; it's value is used elsewhere in the program.

        Comment


        • #5
          Originally posted by bjacobson View Post
          =variable("V1")

          This works like a dream when using the variable value by itself, but I can't seem to concatenate. When I try the code below in the text property it displays exactly the way I type it, as if I had placed the whole thing in quotes.

          Code:
          =variable("V1")&"concat"

          Comment


          • #6
            Maybe replace the & with +

            Comment


            • #7
              + gives the same result.

              Comment


              • #8
                You can get set what you want via the various events of the form. I played with the EventInitialize event of TheFrame/TheView. I added the following:

                Code:
                    Dim Pcdmis As Object
                    Dim PartProg As Object
                    Dim varValue As Object
                    Set Pcdmis = GetObject("", "PCDLRN.Application")
                    Set PartProg = Pcdmis.ActivePartProgram
                    Set varValue = PartProg.GetVariableValue("V1")
                    If Not varValue is Nothing Then
                       text1.Text = "The result is " + varValue.StringValue
                    End If
                    Set varValue = nothing
                    Set PartProg = nothing
                    Set Pcdmis = nothing
                When the FORM is initialized (opened), the script will run, looking for variable V1. If found, it will set the text of my TEXT1 control to "The result is " along with the result it found.

                Comment


                • #9
                  I just used =variable("V1")+"concat" in a text control and it worked just fine.

                  Usually when it shows the expression rather than the result, it means there is a problem with the expression.

                  What kind of control are you using, and how (text property?) are you using the expression?

                  Comment


                  • #10
                    Originally posted by bjacobson View Post
                    I just used =variable("V1")+"concat" in a text control and it worked just fine.

                    Usually when it shows the expression rather than the result, it means there is a problem with the expression.

                    What kind of control are you using, and how (text property?) are you using the expression?

                    Well I'll be a sunamagun! That worked for me when I copied/pasted it into the text property of a text control. I must have had a space in there somewhere that screwed it up. Thanks!


                    SABarber, I was thinking something similar. I declared a Local Variable in the advanced properties of TheFrame, then during the EventInitialize event I set the value of the variable using the bjacobson method: =variable("V1").

                    Thanks for the help, guys!

                    Comment


                    • #11
                      Glad you got it working. You know, I just realized my 2nd post above was exactly what you had in your initial post. lol. Doh!

                      Comment

                      Related Topics

                      Collapse

                      Working...
                      X