From Shopbot Wiki

Here are some suggestions for writing ShopBot files that could make your files easier to read and follow. You don’t have to follow all of them (and your files will probably work just fine if you don’t), but if you follow these guidelines it'll be easier for you (and someone else reading your files) to figure out what your file does.

  • Rule #1…Comment, comment, comment. Something that's obvious to you may or may not be obvious to someone else reading your file...a comment is you're chance to explain yourself
  • Organize your files into logical sections by using whitespace…leaving empty lines in your file. Also indent sections that are part of a "block" of commands, like the lines of a subroutine that are between the label and the RETURN statement. It's a lot easier to see what's happening in a file if it's broken up like that.
  • Use subroutines (GOSUB) whenever you can. They help to organize your file and make it easier to follow the flow, and also to hold things that are used multiple times.
    • Place all the subroutines at bottom of file...they're easier to find there
    • Put an END statement before the first subroutine sections to keep from “falling through”
  • Use Variables!
    • Pick descriptive names for your variables. It's a lot easier to figure out what a variable named "&cutdepth" does than a variable named "&x".
    • Don’t use “magic numbers” in your files that can't be easily modified. Use a variable instead even if you don’t think you'll ever need to “vary” it. For instance, you could use "MZ, -0.5" in your file for your cutting depth, but if you use a variable instead like "MZ, &cutdepth" then if you later wanted to cut the file in 3/4" material you would just have to change the &cutdepth variable.
    • Give any variables a starting value in the beginning of your files...if not then by default they will have a value of 0 or maybe give an error message
    • Initialize variables at the beginning of a program and add a comment to persistent variables to show where they were initialized
   &first_variable = 1.0   
   &second_variable = 2.0
  ' &third_variable         persistent variable, initialized in file xxx.sbp
  ' &fourth_variable       persistent variable, initialized in file yyy.sbp
  • Use an underscore to split words in variable names to make your file more readable...use "&A_Axis_cut_depth" instead of "&AAxiscutdepth"
  • Use a comma as a separator between the Command and the first parameter, even though a blank will work there. In other words, even though you can do "M2 3, 3" doesn't mean you should... "M2, 3, 3" is better!
  • Leave a space after commas in parameters (if there’s a parameter there). "M3, 0.4, 0.5, 0.6" is easier to read than "M3,0.4,0.5,0.6"
  • Put the leading "0" in front of a decimal value, even though it's not necessary. It's a lot easier to tell the the values are decimals in "M3, 0.4, 0.5, 0.6" than in "M3, .4, .5, .6"
  • Don’t add extra commas as placeholders in Commands, beyond the last parameter that you're using.
  • Capitalize ShopBot Programming Statements and Commands
  • Use parenthesis to enclose calculations in a file line, even if they’re not necessary for the calculation

Personal tools