re-Formatting a given Rexx source code
The reFormat.rex program is a fast conversion from the
REXREF3.rex code for Personal REXX for DOS by Stephen Ferg to
Object Rexx for Windows. It has been tested only on a few Classic
Rexx files.
Use with care. Operate on a clean tested code controlled
first by your Rexx interpreter. Control and retest the
re-formatted file. It works on small standard Rexx files as
it is, it may not work on other files.
The in-line comments (prefixed by '--' as in Object-Rexx and
NetRexx) are not supported. You can use the reCMT.rex to convert
to standard Rexx comments (/* */) if any -- are not embedded
in any literal string.
Function
reFormat is a REXX program that takes a REXX source-code file
and:
- produces a cross-reference listing showing the program's
variables, labels, and functions, and the lines where they occur
in the program
- reformats it
In reformatting the code, it:
- puts keywords and function names into upper or lower case, or
proper noun style (the name that is spelt with a capital letter,
then lowercase), or preserves the original case from the
reFMT_kwd.txt and reFMT_fct.txt files (this is controlled by
reFMT_cfg.txt)
- puts variable names into upper or lower case, or proper noun
style, or preserves the original case from the input file (this
is controlled by reFMT_cfg.txt)
- the names in mixed-case (eg SysFileTree) in the source code
will not be modified if the mixed mode is specified (ML MU MP).
The names all uppercase or all lowercase will be formatted
according to the 2nd indicator, lowercase (L), uppercase (U),
proper noun (P).
- adjusts the indenting of the code
- where a line ends with a comment, right-justifies the
comment
About the program
- tested with Object Rexx 2.1.2 for Windows XP (a few
statements only are ORexx specific, see the /*orx*/
indicator)
- LSRTNT (or another Win32 file-sorting utility) required. This
one is by London Computing and is included in the ZIP file. It is
shareware. See their lsrtnt.txt file for details.
- The program comes as a REXX module: reFormat.REX
- and 2 data files reFMT_kwd.txt [contains a list of keywords ]
reFMT_fct.txt [contains a list of REXX function names]
- and 1 (optional) configuration file reFMT_cfg.txt
- any TAB CR LF characters left in the input file will be
changed to the blank character before formatting.
All of the above files should be put in the same directory.
You can either put that directory in your path, or make that
directory your current directory when running reFormat. The
source code file to be processed does not have to be in this
directory, but when you pass its name to reFormat, its name must
be qualified enough for reFormat to find it. The user has to set
the two variables ResourceDir and WorkDir within the reFormat.rex
code.
And of course the executables for the sort program must be
placed in a directory that DOS can find when the sort is invoked.
Copy LSRTNT.EXE to the \Windows\System32 directory for
example.
There is also a test input file called TESTXREF.REX
Running reFormat
- first, save the code to re-format after cleaning it (better
if it is bug free, use your Rexx interpreter). Change in-line
comments (prefix --) to standard comments (/* */) to avoid
unwanted formatting.
- once, set the two variables ResourceDir and WorkDir within
the reFormat.rex code with any text editor (Notepad).
- modify the configuration file reFMT_cfg.txt with any text
editor (Notepad).
- Then run reFormat and enter the full path and name of the
input file. Example : C:\CMD\testxref.rex
- 2 output files will be created
- testxref_r.rex -- contains reformatted progam text
- testxref_xref.txt -- contains the cross-reference
listing
- existing old output files will be erased without any
warning.
About the configuration file
The configuration file, reFMT_cfg.txt contains REXX assignment
statements that initialize certain key variables in the reFormat
program. If the configuration file does not exist, or does not
set values for those variables, defaults are used. Values are not
case-sensitive. This file can be edited with any ordinary text
editor.
The variables that specify the case formatting take values
of
- 'U' for 'Upper'
- 'L' for 'Lower'
- 'P' for 'Proper noun: the name that is spelt with a capital
letter, then lowercase'
- 'R' for 'Reference: to get from the reFMT_kwd reFMT_fct files
for functions and keywords'
- 'R' for 'Reference: to get from the source code for variables
and labels'
- 'ML' for source code mixed-case preservation and lowercase
for monocase source names
- 'MU' for source code mixed-case preservation and uppercase
for monocase source names
- 'MP' for source code mixed-case preservation and proper noun
for monocase source names
For the 'R' indicator: you can use an ordinary text editor to
customize the case of the keywords and function names in
reFMT_kwd.txt and reFMT_fct.txt to suit your own taste.
News group
Thanks to those that have contributed to make this conversion
(newsgroup: comp.lang.rexx). Report there for comments, questions
etc.