Can I add my own custom variable to my_variables.sbc, then change that variable from an sbp file?
Can I add my own custom variable to my_variables.sbc, then change that variable from an sbp file?
Yes and yes. For writing to the file, look at OPEN "path&filename" FOR {INPUT/OUTPUT/APPEND} in the programming manual.
Scott
I don't see how the OPEN command will do what I want. my_variables.sbc is the shopbot created file that has a ton of variables. I know how to open that file and read all the variables in memory. I could use a text editor to manually add a new custom variable, and opening that file would read that variable along with all the others. But what I'd like to do is use shopbot program to change the value of just that one variable.
Open the file for output and the use the "Write" command to write to it by using variables in your file. Variables can be hard coded or set with the input command.
Sample code to open a file and write to it and then close it....
'Save Work Offsets 1 - 6
SL 'Clear variables
'INPUT "Do you want to SAVE a work offset at the current location?" &choice
'IF &choice = S THEN GOTO SAVE
'IF &choice = G THEN GOTO OFFSET
'IF &choice = T THEN GOTO TBC
'SAVE:
INPUT "Which work offset would you like to save the current location to? (1-6)" &offset
If &offset < 1 THEN END
If &offset > 6 THEN END
Z2
IF &offset = 1 THEN OPEN "C:\SbParts\WorkOffsets\Offset1.sbp" FOR OUTPUT AS #1
IF &offset = 2 THEN OPEN "C:\SbParts\WorkOffsets\Offset2.sbp" FOR OUTPUT AS #1
IF &offset = 3 THEN OPEN "C:\SbParts\WorkOffsets\Offset3.sbp" FOR OUTPUT AS #1
IF &offset = 4 THEN OPEN "C:\SbParts\WorkOffsets\Offset4.sbp" FOR OUTPUT AS #1
IF &offset = 5 THEN OPEN "C:\SbParts\WorkOffsets\Offset5.sbp" FOR OUTPUT AS #1
IF &offset = 6 THEN OPEN "C:\SbParts\WorkOffsets\Offset6.sbp" FOR OUTPUT AS #1
&Xoff = %(6) 'Base coordinate X
&Yoff = %(7) 'Base coordinate Y
WRITE #1; "'Offset "; &offset
WRITE #1; ""
WRITE #1; "&Xoff = "; &Xoff
WRITE #1; "&Yoff = "; &Yoff
WRITE #1; ""
WRITE #1; "ST"
WRITE #1; "J2, &Xoff, &Yoff"
WRITE #1; "Z2"
Close
END
Scott
Thank you. I'll give this a try.