Assignment Values Not Updating Properly

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

  • Assignment Values Not Updating Properly

    I am having a problem with my assignment values not properly updating after being set in my Basic script. If I put my cursor on the line that calls the Basic script in the edit window of my part program; press F9 to edit the script; and simply execute the script, everything works great. I can immediately see in the part program edit window that my assignment values have changed to the values being sent from the script. But, if I execute the part program, these values do not change until after the part program has finished running...so, I am forced to run each part program using the assigned values from the previous part program run.

    I didn't know if I am overlooking some setting that updates the values after the program run or what? I am using PC-DMIS 2011 MR1

    In my Basic file, I create an Application Object and a Part Object:

    Dim PCDMISAPP as Object
    Dim PCDMISPart as Object

    Set PCDMISAPP = CreateObject("PCDLRN.Application")
    Set PCDMISPart = PCDMISAPP.ActivePartProgram

    '//Declare variables. Ex.:

    Dim Serial as String

    Serial = "ABC123"

    '//Then I create 2 command objects and assign my Basic Variable value to my PC-DMIS variable

    Dim Cmds as Object
    Dim Cmd as Object

    Set Cmds = PCDMISPart.Commands

    For Each Cmd In Cmds
    If Cmd.Type = ASSIGNMENT Then
    If Cmd.GetText(DEST_EXPR, 0) = "SerialNumber" Then
    bln = Cmd.PutText("""" + Serial + """", SRC_EXPR, 0)
    Cmd.ReDraw
    End If
    End IF
    Next Cmd

    And then in my PC-DMIS part program, before I call this script, I Assign SerialNumber = ""

    ASSIGN/SerialNumber = ""

    Granted, I am simply mimicking what was already set in place in the way of passing values to PC-DMIS assignments from a Basic script by my predecessor, who passed away; so, I am not entirely sure how the GetText, PutText, and ReDraw functions do or what the bln is.

    Anyway, any help would be greatly appreciated why the values update when I simply execute the Basic file and why they don't update until after the part program runs if I execute the part program.

    Thank you!



  • #2
    Maybe you should post the entire sub in the sample section of the forum, some guys of basics here could help you !

    Comment


    • #3
      I'm at home now and can't check, but it is easier to get/set variables with the GetVariable/SetVariable functions. I've never seen those not update the variable in the program.

      There is an example in the PC-DMIS Help.
      AndersI
      SW support - Hexagon Metrology Nordic AB

      Comment


      • #4
        Thank you JefMan and Andersl for your advice. The Get/SetVariableValue functions work like a charm!

        I'm not sure how to assign you credit for the solution; but, I greatly appreciate your help.

        Comment

        Loading...
        Working...
        X