Avoiding Pitfalls in Multi-Language Programming

If a Pascal routine is called from a foreign outer block, the input and/or output standard files must be
opened in the Pascal routine with the reset and rewrite functions.
If a Pascal file number is passed to a foreign routine, the eof function can be used, upon return, to re-
establish the file position, reflecting any changes made to the file while not under control of Pascal.
The following file names should not be used
in a Transact program or in a file equation while
Transact is running. They could be overwritten without notice:
IPxxxxxx - Transact p-code file
ITxxxxxx - TRANDEBUG file (version A.04.00 and earlier)
IUxxxxxx - TRANDEBUG file (version A.04.02 and later)
OUTPUT - Internal file used by Transact
where xxxxxx is the system name of the Transact program.
When calling a Transact routine, all databases and files specified in the system statement will be
opened, whether or not they are accessed by the calling
program. No database or file information is
preserved during a call to a Transact routine. The calling program has sole
responsibility for
managing these issues. Transact routines assume the terminal is in character mode on entry, and will
unconditionally return the terminal to character mode on exit.
Transact maintains its own copy of the
VPLUS comarea, which is not accessible outside the Transact runtime system.
In Basic, each compiled routine checks to see if the library has been initialized. If it hasn't, the
initialization routine is called. This initialization routine
queries the HPBBCNFG.PUB.SYS file, if it
exists, to determine defaults for such things as the PRINTER specification and
whether the terminal
is BASIC-compatible. Be aware that if the configuration file specifies a BASIC-
compatible terminal,
the Basic
initialization routine will output a terminal status check to query the type of the terminal. This status
check can interfere with such things as typeahead and PAD
terminals. VPLUS intrinsics and Basic
statements should not be mixed to access the same form. Basic maintains its own copy of
the
VPLUS comarea, which is not accessible outside the Basic runtime system.
The FNUM function can be used to get the MPE
file number of a Basic file designator. Be aware that
Basic may buffer output until a record is filled.
The POSITION statement will flush the buffer to the file in addition to positioning to a specific record.
Basic maintains its own record counter for sequential I/O, so
if the file position changes via intrinsic
calls or I/O in other languages, a POSITION or direct I/O statement should be used to re-
establish the
file position. Basic data files (file code 1248) contain extra information about the type of each
data
item.
Debugging Tips
Pitfalls:
Optimization can cause programs to fail.
Either because the program violates one of the assumptions
of the compiler, or because the compiler failed to allow for some corner-
case condition. Turn off
optimization at the start of debugging to avoid chasing these very subtle and hard to
isolate problems.
Recommendations
:
Utilize the compiler options for symbol lists, range or overflow checking, and initialization.
Page
10
of
14
Avoiding Pitfalls in Multi
-
7/18/2008
http://www.hp.com/cgi
-
bin/pf
-
new.cgi?IN=http://jazz.external.hp.com/papers/lang/pgm_pi
...