Results 1 to 5 of 5

Thread: Modify custom variable in my_variables.sbc

  1. #1
    Join Date
    Dec 2015
    Location
    New Jersey
    Posts
    60

    Question Modify custom variable in my_variables.sbc

    Can I add my own custom variable to my_variables.sbc, then change that variable from an sbp file?

  2. #2
    Join Date
    Dec 2000
    Location
    Thorp, WI
    Posts
    2,845

    Default

    Yes and yes. For writing to the file, look at OPEN "path&filename" FOR {INPUT/OUTPUT/APPEND} in the programming manual.
    Scott




  3. #3
    Join Date
    Dec 2015
    Location
    New Jersey
    Posts
    60

    Default

    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.

  4. #4
    Join Date
    Dec 2000
    Location
    Thorp, WI
    Posts
    2,845

    Default

    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




  5. #5
    Join Date
    Dec 2015
    Location
    New Jersey
    Posts
    60

    Default

    Thank you. I'll give this a try.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •