PDA

View Full Version : Modify custom variable in my_variables.sbc



Scott216
07-13-2023, 07:40 AM
Can I add my own custom variable to my_variables.sbc, then change that variable from an sbp file?

srwtlc
07-13-2023, 10:29 AM
Yes and yes. For writing to the file, look at OPEN "path&filename" FOR {INPUT/OUTPUT/APPEND} in the programming manual.

Scott216
07-13-2023, 11:08 AM
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.

srwtlc
07-13-2023, 03:27 PM
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

Scott216
07-15-2023, 09:22 AM
Thank you. I'll give this a try.

nolanmaris
07-16-2024, 02:34 AM
Hello


To add a custom variable to my_variables.sbc and modify it from an sbp file, follow these steps:
Add Custom Variable: In my_variables.sbc, declare your custom variable. For example:

&my_custom_variable = 0
Modify in SBP File: In your sbp file, you can modify this variable using:

&my_custom_variable = 100
For detailed instructions, you may want to provide specific code snippets and ensure proper syntax according to your setup.

Hope it helps ! :)