PDA

View Full Version : Repeat Program



mnrite
03-17-2007, 07:43 PM
If I had a program for a part that looked like this

MS,1.7,0.5
JZ,1.000
J2,0.000,0.000
J3,12.000,12.000,0.250
M3,12.000,12.000,-1.000
M3,24.000,12.000,-1.000
M3,24.000,24.000,-1.000
M3,12.000,24.000,-1.000
M3,12.000,12.000,-1.000
J3,12.000,12.000,0.250
J3,0.000,0.000,1.000
JZ,1.000
J2,0.000,0.000

and I wanted to cut a random amount and then quit, would the program look like this?

MS,1.7,0.5
JZ,1.000
J2,0.000,0.000
start;
J3,12.000,12.000,0.250
M3,12.000,12.000,-1.000
M3,24.000,12.000,-1.000
M3,24.000,24.000,-1.000
M3,12.000,24.000,-1.000
M3,12.000,12.000,-1.000
J3,12.000,12.000,0.250
INPUT{"Do you want to cut another part Y/N"}&x
IF &x=y THEN GOTO start
If &x=n THEN GOTO end
end;
J3,0.000,0.000,1.000
JZ,1.000
J2,0.000,0.000

Thanks
Mike

paco
03-17-2007, 11:02 PM
Hi Mike!

That would be more like:

MS,1.7,0.5
JZ,1.000
J2,0.000,0.000
start: '--- not ; but :
J3,12.000,12.000,0.250
M3,12.000,12.000,-1.000
M3,24.000,12.000,-1.000
M3,24.000,24.000,-1.000
M3,12.000,24.000,-1.000
M3,12.000,12.000,-1.000
J3,12.000,12.000,0.250
INPUT "Do you want to cut another part Y/N" &x '--- no need for {} and you might want to give your variable a more explicit name...
IF &x=y THEN GOTO start
If &x=n THEN GOTO end
end: '--- : instead of ;
J3,0.000,0.000,1.000
JZ,1.000
J2,0.000,0.000
' ---will you be repeating the cut on the same position over again?!
' ---you may want to implement some more code to check for something else that Y or N...

Everything that's after a ' is a comments (not read, just displayed) by SB3.

Does that help?

mnrite
03-18-2007, 11:49 AM
Thanks Paco,

Yes that helps,I knew from BASIC programing that I would have the general idea right, but would mess up the exact formating and puncuation.

Thanks Again
Mike

beacon14
03-18-2007, 10:16 PM
You can delete these two lines:

If &x=n THEN GOTO end
end:

since even if &x is not equal to n it will go to the next line anyway.

However if you want to add error-checking you could use:

input:
INPUT "Do you want to cut another part Y/N" &repeat
IF &repeat=y THEN GOTO start
If &repeat=n THEN GOTO end
GOTO input
end:


Also, you might want to add a J2 just before the INPUT to move the gantry out of the way to make it easier to change the workpiece