Every programmer wants their program to be the best when it comes to quality and efficiency. The following are some of the best programming practices or hints when writing Rexx programs which can help one achieve these goals.
Use the address command before you issue any command to the operating system or command prompt. This will help you get the address space beforehand in memory and cause your program to run more efficiently.
An example of the address command is shown below.
/* Main program */ address system dir
The output of the command is as follows, but it could vary from system to system.
Volume in drive H is Apps Volume Serial Number is 8E66-AC3D Directory of H:\ 06/30/2016 01:28 AM <DIR> Apps 07/05/2016 03:40 AM 463 main.class 07/07/2016 01:30 AM 46 main.nrx 07/07/2016 01:42 AM 38 main.rexx 3 File(s) 547 bytes Dir(s) 313,085,173,760 bytes free
Ensure all commands to the operating system are in upper case and in quotes wherever possible.
An example for the same is shown below.
/* Main program */ options arexx_bifs say chdir('\REXXML100') say directory()
When we run the above program, we will get the following result.
Avoid creating big comment blocks as shown in the following program.
/******/ /* */ /* */ /* */ /******/ /* Main program */ address system dir
Use the Parse statement to assign default values. An example for the same is shown below.
parse value 0 1 with a, b
Use the "Left(var1,2)" statement wherever possible instead of the “substr(var1,1,2)" statement.
Use the "Right(var1,2)" statement wherever possible instead of the “substr(var1,length(var1),2)" statement.