Current Help System: PC-DMIS BASIC (View Core Help)

#### Sample Automation Script 4

This script shows how to pass a variable's ID into a script from a PC-DMIS part program, how to locate the passed in ID in the script, and then how to modify the right side of the ASSIGN command associated with the ID.

Sample Part Program Code:

This script takes one parameter, a variable's ID, supplied by your part program. When you execute this example part program code within PC-DMIS, an Input comment will appear, asking you for the variable's ID to change. Once you type that valid ID, PC-DMIS passes that ID into a script called SETASSIGNMENTVALUE.BAS.

START =LABEL/

C1 =COMMENT/INPUT,NO,'Type a variable's id: V1, V2, V3, V4, or V5.'

IF/C1.INPUT <> "V1" AND C1.INPUT <> "V2" AND C1.INPUT <> "V3" AND C1.INPUT

<> "V4" AND C1.INPUT <> "V5"

COMMENT/OPER,NO,You did not enter a correct variable ID.

GOTO/START

END_IF/

ELSE/

CS1 =SCRIPT/FILENAME= D:\MYAUTOMATIONSCRIPTS\SETASSIGNMENTVALUE.BAS

FUNCTION/Main,SHOW=YES,ARG1=C1.INPUT,,

STARTSCRIPT/

ENDSCRIPT/

ASSIGN/V1 = ""

ASSIGN/V2 = ""

ASSIGN/V3 = ""

ASSIGN/V4 = ""

ASSIGN/V5 = ""

END_ELSE/

SETASSIGNMENTVALUE.BAS Code:

Below is the code for SETASSIGNMENTVALUE.BAS. Once the script opens, it takes the passed in ID, cycles through all the commands, and when it finds the matching ID, it displays an input box asking you to specify a new value for the command:

Sub Main (strID As String)

Dim App As Object

Set App = CreateObject ("PCDLRN.Application")

Dim Part As Object

Set Part = App.ActivePartProgram

Dim Cmds As Object

Set Cmds = Part.Commands

Dim Cmd As Object

Dim FCCmd As Object

Dim VarCommentValue As Variant

VarCommentValue = InputBox("Type a Value for " & strID & ". (Surround what you Type With quotation marks To make it a String.)","Set Assignment Value","""Type Something Here""")

For Each Cmd In Cmds

If Cmd.TypeDescription = "Assignment" Then

Set FCCmd = Cmd.FlowControlCommand

If FCCmd.GetLeftSideOfExpression = strID Then

FCCmd.SetRightSideOfAssignment VarCommentValue

End If

End If

Next Cmd

End Sub