[Mi...] Posted April 27, 2023 Share Posted April 27, 2023 This code is part of a longer code that controls the header data at the start of runs. I need to change it, but what I need to do is likely going to become very inefficient using If statements, I suppose I could put a few "or" gates in and it would work... but can anybody give an idea of a better way? I need to efficiently react to 3 scenarios. 1: Machines 776, 1826, and 1555 – No pallets/Spindles 2: Machine 1546 – Unique Pallet System 3: Everything else with the 1L,2L,1R,2R System //-------------Machine Number Input Loop--------------------- //if nextLoop then repeat loopBreak=false mach=inquireList("Choose CNC Machine (Last Entered: "+curMachID+")","776","1502","1507","1529","1539","1540","1546","1555","1826") if mach=="" then loopBreak=confirm(cancelMess) if loopBreak then nextLoop=false programCancel=true endif else loopBreak=true nextLoop=true endif until loopBreak //endif //-------------Pallet/Spindle ID Input Loop--------------------- if (mach <> "776") and (nextLoop) then selectCase mach case "1546" repeat loopBreak=false pall=inquireList("Choose Pallet/Spindle ID (Last Entered: "+curPalletID+")","Pallet 1","Pallet 2") if pall=="" then loopBreak=confirm(cancelMess) if loopBreak then nextLoop=false programCancel=true endif else loopBreak=true nextLoop=true endif until loopBreak caseElse repeat loopBreak=false pall=inquireList("Choose Pallet/Spindle ID (Last Entered: "+curPalletID+")","1L","2L","1R","2R") if pall=="" then loopBreak=confirm(cancelMess) if loopBreak then nextLoop=false programCancel=true endif else loopBreak=true nextLoop=true endif until loopBreak endSelect endif Link to comment Share on other sites More sharing options...
[Mi...] Posted April 27, 2023 Author Share Posted April 27, 2023 Adding a reply, I did get this to work as intended... however there must be a better way. I'd love to see somebody else's method. //variables at the top of the file defineFunctionStart("MachineNumbers") mach=inquireList("Choose CNC Machine", "776","1502","1507","1529","1539","1540","1546","1826","1555") defineFunctionEnd(mach) singleSpindleMachines = "776","1826","1555" doubleLRPalletMachines = "1502","1507","1529","1539","1540" singleNumberedPalletMachines = "1546" //-------------Machine Number Input Loop--------------------- //if nextLoop then repeat loopBreak=false executeFunctionNamed("MachineNumbers") if mach=="" then loopBreak=confirm(cancelMess) if loopBreak then nextLoop=false programCancel=true endif else loopBreak=true nextLoop=true endif until loopBreak //endif //-------------Pallet/Spindle ID Input Loop--------------------- if (inStr(doubleLRPalletMachines,mach) <> 0) and (nextLoop) then repeat loopBreak=false pall=inquireList("Choose Pallet/Spindle ID (Last Entered: "+curPalletID+")","1L","2L","1R","2R") if pall=="" then loopBreak=confirm(cancelMess) if loopBreak then nextLoop=false programCancel=true endif else loopBreak=true nextLoop=true endif until loopBreak endif if inStr(singleNumberedPalletMachines,mach) <> 0) and (nextLoop) then repeat loopBreak=false pall=inquireList("Choose Pallet/Spindle ID (Last Entered: "+curPalletID+")","Pallet 1","Pallet 2") if pall=="" then loopBreak=confirm(cancelMess) if loopBreak then nextLoop=false programCancel=true endif else loopBreak=true nextLoop=true endif until loopBreak endif Link to comment Share on other sites More sharing options...
[Je...] Posted May 1, 2023 Share Posted May 1, 2023 Maybe this will help simplify your line qty. It would appear that you are complicating an error proofing function to force an input/value. Here is an example of how to prevent a non-entry, or "Cancel" from allowing progression in a much simpler fashion; if //any if statement to qualify starting the routine repeat line = inquireText("Operator Number") setRecordHead("line",line) until (line) <> "" endif The rest of it appears very one-off and there a million ways to do what you are trying to do. A matrix showing what is possible would be the best place to start so that a proper path can be established. Link to comment Share on other sites More sharing options...
[Mi...] Posted May 1, 2023 Author Share Posted May 1, 2023 Please sign in to view this quote. This is true, but having it be that simple doesn't cover all the scenarios that I will need to react to. One of which is letting the operators exit the repeat loop if they need to for whatever reason - but NOT have the code continue to execute. That's the reason for all the code. I don't want to trap the operators and force them to make a selection if they want to cancel. I'd have to post the entire code likely for another to understand fully. This is only a few lines of a much longer file. It seems cumbersome, but that part of it is very simple as it's made to be modular, just copy the whole repeat loop from where it is to where I need it saved. What I really need is a way to have the selection list in inquireList() be a variable without complicating it like I did - but I can't figure out a way to do that. THAT would save me lines like crazy. if //any if statement to qualify starting the routine repeat mach = inquireList("Choose CNC Machine (Last Entered: "+curMachID+")",variableName) until (mach) <> "" endif Link to comment Share on other sites More sharing options...
[Je...] Posted May 1, 2023 Share Posted May 1, 2023 Ah, I see. Let me dig into a few items but I think I have an idea. I'm thinking recalling the items .asList but I have to experiment. Link to comment Share on other sites More sharing options...
[Je...] Posted May 5, 2023 Share Posted May 5, 2023 Michael, Have you explored creating the specific machineIDs in a text file so that it can be recalled each time rather than continuing to reference the machine list via copy/paste? This also would allow for global edits in the event a machineID changes or is added/removed readListFile("c:/yourpath/file.txt") reads file and indexs every line. Instance Variables: readListFile("c:/yourpath/file.txt").sort readListFile("c:/yourpath/file.txt").asString readListFile("c:/yourpath/file.txt").asArray readListFile("c:/yourpath/file.txt").sort.asArray readListFile("c:/yourpath/file.txt").size You can also place this entire PCM routine you have noted in an "inspection_start_pcm.txt" file and place it in the main inspection directory (or specific plans) to run each time an inspection is started. This is usually the best place for error-proofing routines as it allows global edits and only requires you place the file in the proper place without ensuring the PCM is added each program internally. Also allows for easier disabling by programmers when troubleshooting is necessary as the file is external from CALYPSO Link to comment Share on other sites More sharing options...
[Mi...] Posted May 8, 2023 Author Share Posted May 8, 2023 Please sign in to view this quote. There is no copying as pasting of the machine number list. -Machine lists are unique to each program. A given part number may have up to a dozen production programs - one for each machining operation. (Because QC-CALC sucks and Certain parts of the AutoRun Interface Suck otherwise I would make 1 big parametric program for all operations) -Pallets/Spindles are unique to each machine. I use inspection_start_pcm.txt to run a .txt file that contains all of this selection and control code, with a simple if Statement to make it only work for the "User" user for troubleshooting. When I use readListFile() I get the same behavior as if I used List(), am I missing something? Both of these examples don't give a list of selections. numbers = readListFile(getActualInspectionDir()+"\test.txt").asString inquireList("choose",numbers) inquireList("choose",readListFile(getActualInspectionDir()+"\test.txt").asString)List.PNG Link to comment Share on other sites More sharing options...
[Wa...] Posted May 9, 2023 Share Posted May 9, 2023 The inquireList function wants values separated by commas. Unfortunately you can't send it a string and have it parsed based on some character. You need to add the individual lines from the file one at a time. The following function builds a list based on the length of the file. clearParameter() filePath = getActualInspectionDir() + "\listFile4.txt" listResult = "" A = readListFile(filePath) B = len(A) defineFunctionStart("ListBuilder") selectCase B case 4 returnValue = inquireList("choose",getParameterNamed(A,1),getParameterNamed(A,2),getParameterNamed(A,3),getParameterNamed(A,4)) case 5 returnValue = inquireList("choose",getParameterNamed(A,1),getParameterNamed(A,2),getParameterNamed(A,3),getParameterNamed(A,4),getParameterNamed(A,5)) case 12 returnValue = inquireList("choose",getParameterNamed(A,1),getParameterNamed(A,2),getParameterNamed(A,3),getParameterNamed(A,4),getParameterNamed(A,5),getParameterNamed(A,6),getParameterNamed(A,7),getParameterNamed(A,8),getParameterNamed(A,9),getParameterNamed(A,10),getParameterNamed(A,11),getParameterNamed(A,12)) endSelect defineFunctionEnd("returnValue") listResult = executeFunctionNamed("ListBuilder") Link to comment Share on other sites More sharing options...
[Ma...] Posted May 10, 2023 Share Posted May 10, 2023 You can try this code. Based on the file's content it creates an "inquireList" dynamically. This is what file looks like inside: 1 2 3 4 filePath = "X:\path\to\your\file.txt" numbers = readListFile(filePath) ListPara = "inquireList(" + qm() + "choose" + qm() for i = 1 to numbers.size ListPara = ListPara +","+ qm() + getParameterNamed(numbers,i) +qm() next i ListPara = ListPara + ")" getParameterNamed(ListPara) Link to comment Share on other sites More sharing options...
[Mi...] Posted May 10, 2023 Author Share Posted May 10, 2023 Please sign in to view this quote. Thank you! This is the route I was trying to go, and got pretty close, the qm() is what makes yours work where I kept failing. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in