Jump to content

How to cancel?


---
 Share

Recommended Posts

Been using this style of code, largely thanks to Eric Moberg on this forum for simplifying what I had, I have run into an issue though and I'm hoping it's fairly simple.

I need to be able to cancel it, because even though we have Autorun with nice big buttons, operators still select the wrong program. They realize this when I force them to select a machine number. On my offline seat, 2015 if you hit escape while it's executing it cancels the run, and stops the code from executing. No problem.

On 2017 and 2018 it doesn't work like that, you end up stuck in an endless loop. So you have to made random selections, start the program then immediately cancel it. Trying to avoid this for obvious reasons.

The least elegant way I've come up with is adding a "cancel" selection to the inquire lists, with if statements or Case select but there has to be something better than that. And I know ill immediately be asked why they can't just hit cancel in the dialogue box.

I do need to Force them to input all 3 if there is 3. My next idea is to make it check at the end and then have a message saying "Too bad, try again" if any are blank, with cncBreak()

Any ideas? Example of the code in question
repeat
	repeat
		m=inquireList("Choose Machine Number", "1","2")
	until m <> ""
	repeat
		p=inquireList("Choose Pallet Identifier", "A","B","C","D")
	until p <> ""
	repeat
		r=inquireList("Select Run Parameters", "Firstoff", "Lastoff", "OIS", "Recheck")
	until r <> ""
	if r <> "Recheck"
		setCF(readListFile("Complete.txt"))
	endif
until executeCode("ICCDialog confirm: '<L>You selected:</L>"+cr()+cr()+cr()+cr()+"<b>Machine Number:</b>		<u><b><c:red><L>"+m+"</L></b></u></c>"+cr()+cr()+"<b>Pallet Identifier:</b>		<u><b><c:red><L>"+p+"</L></b></u></c>"+cr()+cr()+"<b>Run Identifier:</b>			<u><b><c:red><L>"+r+"</L></b></u></c>"+cr()+cr()+cr()+cr()+"Is this correct?' asRichText")
setRecordHead("procid",m)
setRecordHead("partnbinc",p," ", r)
I tried this too, it does work, but it's ugly because the cncBreak() turns the stoplight red, but doesn't stop the rest of the code from executing.

repeat
		m=inquireList("Choose CNC Machine","1530","1812")
	if m== "" then
		cncBreak()
	endif
		r=inquireList("Select Run Parameters", "Firstoff", "Lastoff", "OIS", "Recheck")
	if r== "" then
		cncBreak()
	endif
	if r <> "Recheck"
		setCF(readListFile("Complete.txt"))
	endif
until executeCode("ICCDialog confirm: '<L>You selected:</L>"+cr()+cr()+cr()+cr()+"<b>Machine Number:</b>		<u><b><c:red><L>"+m+"</L></b></u></c>"+cr()+cr()+"<b>Run Identifier:</b>			<u><b><c:red><L>"+r+"</L></b></u></c>"+cr()+cr()+cr()+cr()+"Is this correct?' asRichText")
setRecordHead("procid",m)
setRecordHead("partnbinc",r)

Thanks to anybody who takes the time!
Link to comment
Share on other sites

Hello Michael,

we use the same kind of inquierList to chose a program run (mini plan) at program start.
It´s breaking the loop after 3 times without a choice or cancel.
Maybe you could use it too:
i=0
repeat
     i=i+1
     MG = inquireList(„Run1“,“Run2“,“Run3“)
     MG_Z = len(MG)
     if MG_Z == 0 
          if i <3 then
               message ("Please make a choice")
          endif
     endif 
     if i == 3 then
          message ("Program is aborted because too often no program run was selected or Cancel was selected. "+cr()+cr()+"(At program start, a program run must be selected).")
     cncBreak()
          MG_Z=1
     endif
until MG_Z>0
Link to comment
Share on other sites

You gave me an idea that's for sure, making it count to break the loop. Where I'm getting stuck is my confirmation question at the end. I've tried many variations of if statements and such to make it only go through the whole set of questions 1-2 times.

that

"until executeCode" line is what's screwing me. If I took it out I can make it work, but I do want to keep it in as a final check, right now if they say no, it starts from the beginning, which is good, but I only want that to happen twice, currently you can say no forever and itll keep starting over. Man I need coding experience, I'm sure this is far simpler than I'm making it. Trying things like this, just can't quite get it. This doesn't work.
m=""
r=""
p=""
z=0
repeat
	z=z+1
	repeat
		m=inquireList("Choose Machine Number", "1804","1805")
	until m <> ""
	repeat
		p=inquireList("Choose Pallet Identifier", "A1 ","A2 ","A3 ","A4 ","B1 ","B2 ","B3 ","B4 ")
	until p <> ""
	repeat
		r=inquireList("Select Run Parameters", "Firstoff", "Lastoff", "OIS", "Recheck")
	until r <> ""
	if r <> "Recheck"
		setCF(readListFile("Complete.txt"))
	endif
until 
if z<2
executeCode("ICCDialog confirm: '<L>You selected:</L>"+cr()+cr()+cr()+cr()+"<b>Machine Number:</b>		<u><b><c:red><L>"+m+"</L></b></u></c>"+cr()+cr()+"<b>Pallet Identifier:</b>		<u><b><c:red><L>"+p+"</L></b></u></c>"+cr()+cr()+"<b>Run Identifier:</b>			<u><b><c:red><L>"+r+"</L></b></u></c>"+cr()+cr()+cr()+cr()+"Is this correct?' asRichText")
setRecordHead("procid",m)
setRecordHead("partnbinc",p," ", r)
else
cncBreak()
endif
Link to comment
Share on other sites

 Share

×
×
  • Create New...