hexagon logo

Operator Login

here is a basic script for a simple operator login.

Sub[SIZE=2][COLOR=#000000] Main[/COLOR]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Begin[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dialog[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] DIALOG_1 50,10, 300, 125, oOPERATORINPUT[/COLOR]
GroupBox 5,5,210,25
Text 20,15,85,12, "Enter Operator :"
TextBox 85,13,50,12, .EditBox_1
GroupBox 5,35,210,25
Text 20,45,85,12, "Enter Job # :"
TextBox 95,43,50,12, .EditBox_2
GroupBox 5,65,210,25
Text 20,75,85,12, "Enter Sample # :"
TextBox 105,73,50,12, .EditBox_3
GroupBox 5,95,210,25
Text 20,105,85,12, "Shift # :"
Text 50, 105,85,12, "1st"
CheckBox 63,103,20,12, .CheckBox_1
Text 85, 105,85,12, "2nd"
CheckBox 98,103,20,12, .CheckBox_2
Text 120, 105,85,12, "3rd"
CheckBox 133,103,20,12, .CheckBox_3 
OKButton 225,80,48,15
CancelButton 225,100,48,16
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dialog
Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] Dialg [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] DIALOG_1[/COLOR]
button1 = Dialog(Dialg)
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] Progtype [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String
If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] button1 = 0 [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]Progtype= "END"
Else
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] App, Part, Cmds, Cmd [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Object
Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] App = CreateObject("PCDLRN.Application")[/COLOR]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] Part = App.ActivePartProgram[/COLOR]
Set Cmds = Part.Commands
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] Samp [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String
Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] Shift [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]Oper = Dialg.EditBox_1
Job = Dialg.EditBox_2
Samp = Dialg.EditBox_3
shift_1 = Dialg.Checkbox_1
shift_2 = Dialg.Checkbox_2
shift_3 = Dialg.Checkbox_3
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] shift_1 = 1 [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]Shift = ("1st")
End If
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] shift_2 = 1 [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]Shift =("2nd")
End If
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] shift_3 = 1 [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]Shift =("3rd")
End If
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If
For[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] Cmd [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] Cmds[/COLOR]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Cmd.[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Type[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = ASSIGNMENT [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Cmd.GetText(DEST_EXPR, 0) = "OPERATOR" [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]bln = Cmd.PutText("""" + Oper + """", SRC_EXPR, 0)
Cmd.ReDraw
End If
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Cmd.GetText(DEST_EXPR, 0) = "JOB" [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]bln = Cmd.PutText("""" + Job + """", SRC_EXPR, 0)
Cmd.ReDraw
End If
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Cmd.GetText(DEST_EXPR,0) = "SAMP" [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]bln = Cmd.PutText("""" + Samp + """", SRC_EXPR, 0)
Cmd.ReDraw
End If 
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Cmd.GetText(DEST_EXPR,0) = "SHIFT" [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]bln = Cmd.PutText("""" + Shift + """", SRC_EXPR, 0)
Cmd.ReDraw
End If 
End If
Next Cmd
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][/COLOR][/SIZE]


put these variables in the program after the script

ASSIGN/OPERATOR = "Ryan"
ASSIGN/JOB = "99999"
ASSIGN/SAMP = "23"
ASSIGN/SHIFT = "1st"


Does anyone have any insight on how to store the last inputed information? be it a csv file or anything else.

Credit goes to the forum. I pieced it together.
  • My code here has a (very) simple snippet that writes stuff to a textfile:

    http://www.pcdmisforum.com/showthread.php?26972-Program-execution-logger-script

    Maybe that can help you on your way.
  • Yeah I am currently implementing your logger file btw lol Slight smile. I will see if I can make it work, I didn't know if there was a simpler means. I'm going to see if I can change it up to log job numbers and sample number in a txt. file located in the program directory. That way it's a log file per program.
  • Well logger complete

    ' A very simple program execution logger by vpt.se modifed by Rploughe
    [SIZE=2]'
    ' Assign variables In your PC-DMIS program:
    [/SIZE][SIZE=2][COLOR=#007f00][SIZE=2][COLOR=#007f00]' Assign/OPERATOR=""
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]' Assign/JOB=""
    [/SIZE][SIZE=2][COLOR=#007f00][SIZE=2][COLOR=#007f00]' Assign/Samp=""
    ' Assign a variable In your PC-DMIS program called WATCHER that is empty:
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]' ASSIGN/WATCHER=""
    ' 
    [/SIZE][SIZE=2][COLOR=#007f00][SIZE=2][COLOR=#007f00]' Call the script And it will look For the variable, when found And the
    ' contents of WATCHER is "" it will Write the JOB+OPERATOR+SAMP
    ' To a file In Program Directory called 'proglog.txt'
    ' The script will change the WATCHER value To "TRUE" indicating that the program
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]' is running.
    '
    [/SIZE][SIZE=2][COLOR=#007f00][SIZE=2][COLOR=#007f00]' At the End of the PC-DMIS program, Call the script again And it will look
    ' For WATCHER again, And If the contents of WATCHER is "TRUE" it will treat
    ' this As the program has finished measuring And Write the End time
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]' To "C:\proglog.txt"
    '
    [/SIZE][SIZE=2][COLOR=#007f00][SIZE=2][COLOR=#007f00]' vpt.se In 2011 (Original)+Rploughe In 2014(modified)
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]
    Sub Main
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDApp, PCDPartPrograms, PCDPartProgram, PCDCommands, varname, opname, joname, sampname, wvar[/COLOR]
    Dim sstate, Fname As String
    
    'Initialization
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDApp = CreateObject("PCDLRN.Application")[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDPartPrograms = PCDApp.PartPrograms[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDPartProgram = PCDApp.ActivePartProgram[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDCommands = PCDPartProgram.Commands[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]
    Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] opname = PCDPartProgram.GetVariableValue ("OPERATOR")[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] joname = PCDPartProgram.GetVariableValue ("JOB")[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] sampname = PCDPartProgram.GetVariableValue ("SAMP")[/COLOR]
    
    Fname = joname.Stringvalue & " " & opname.Stringvalue & " " & sampname.Stringvalue & " "
     
    'Assignment To look For
    varname = "WATCHER"
    [/SIZE][SIZE=2][COLOR=#007f00][SIZE=2][COLOR=#007f00]
    ' Is it enabled?
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]sstate = ""
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]
    For[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] cnt = 1 [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDCommands.Count[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PCDCommand = PCDCommands.Item(cnt)
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ((PCDCommand.[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Type[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = 195) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]And[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (varname = PCDCommand.GetText(DEST_EXPR, 0))) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]wvar = PCDCommand.GetText(SRC_EXPR, 0)
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]
    If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] wvar = """""" [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 
    sstate = " started @ "
    retval = PCDCommand.PutText("""TRUE""", SRC_EXPR, 0)
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]
    If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] wvar = """TRUE""" [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]sstate = " ended @ "
    retval = PCDCommand.PutText("""""", SRC_EXPR, 0)
    End If
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]
    Open[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PCDpartprogram.Path & "proglog.txt" [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Append[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] #1
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Write[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] #1, Fname & sstate & Date & " " & Time(Now)
    
    Close #1
    End If
    Next
    
    'Cleanup
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDPartProgram = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing
    Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDPartPrograms = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing
    Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDApp = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]End Sub
    [/SIZE]
    


    I was talking more along the lines of having the last inputed values show up in the text box upon re-execution of the script VPT.se. I will see if I can fiddle with some things to get it to work. Maybe put a text string with something like last inputed value = and just update it upon new input.
  • Thanks for sharing and keep fiddling - you will learn from it.