hexagon logo

Reset to nominals

Here's one...

I got it from WILCOX
  • Try this:

    Set MyVar = MyPartProgram.GetVariableValue ("TIMETOMOVE")
    MsgBox (MyVar.LongValue)
    

    See what that returns.

    TimeToMove is your PCDMIS variable, once you point to it with MyVar you need to reference MyVar when you want TimeToMove.

    Craig
  • Here is how you may want the .bas

    Sub Main
      Dim MyApp As Object
      Set MyApp = CreateObject ("PCDLRN.Application")
      Dim MyPartProgram As Object
      Set MyPartProgram = MyApp.ActivePartProgram
      Dim MyVar As Object
      Set MyVar = MyPartProgram.GetVariableValue ("TIMETOMOVE")
      MSGBOX Myvar.LongValue
        If Not MyVar Is Nothing Then
          MyVar.LongValue = MyVar.LongValue + 1
          MyPartProgram.SetVariableValue "TIMETOMOVE", MyVar
          MsgBox "V1 is now: " & CStr(MyVar.LongValue)
        Else
          Msgbox "Could Not find variable"
        End If 
    End Sub
    


    I'm not sure if the CStr is needed but you could try it (I'd try it without it too, I'm thinking it is not neded). I also removed a declaration of I = Object, it was not being referenced after the declaration. Let me know how you make out.

    Craig
  • the silly command just doesn't work...

    just before calling the script, the TIMETOMOVE variable is equal to 120.

    IN the script and just after using the GETVARIABLEVALUE command, the MyVar value is 0.

    after resetting MyVar to 6, the MyVar value is the new value (6).

    The SETVARIABLEVALUE command works because AFTER the script finishes, the TIMETOMOVE variable is equal to 6.

    Thanks for your help. Must be a bug in the GETVARIABLEVALUE method.

    Keith
  • GetVariableValue works perfectly for me and I, like you, am using 3.7. I'm going to run the most recent script I posted here and I'll let you know how it goes. Who knows perhaps the problem is using GetVariableValue on a variable that contains the syntax C1.INPUT * 60. I'll get back with you.

    Craig
  • Thanks.

    I did put c1.input in an INT() function, then multiply by 60. I'll try not multiplying at all.
  • HOLY COW!

    I took out the *60 and it worked!!!

    I changed that line to
    ASSIGN/TIMETOMOVE = INT(C1.INPUT*60)
    and it worked perfectly!

    Thanks!
  • You can also pass variables directly to your sub from PCDMIS rather than getting it through automation. That would be another way of getting the data there and probably the safest since obviously it does not like some syntax.

    Craig
  • The help file says:

    The only supported variable types that can be passed into BASIC scripts from PC-DMIS are:

    Integer
    String
    Double


    I can get ONLY INTEGER to work, though... UNTIL I discovered that this form of BASIC requires that we specify the value of the MyVar object as LongValue, DoubleValue, or StringValue, etc. The variable type in the part program MUST match the variable usage in the BASIC program.

    Thanks for your help...