I actually defined coding guidelines that the staff need to follow, some of which are:
You'll find that every UDF that I post will follow these standards.
- 2-space indents for all paired statements (if/endif, loops, etc.) Select/Case is the exception - the "case" is indented one space, and it's commands indented the second space.
- Local var names are $MixedCase, Globals are $CAPS, as are @MACROS. Local vars in functions have a "_" prefix, as in "$_FnVar".
- one blank line between code blocks, 3 blank lines plus a comment divider (; ====) between key logic sections. I use "#" dividers at major divisions, "=" at minor divisions and at the start of each function, and "-" for minor sections.
- Command and Function names are MixedCase
- Spaces between ALL operators
- Use of CRLF at the END of output only. Never start a line with "?". It's a shortcut for CRLF, which traditionally comes at the end of a line. It's often confused with MS BASIC's use of "?" as a shortcut for the PRINT statement, which comes at the start of the line.
I use KGEN to generate all scripts, which builds the script from a central UDF library, runs Sanity, tokenizes the script, and even copies the finished script to an alternate (production) location.
All of these standards result in code that's easy for the team to support. We currently have over 100 Kix scripts collectively exceeding 150-thousand lines of code in production on more than 35,000 computers world-wide. Several scripts are in the 12-15 thousand line range.
a Rocket Scientist!