SPL to HP C/XL Migration Guide (30231-90001)

11-2
Step Two: Rewrite SPL to Look Like HP C/XL
The case sensitivity of HP C/XL is one of the first differences between
these two languages that an SPL programmer is liable to notice. Because
SPL ignores case, some SPL programs have examples of the same reserved
word or variable name appearing in both upper- and lowercase at various
points in the source. In HP C/XL, these names will be interpreted as
different
entities. HP C/XL keywords
must
be expressed in lowercase.
Many HP C/XL programmers tend to specify #define macro identifiers in
uppercase to distinguish them from function names, but there are no
universally accepted standards.
As a first step, convert the SPL source to all uppercase (except for
strings, of course). When you convert to HP C/XL in the next step,
reserved and keywords will shift to lowercase, and the identifiers of
variables, etc., will remain in uppercase, thereby avoiding any possible
conflict with HP C/XL reserved words and library function names.
There are a number of other changes which may be made to SPL programs,
causing them to conform more closely to HP C/XL forms, and rendering them
easier to translate.
For example, HP C/XL does not allow nested functions, so SPL subroutines
will be awkward to translate. Careful examination now of any subrou-
tines used in your SPL program will give you a head start on determining
how best to eliminate the subroutines.
Possibilities are: moving the subroutine code inline (meaning that the
code will be repeated wherever the subroutine is called, possibly by
means of a DEFINE), or converting the subroutine to an SPL procedure. In
the latter case, variables in the procedure that are accessed by the
subroutine will have to be supplied as parameters, or declared global to
both the new procedure and its caller. In many cases, these variables
were declared in the procedure simply for use by the subroutine, which
means they may be declared within the new procedure.
Also, be alert for the possibility that identical subroutines were
declared local to more than one procedure; they could all be replaced by
one global procedure.
Another change that may be easier to debug prior to converting to HP C/XL
is the elimination of any pass-by-reference procedure parameters. By
changing such parameters to pass-by-value pointers, and then changing
the actual parameters to addresses (generated with the "@" operator),
the process of passing and accessing parameters in the same manner as
HP C/XL may be tested in an SPL environment. Remember that unsubscripted
array, pointer, and procedure identifiers passed by reference do not
require any modification.
Because the natural data size of HP C/XL is 32 bits, you should convert
as many SPL INTEGER variables to SPL DOUBLE as possible. This will
result in a more efficient final HP C/XL program.