目录

Rexx - 最佳编程实践( Best Programming Practices)

每个程序员都希望他们的程序在质量和效率方面是最好的。 以下是编写Rexx程序时可以帮助实现这些目标的一些最佳编程实践或提示。

Hint 1

在向操作系统或命令提示符发出任何命令之前,请使用address命令。 这将帮助您事先在内存中获取地址空间,从而使您的程序更有效地运行。

地址命令的示例如下所示。

例子 (Example)

/* Main program */ 
address system dir 

该命令的输出如下,但它可能因系统而异。

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

确保操作系统的所有命令均为大写,并尽可能使用引号。

其示例如下所示。

例子 (Example)

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

当我们运行上述程序时,我们将得到以下结果。

0 
D:\rexxxml100 

Hint 3

避免创建大注释块,如以下程序所示。

例子 (Example)

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

Hint 4

使用Parse语句指定默认值。 其示例如下所示。

例子 (Example)

parse value 0 1 with 
a, 
b 

Hint 5

尽可能使用“Left(var1,2)”语句而不是“substr(var1,1,2)”语句。

Hint 6

尽可能使用“Right(var1,2)”语句而不是“substr(var1,length(var1),2)”语句。

↑回到顶部↑
WIKI教程 @2018