Avoiding Pitfalls in Multi-Language Programming

The Basic BRK function can be used to reset
Basic traps if trap handling has been changed by a
foreign routine or by explicit calls to the trap intrinsics.
HALT is simulated in Basic by checking for control-y being pressed twice within a short time period. In
compiled code, the check for the HALT condition is done at the
end of each statement and within
certain Basic library routines. Therefore, if the HALT occurs when executing a
foreign routine,
detection of the condition may be delayed until execution resumes in Basic.
Runtime Factors
Pitfalls:
HFS file names may exceed the previous maximum name length for MPE files.
Certain file names are used by some languages for special purposes.
Special care must be taken when using VPLUS forms with some languages.
Some file types and special I/O handling may not be supported by all languages.
File I/O cannot readily be shared between C
and other languages because I/O in C is buffered
internally.
Basic may output a terminal status check during initialization.
The Basic Report Writer has no knowledge of output generated by intrinsics or by foreign routines.
Recommendations:
Use MPE file names for maximum compatibility. Most file access routines can handle names up to 86
characters, but sometimes a maximum of 35 characters is used.
Avoid using file names that conflict with those reserved by any of the languages.
Use VPLUS intrinsic calls rather than language form-handling statements if the form must be active
across inter-language procedure calls.
Make sure that the terminal is in character mode before calling a Transact routine.
For access to non-standard files, such as
KSAM, message IPC, CIO, RIO, etc. use system intrinsics
as special open options, control calls, and buffer management are not available in all languages.
Make sure that the I/O buffer is flushed before calling a foreign routine or intrinsic that accesses
shared files.
If possible, avoid dependencies on BASIC-compatible terminals in Basic routines that will be
called
from foreign outer blocks, and set the terminal type in the configuration file to non-Basic.
While a Basic report is active, use only Basic I/O statements to write to the output file.
Details:
I/O in standard C is handled by explicit calls to library functions, which are implemented on top of
the
MPE/iX file system. Typically, C file I/O is buffered,
with the C library maintaining its own buffers,
distinct from those used by MPE. When possible, the C library uses mapped
file access for reading
and writing to disk files. The file buffers and other data structures maintained by C are not
common
with any other language.
Page
9
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
...