hexagon logo

Broken Script

Hey all. I hope someone can help me. This won't run Confused

I'm using 4.2 MR3

Sub Main

Begin Dialog DIALOG_1 53,9, 211, 287, "Dialog One", .enable
  OptionGroup .GROUP_1
    OptionButton 16,80,80,12, "1st Piece Sign-Off"
    OptionButton 16,96,80,12, "In-Process Scan"
    OptionButton 16,112,84,12, "Audit"
  GroupBox 4,4,200,280, " "
  TextBox 40,156,32,12, .EditBox_1
  TextBox 40,176,32,12, .EditBox_2
  TextBox 40,196,32,12, .EditBox_3
  TextBox 40,216,32,12, .EditBox_4
  Text 16,140,52,12, "Enter Scan #'s:"
  Text 16,64,72,12, "Enter Scan Type:"
  Text 16,236,180,12, "NOTE: Enter Scan #'s in the station you want to run."
  Text 16,156,24,12, "ST 1:"
  Text 16,176,24,12, "ST 2:"
  Text 16,196,24,12, "ST 3:"
  Text 16,216,24,12, "ST 4:"
  Text 64,20,76,12, "Enter Work Order #:"
  TextBox 64,36,72,12, .EditBox_5
  OKButton 16,260,48,16
  CancelButton 140,260,48,16
End Dialog

Dim app As Object 
Set App = CreateObject("pcdlrn.Application") 

Dim part As Object 
Set Part = App.activePartProgram 

Dim cmds As Object 
Dim cmd As Object 

Dim dlg1 As Menu 
button = Dialog( Dlg1 ) 

Dim sel_text As String 
Dim STATION1 As String 
Dim STATION2 As String 
Dim STATION3 As String 
Dim STATION4 As String 
Dim WORKORDER As String 

If button = 0 Then
    sel_text = "END"
End If

If button = -1 Then 
    Select Case Dlg1.GROUP_1 
        Case 0 
            sel_text = "SIGN-OFF"
        Case 1 
            sel_text = "IN-PROCESS"
        Case 2 
            sel_text = "AUDIT"
    End Select 

    STATION1 = Dlg1.EditBox_1
    STATION2 = Dlg1.EditBox_2
    STATION3 = Dlg1.EditBox_3
    STATION4 = Dlg1.EditBox_4

    WORKORDER = Dlg1.EditBox_5
End If 

Set cmds = part.Commands 
For Each cmd In cmds 

