I'm new at VB programming inside PCDMIS. The first thing I'm trying to do is to get a variable from the part program and use it inside the script. What I've done is to follow the example wich comes in the pcdmis basic help file:
Inside the part program:
C1=COMMENT/INPUT,Please type an integer value.
ASSIGN/V1 = INT(C1.INPUT)
COMMENT/OPER,BEFORE SCRIPT: Variable is: ,V1
CS1=SCRIPT/FILENAME= D:\PROGRAM FILES\PCDMIS35\TEST2.BAS
FUNCTION/Main,,
STARTSCRIPT/
ENDSCRIPT/
and the script is the following:
Sub Main
Dim App As Object
Set App = CreateObject ("PCDLRN.Application")
Dim Part As Object
Set Part = App.ActivePartProgram
Dim Var As Object
Set Var = Part.GetVariableValue ("V1")
Dim I As Object
If Not Var Is Nothing Then
Var.LongValue = Var.LongValue + 1
Part.SetVariableValue "V1", Var
MsgBox "V1 is now: " & Var
Else
Msgbox "Could Not find variable"
End If
End Sub
the problem is that when I run the program, or the script from inside the basic editor, i get this error
OLE Automation object does not have a default value
I've been able to get the variable from the program to the script, that's OK. But now, how to write variables from the script to the program??
I've made this
Sub Main(var As Integer)
Dim App As Object
Set App = CreateObject ("PCDLRN.Application")
Dim Part As Object
Set Part = App.ActivePartProgram
var = var +10
Part.SetVariableValue "V1", Var
End Sub
But I get a "type mismatch" error
In the help there's something like this
The GetVariableValue and SetVariableValue methods only change a variable's value during the script's execution. If you want to permanently change a value of a variable inside PC-DMIS, you should use the PutText method instead.
what does this mean?
I only want to open an operator comment showing me the new value of V1
I've been able to get the variable from the program to the script, that's OK. But now, how to write variables from the script to the program??
I've made this
Sub Main(var As Integer)
Dim App As Object
Set App = CreateObject ("PCDLRN.Application")
Dim Part As Object
Set Part = App.ActivePartProgram
var = var +10
Part.SetVariableValue "V1", Var
End Sub
But I get a "type mismatch" error
In the help there's something like this
The GetVariableValue and SetVariableValue methods only change a variable's value during the script's execution. If you want to permanently change a value of a variable inside PC-DMIS, you should use the PutText method instead.
what does this mean?
I only want to open an operator comment showing me the new value of V1