#### Sample Automation Script 2

The following script receives an operator name from the user and then inserts an COMMENT/OPER command into the Edit window for the currently open part program, displaying the name of the operator.

PC-DMIS must be running with an open part program in the background.

Sub Main
'Get operator Name And assign it To variable: N$.
N$ = InputBox$("Please enter your name:", "Operator", "", 200, 175)
'The following section adds a comment cmd to the part program
Dim App As Object
'Get the pointer to the PC-DMIS application
Set App = CreateObject("PCDLRN.Application")
Dim Part As Object
'Get the pointer to the current part program
Set Part = App.ActivePartProgram
Dim Cmds As Object
'Get the pointer to the set of commands In the part program
Set Cmds = Part.Commands
Dim Cmd As Object
'Add a COMMENT command
Set Cmd = Cmds.Add(SET_COMMENT, True)
'Set the comment's type to REPT
retvaltype = Cmd.PutText("REPT", COMMENT_TYPE, 0)
'Put the string held in variable N$ into the comment's text
retvaltext = Cmd.PutText(N$, COMMENT_FIELD, 1)
'Redraws the COMMENT command so that the applied changes are applied to the part program
Cmd.ReDraw
End Sub