hexagon logo

Flow Control - Check for Typos

Good Morning,

We have a CMM program where the operator uses a comment input to type in the machine number for the part being inspected. I would like to reference a text file with all of the acceptable machine numbers to prevent typos. I know I can use a form, but we frequently change machine numbers and I would like to be able to quickly edit a simple text file as needed. I would appreciate any help on ways to do this.

Thanks,
Ben
  • Pseudo-code:

    Populate your textfile
    Read the contents of the textfile into an array (in PC-DMIS)
    Check the array for the operator input
    Do your flow control magic
  • I have my input program read in a text file of all the operator names/numbers and all the machines. they are then selected thru a pull down menu.
  • Moolvie do you mind sharing an example notepad file and how you do this?
  • Not at all.
    This is the machine text file named MachineList.txt:

    000 None
    001 Vendor
    101 Barfeeder
    102 Doosan QL30
    103 400 #1
    104 400X
    105 Workcell #1
    106 Workcell #2
    156 Workcell
    213 300 Live
    107 300 #1
    108 300 #2
    109 Hankook VTB 140
    110 Hankook VTC 140
    111 400 #3 (In back)
    112 700
    113 2500 TT
    114 7NB
    115 Hankook VTC 200
    116 Hankook VTC 160
    117 12LB
    118 Hankook VTC 100
    201 A51A
    202 A51B
    203 Brother
    204 VC 510
    205 V65
    206 Toyoda
    207 Hurco
    208 A82
    209 A92
    210 A82M
    211 A81
    212 Toyoda FH450S
    213 DMG


    And The operator list named EmployeeList.txt:

    000 None
    001 Vendor
    002 Customer
    268 Ted B. (268)
    330 Dan C. (330)
    129 Dave E. (129)
    315 Andre G. (315)
    228 Dan G. (228)
    109 Sim G. (109)
    325 Melvin J.(325)
    329 John J. (329)
    298 Mike K. (298)
    297 James M. (297)
    125 Duane M. (125)
    272 Thomas N.(272)
    295 Bryce R. (295)
    288 Walt R. (288)
    227 Talon S.(227)
    337 Ray S. (337)
    163 David S. (163)
    105 Dave S. (105)
    103 Jeff S. (103)
    104 Jon S.(104)
    332 Tim S. (332)
    313 Eric S. (313)
    333 John T. (333)
    116 Tim W. (116)
    267 Blair W. (267)
    276 Spencer W. (276)
    317 Joe Y. (317)
    334 Ken M. (334)


    Now when I read them in I split into # and name. I see the name and number in parantheses in my pull down. But the program puts just the number in my custom header. Same for the machine list, it gets split too.
    Here is the code for reading in and splitting:

    Sub Main()
    Dim PCDApp, PCDPartPrograms, PCDPartProgram, PCDCommands, PCDCommand As Object
    Dim Partnumber, Partname, Supplier, Count%, ECount%, TextLine, EmpList$ ( ), EmpNum% ( ), MachName$ ( ), MachNum% ( ), last$
    Dim strPrgName$, strNewName$, strNoExt$, strPath$, FindDot
    
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set PCDPartPrograms = PCDApp.PartPrograms
    Set PCDPartProgram = PCDApp.ActivePartProgram
    Set PCDCommands = PCDPartProgram.Commands
    
    
    For Each PCDCommand In PCDCommands
    If PCDCommand.Type = ASSIGNMENT Then
    
    If PCDCommand.GetText(DEST_EXPR,0) = "SRN" Then
    blr = PCDCommand.GetText(SRC_EXPR,0)
    bll = Len(blr)
    Sam = Mid(blr,2,bll-2)
    PCDCommand.ReDraw
    End If
    
    End If
    
    Next PCDCommand
    
    
    
    
    ' Read In the list of employess With clock numbers
    Let Count = "1"
    Open "S:\CNC Programs\Unedited From Office\Doug\CMM Programs\EmployeeList.txt" For Input As #1
    Do While Not EOF(1)
          Line Input #1, Textline
          Count = Count + 1
    Loop
    Close #1
     
     ReDim EmpList$ (Count)
     ReDim  EmpNum% (Count)
    
    Let ECount = "0"
    
    ' Separate out the clock number And Employee And Put them In re-dimensioned arrays
    Open "S:\CNC Programs\Unedited From Office\Doug\CMM Programs\EmployeeList.txt" For Input As #1
    Do While Not EOF(1)
          Line Input #1, Textline
          EmpNum (ECount) = Left(Textline, 3)
          EmpList (ECount) = Right(Textline, Len(Textline)-3)
          ECount = ECount + 1
    Loop
    Close #1
    
    ' Read In a list of machines With numbers
    Let Count = "1"
    Open "S:\CNC Programs\Unedited From Office\Doug\CMM Programs\MachineList.txt" For Input As #1
    Do While Not EOF(1)
          Line Input #1, Textline
          Count = Count + 1
    Loop
    Close #1
      
    ReDim MachName$(Count)
    ReDim MachNum%(Count)
    
    ' Separate machine And number into their own arrays
    Let ECount = "0"
    Open "S:\CNC Programs\Unedited From Office\Doug\CMM Programs\MachineList.txt" For Input As #1
    Do While Not EOF(1)
          Line Input #1, Textline
          MachNum (ECount) = Left(Textline, 3)
          MachName(ECount) = Right(Textline, Len(Textline)-3)
          ECount = ECount + 1
    Loop
    
    ' a list of inspectors
    Dim NameList$ (3)
      NameList (0) = "None"
      NameList (1) = "Doug"
      NameList (2) = "Andréa"
      NameList (3) = "John"
    
    ' And their employee numbers
    Dim MyList$ (3)
      MyList (0) = " 0 "
      MyList (1) = " 205 "
      MyList (2) = " 320 "
      MyList (3) = " 333 "
    
    ' Code for dialog box starts here ...
     
    

    I hard code the inspectors into the program because there aren't that many of us. You can also see in the code I am dynamically allocating space for the employee and machine arrays so as the people and machines come and go, it resizes.

    I have a custom menu button that runs a macro to load this input program at the beginning of every program I write. It also lives on the network with the text files so all the seats of PC-DMIS can read it.

    Also the first little bit of code before reading in the list, grabs the serial number of the last run. The sample Dialog I pasted in my previous post had an SRN of "NEW" which my macro automatically puts in a new program, after that this program updates the serial number and keeps track of it because I use it in my autosave program.
  • I'll give this a try. Thank you very much for your support.