Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Your code should meet the following coding standard. It is a recommendation, not a requirement. Clarity, simplicity and organization are the goals.
Overall program structure is as follows:
The program should have a header block containing:
;**************************************************************** ;* PROGRAM NAME ;* ;* Purpose : ;* Author : ;* Inputs : ;* Outputs : ;* Special Instructions : ;* Known issues : ;* Revision History : ;****************************************************************
Every 'User Defined Function' or 'Subroutine' should have a header block containing:
parm1 : description parm2 : description
returns : description
;---------------------------------------------------------------- ; udfFunction ( parm1, parm2 ) ;---------------------------------------------------------------- ; description ;---------------------------------------------------------------- ; parm1 : description. ; parm2 : description. ;---------------------------------------------------------------- ; returns: @true if success, @false if failure ;---------------------------------------------------------------- ; notes : ;----------------------------------------------------------------
Blocks of code need short descriptions to identify their purpose. For example:
; fill the array with values 1,2,3,...,n for i = 0 to n list[i] = i + 1 next
Inline comments should be used to clarify anything that is not immediately obvious in the code.
roll = Random(12) Mod 11 + 2 ; compute random roll of dice
Should be used liberally
Compute_sum( list, n )
x = 3 + y ; NOT: x=3+y
if ( x < 10 && y > 13 ) ; NOT: if(x<10&&y>13)
for i = 1 to 10 if i Mod 2 == 0 Pause( 'Number is even', i ) else Pause( 'Number is odd', i ) endif next
switch ( day ) case 1 ;handle Monday Pause( 'Notice', 'Today is Monday' ) break case 2 ; handle Tuesday Pause( 'Notice', 'Today is Tuesday' ) break endswitch
WinBatch Studio can be used to help indent your code. You can highlight blocks of code then use the Tab key to indent or the Shift-Tab key to remove indents.
Be sure to tailor WinBatch Studio's Tab settings to fit your needs. You can modify the tab size using the View|Options menu and selecting the 'File types' tab.
There is a code Beautifier Script available for reformatting existing code in the tech database. After formatting your source file. Make sure to double check your code for compliancy to the coding standards.
MAX = 1000 @TRUE @TAB
:CANCEL
_GLOBAL_TABLE_SIZE_ = 1023
Article ID: W17640
Filename: Coding Standard.txt
File Created: 2014:06:18:13:39:34
Last Updated: 2014:06:18:13:39:34