Rexx - Best Programming Practices


Advertisements


Every programmer wants their program to be the best when it comes to quality and efficiency. The following are some of the best programing practices or hints when writing Rexx programs which can help one achieve these goals.

Hint 1

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.

Example

/* 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

Hint 2

Ensure all commands to the operating system are in upper case and in quotes wherever possible.

An example for the same is shown below.

Example

/* Main program */ 
options arexx_bifs 
say chdir('\REXXML100') 
say directory()

When we run the above program, we will get the following result.

0 
D:\rexxxml100 

Hint 3

Avoid creating big comment blocks as shown in the following program.

Example

/******/ 
/* */ 
/* */ 
/* */ 
/******/ 
/* Main program */ 
address system dir

Hint 4

Use the Parse statement to assign default values. An example for the same is shown below.

Example

parse value 0 1 with 
a, 
b 

Hint 5

Use the "Left(var1,2)" statement wherever possible instead of the “substr(var1,1,2)" statement.

Hint 6

Use the "Right(var1,2)" statement wherever possible instead of the “substr(var1,length(var1),2)" statement.



Advertisements
E-Books Store