If cmd.TypeDescription = "Assignment" Then 
    If cmd.gettext(dest_expr,0) = "TYPE" Then
        bln = cmd.PutText("""" + sel_text + """", SRC_EXPR, 0)
        cmd.ReDraw
    End If 
    If cmd.gettext(dest_expr,0) = "ST1" Then
        bln = cmd.PutText("""" + STATION1 + """", SRC_EXPR, 0)
        cmd.ReDraw
    End If 
    If cmd.gettext(dest_expr,0) = "ST2" Then
        bln = cmd.PutText("""" + STATION2 + """", SRC_EXPR, 0)
        cmd.ReDraw
    End If 
    If cmd.gettext(dest_expr,0) = "ST3" Then
        bln = cmd.PutText("""" + STATION3+ """", SRC_EXPR, 0)
        cmd.ReDraw
    End If 
    If cmd.gettext(dest_expr,0) = "ST4" Then
        bln = cmd.PutText("""" + STATION4 + """", SRC_EXPR, 0)
        cmd.ReDraw
    End If 
    If cmd.gettext(dest_expr,0) = "WO" Then
        bln = cmd.PutText("""" + WORKORDER+ """", SRC_EXPR, 0)
        cmd.ReDraw
    End If 
End If 

End Sub
  • Sub Main
    
    ' The following variables must have been assigned In the PC-DMIS partprogram:
    ' Type
    ' ST1
    ' ST2
    ' ST3
    ' ST4
    ' WO
    
    ' Setup the Dialog
    Begin Dialog DIALOG_1 53,9, 211, 287, "Dialog One", .enable
      OptionGroup .GROUP_1
        OptionButton 16,80,80,12, "1st Piece Sign-Off"
        OptionButton 16,96,80,12, "In-Process Scan"
        OptionButton 16,112,84,12, "Audit"
      GroupBox 4,4,200,280, " "
      TextBox 40,156,32,12, .EditBox_1
      TextBox 40,176,32,12, .EditBox_2
      TextBox 40,196,32,12, .EditBox_3
      TextBox 40,216,32,12, .EditBox_4
      Text 16,140,52,12, "Enter Scan #'s:"
      Text 16,64,72,12, "Enter Scan Type:"
      Text 16,236,180,12, "NOTE: Enter Scan #'s in the station you want to run."
      Text 16,156,24,12, "ST 1:"
      Text 16,176,24,12, "ST 2:"
      Text 16,196,24,12, "ST 3:"
      Text 16,216,24,12, "ST 4:"
      Text 64,20,76,12, "Enter Work Order #:"
      TextBox 64,36,72,12, .EditBox_5
      OKButton 16,260,48,16
      CancelButton 140,260,48,16
    End Dialog
    
    Dim Dlg1 As DIALOG_1
    button = Dialog(Dlg1) 
    
    Dim sel_text As String 
    Dim STATION1 As String 
    Dim STATION2 As String 
    Dim STATION3 As String 
    Dim STATION4 As String 
    Dim WORKORDER As String
    
    If button = 0 Then
        sel_text = "END"
    Else
    Select Case Dlg1.GROUP_1 
            Case 0 
                sel_text = "SIGN-OFF"
            Case 1 
                sel_text = "IN-PROCESS"
            Case 2 
                sel_text = "AUDIT"
        End Select
    
    STATION1 = Dlg1.EditBox_1
    STATION2 = Dlg1.EditBox_2
    STATION3 = Dlg1.EditBox_3
    STATION4 = Dlg1.EditBox_4
    WORKORDER = Dlg1.EditBox_5
    End If
    ' Dialog setup End
    
    'Setup PC-DMIS Connection
    Dim App As Object
    Set App = CreateObject("PCDLRN.Application")
    
    Dim Part As Object
    Set Part = App.ActivePartProgram
    
    Dim Cmds As Object
    Dim Cmd As Object
    
    Set Cmds = Part.Commands
    
    For Each Cmd In Cmds
        If Cmd.Type = ASSIGNMENT Then
            If Cmd.GetText(DEST_EXPR, 0) = "TYPE" Then
              bln = Cmd.PutText("""" + sel_text + """", SRC_EXPR, 0)
              Cmd.ReDraw
            End If
            If Cmd.GetText(DEST_EXPR,0) = "ST1" Then
              bln = Cmd.PutText("""" + STATION1 + """", SRC_EXPR, 0)
              Cmd.ReDraw
            End If
            If Cmd.GetText(DEST_EXPR,0) = "ST2" Then
              bln = Cmd.PutText("""" + STATION2 + """", SRC_EXPR, 0)
              Cmd.ReDraw
            End If
            If Cmd.GetText(DEST_EXPR,0) = "ST3" Then
              bln = Cmd.PutText("""" + STATION3 + """", SRC_EXPR, 0)
              Cmd.ReDraw
            End If
            If Cmd.GetText(DEST_EXPR,0) = "ST4" Then
              bln = Cmd.PutText("""" + STATION4 + """", SRC_EXPR, 0)
              Cmd.ReDraw
            End If
            If Cmd.GetText(DEST_EXPR,0) = "WO" Then
              bln = Cmd.PutText("""" + WORKORDER + """", SRC_EXPR, 0)
              Cmd.ReDraw
            End If
        End If
    Next Cmd
    
    End Sub


    Enjoy.
  • I copied it in and replaced the entire script. But it didn't work. Here's what the PC-DMIS program looks like. Maybe it's something there.

    CS1 =SCRIPT/FILENAME= C:\CMM\SCRIPTS\MENU.BAS
    FUNCTION/Main,SHOW=YES,,
    STARTSCRIPT/
    ENDSCRIPT/
    ASSIGN/TYPE=0
    ASSIGN/ST1=0
    ASSIGN/ST2=0
    ASSIGN/ST3=0
    ASSIGN/ST4=0
    ASSIGN/WO=0

    Is there a setting or anything I need to do to enable scripts?
  • The message I get is a PC-DMIS error message.

    Error executing basic script!
    C:\CMM\SCRIPTS\MENU.BAS:Main
  • The same program, BAS file work on our off-line station, but won't work online. Both running the same version of PC-DMIS.
  • It works here, CAD++ v4.2MR3, I guess it's some local problem?

    CS1        =SCRIPT/FILENAME= C:\MENU.BAS
                FUNCTION/Main,SHOW=YES,,
                STARTSCRIPT/
                ENDSCRIPT/
                ASSIGN/TYPE="SIGN-OFF"
                ASSIGN/ST1="1"
                ASSIGN/ST2="2"
                ASSIGN/ST3="3"
                ASSIGN/ST4="4"
                ASSIGN/WO="123123"
  • We found what it was; someone on the other shift was messing around in the registry. Thanks for the help.

    One quick question though... is it possible to take an assignment in the PC-DMIS program and populate the script? We'll have to type in the work order number every time, compared to the old way which was using an input comment.
  • You should be able to use GetVariableValue (look it up in the PCDBASIC helpfile) in order to 'read' a variable from your PC-DMIS partprogram.