Operator Login

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Operator Login

    here is a basic script for a simple operator login.

    Code:
    Sub Main
    BeginDialog DIALOG_1 50,10, 300, 125, oOPERATORINPUT
    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
    EndDialog
    Dim Dialg As DIALOG_1
    button1 = Dialog(Dialg)
    Dim Progtype AsString
    If button1 = 0 Then
    Progtype= "END"
    Else
    Dim App, Part, Cmds, Cmd AsObject
    Set App = CreateObject("PCDLRN.Application")
    Set Part = App.ActivePartProgram
    Set Cmds = Part.Commands
    Dim Samp AsString
    Dim Shift AsString
    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
    If shift_1 = 1 Then
    Shift = ("1st")
    End If
    If shift_2 = 1 Then
    Shift =("2nd")
    End If
    If shift_3 = 1 Then
    Shift =("3rd")
    End If
    EndIf
    ForEach Cmd In Cmds
    If Cmd.Type = ASSIGNMENT Then
    If Cmd.GetText(DEST_EXPR, 0) = "OPERATOR" Then
    bln = Cmd.PutText("""" + Oper + """", SRC_EXPR, 0)
    Cmd.ReDraw
    End If
    If Cmd.GetText(DEST_EXPR, 0) = "JOB" Then
    bln = Cmd.PutText("""" + Job + """", SRC_EXPR, 0)
    Cmd.ReDraw
    End If
    If Cmd.GetText(DEST_EXPR,0) = "SAMP" Then
    bln = Cmd.PutText("""" + Samp + """", SRC_EXPR, 0)
    Cmd.ReDraw
    End If 
    If Cmd.GetText(DEST_EXPR,0) = "SHIFT" Then
    bln = Cmd.PutText("""" + Shift + """", SRC_EXPR, 0)
    Cmd.ReDraw
    End If 
    End If
    Next Cmd
    EndSub
    
    put these variables in the program after the script

    Code:
    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.

  • #2
    My code here has a (very) simple snippet that writes stuff to a textfile:

    http://www.pcdmisforum.com/showthrea...-logger-script

    Maybe that can help you on your way.
    PC-DMIS CAD++ 2o19 R1 SP11

    Comment


    • #3
      Yeah I am currently implementing your logger file btw lol . 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.

      Comment


      • #4
        Well logger complete

        Code:
        ' A very simple program execution logger by vpt.se modifed by Rploughe
        '
        ' Assign variables In your PC-DMIS program:
        ' Assign/OPERATOR=""
        ' Assign/JOB=""
        ' Assign/Samp=""
        ' Assign a variable In your PC-DMIS program called WATCHER that is empty:
        ' ASSIGN/WATCHER=""
        ' 
        ' 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
        ' is running.
        '
        ' 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
        ' To "C:\proglog.txt"
        '
        ' vpt.se In 2011 (Original)+Rploughe In 2014(modified)
        
        Sub Main
        Dim PCDApp, PCDPartPrograms, PCDPartProgram, PCDCommands, varname, opname, joname, sampname, wvar
        Dim sstate, Fname As String
        
        'Initialization
        Set PCDApp = CreateObject("PCDLRN.Application")
        Set PCDPartPrograms = PCDApp.PartPrograms
        Set PCDPartProgram = PCDApp.ActivePartProgram
        Set PCDCommands = PCDPartProgram.Commands
        
        Set opname = PCDPartProgram.GetVariableValue ("OPERATOR")
        Set joname = PCDPartProgram.GetVariableValue ("JOB")
        Set sampname = PCDPartProgram.GetVariableValue ("SAMP")
        
        Fname = joname.Stringvalue & " " & opname.Stringvalue & " " & sampname.Stringvalue & " "
         
        'Assignment To look For
        varname = "WATCHER"
        
        ' Is it enabled?
        sstate = ""
        
        For cnt = 1 To PCDCommands.Count
        Set PCDCommand = PCDCommands.Item(cnt)
        If ((PCDCommand.Type = 195) And (varname = PCDCommand.GetText(DEST_EXPR, 0))) Then
        wvar = PCDCommand.GetText(SRC_EXPR, 0)
        
        If wvar = """""" Then 
        sstate = " started @ "
        retval = PCDCommand.PutText("""TRUE""", SRC_EXPR, 0)
        EndIf
        
        If wvar = """TRUE""" Then
        sstate = " ended @ "
        retval = PCDCommand.PutText("""""", SRC_EXPR, 0)
        End If
        
        Open PCDpartprogram.Path & "proglog.txt" ForAppendAs #1
        Write #1, Fname & sstate & Date & " " & Time(Now)
        
        Close #1
        End If
        Next
        
        'Cleanup
        Set PCDPartProgram = Nothing
        Set PCDPartPrograms = Nothing
        Set PCDApp = Nothing
        End Sub
        
        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.
        Last edited by Rploughe; 01-22-2014, 07:27 AM.

        Comment


        • #5
          Thanks for sharing and keep fiddling - you will learn from it.
          PC-DMIS CAD++ 2o19 R1 SP11

          Comment


          • #6
            or break something.

            Comment

            Related Topics

            Collapse

            Working...
            X