[ver] 4 [sty] _DEFAULT.STY [files] [charset] 82 ANSI (Windows, IBM CP 1252) [revisions] 0 [prn] HP LaserJet 4/4M [port] LPT1: [lang] 1 [fldnames] Field1 Field2 Field3 Field4 Field5 Field6 Field7 Field8 [desc] 895097145 12 799697658 870 23 0 0 0 0 1 [fopts] 0 1 0 0 [lnopts] 2 Body Text 1 [docopts] 5 2 [GramStyle] [lay] Standard 513 [rght] 15840 12240 1 2520 1440 1 1440 1440 0 1 0 1 0 2 1 2520 10800 12 1 720 1 1440 1 2160 1 2880 1 3600 1 4320 1 5040 1 5760 1 6480 1 7200 1 7920 1 8640 [hrght] [lyfrm] 1 11200 0 0 12240 1440 0 1 3 1 0 0 0 0 0 0 0 0 1 [frmlay] 1440 12240 1 1440 72 1 792 1440 0 1 0 1 1 0 1 1440 10800 2 2 4680 3 9360 [txt] > [frght] [lyfrm] 1 13248 0 14400 12240 15840 0 1 3 1 0 0 0 0 0 0 0 0 2 [frmlay] 15840 12240 1 1440 792 1 14472 1440 0 1 0 1 1 0 1 1440 10800 2 2 4680 3 9360 [txt] <+B>Avoiding Pitfalls in Multi-Language Programming <+B><:f240,BArial MT,><:P11,0,4015-><:f> <+B> > [elay] [l1] 0 [pg] 23 39 0 32 0 0 0 0 65535 2 Standard 65535 0 0 0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0 70 0 43 512 0 0 0 65535 23 Standard 65535 0 0 0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0 94 0 22 512 0 0 0 65535 2 Standard 65535 0 0 0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0 136 0 49 0 0 0 0 65535 65535 Standard 65535 0 0 0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0 171 218 77 0 0 0 0 65535 144 Standard 65535 0 0 0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0 177 1320 62 0 0 0 0 65535 2 Standard 65535 0 0 0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0 188 0 17 0 0 0 0 65535 2 Standard 65535 0 0 0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0 199 193 92 32 0 0 0 65535 2 Standard 65535 0 0 0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0 199 384 82 512 0 0 0 65535 2 Standard 65535 0 0 0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0 224 304 43 512 0 0 0 65535 275 Standard 65535 0 0 0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0 237 0 22 512 0 0 0 65535 2 Standard 65535 0 0 0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0 266 95 77 0 0 0 0 65535 2 Standard 65535 0 0 0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0 274 0 22 512 0 0 0 65535 2 Standard 65535 0 0 0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0 305 94 40 32 0 0 0 65535 65535 Standard 65535 0 0 0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0 327 244 70 0 0 0 0 65535 2 Standard 65535 0 0 0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0 332 0 22 512 0 0 0 65535 2 Standard 65535 0 0 0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0 359 161 41 0 0 1 0 65535 2 Standard 65535 0 0 0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0 376 430 78 0 0 0 0 65535 327 Standard 65535 0 0 0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0 386 0 22 512 0 0 0 65535 2 Standard 65535 0 0 0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0 406 0 22 512 0 0 0 65535 2 Standard 65535 0 0 0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0 442 160 23 0 0 0 0 65535 2 Standard 65535 0 0 0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0 473 0 17 0 0 0 0 65535 2 Standard 65535 0 0 0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0 484 0 0 1025 0 0 0 65535 65535 Standard 65535 0 0 0 0 0 0 0 0 0 65535 0 0 65535 0 0 0 0 0 [edoc] <+C><:s><:f240,BArial MT,> Paper 4015 <+C><:s><:f280,BArial MT,><+!> <+C><-!><+!><:f320,BArial MT,>Avoiding Pitfalls in M<-!><+!><:f320,BArial MT,>ulti-Language Programming <:f> <+C><:s><+!> <+C><:s><:f280,BArial MT,> <:f><:f280,BArial MT,> by <+C><:s><:f280,BArial MT,> <+C><:f240,BArial MT,> James Overman <+C><:f240,BArial MT,> Sue Meloy <+C><:f240,BArial MT,> Walter Murray <+C><:f240,BArial MT,> Jim Scaccia <+C><:f240,BArial MT,> <:f240,BArial MT,>Don Jenkins <+C><:s><:f240,BArial MT,> <+C><:f240,BArial MT,>Language Team members in the Software Technology Lab of the Support Technology Center of the Worldwide Customer Support Organization of: <+C><:s><:f240,BArial MT,> <+C><:s><:f240,BArial MT,>Hewlett-Packard Company <+C><:s><:f240,BArial MT,>8000 Foothills Boulevard <+C><:s><:f240,BArial MT,>Roseville, CA 95747-5613<:f><:f240,BArial MT,> <+C><:s><:f240,BArial MT,>(916) 785-5672 <+C><:s><:f240,BArial MT,> <+C><:f240,BArial MT,>This paper is a review of the features<:f><:f240,BArial MT,> involved in programs written using multiple languages in the HP3000 MPE/iX native mode environment. The languages to be discussed and the short identifiers that are used to refer to the languages in the paper are: <+C><:s><:f240,BArial MT,> <+C><:s><:f240,BArial MT,>HP Business Basic/iX Basic <+C><:s><:f240,BArial MT,>HP C/iX C <+C><:f240,BArial MT,>HP COBOL II/iX Cobol <+C><:f240,BArial MT,>HP FORTRAN 77/iX Fortran <+C><:s><:f240,BArial MT,>HP Pascal/iX Pascal <+C><:f240,BArial MT,>HP RPG/iX RPG <+C><:s><:f240,BArial MT,>HP TRANSACT/iX Transact <+C><:s><-"><:f240,BArial MT,> <+C><:s><:f240,BArial MT,>This paper is divided into topic areas and each topic includes a list of<+"> Pitfalls<-"> and <+">Recommendations<-"> before a more detailed discussion of the specific <:f><:f240,BArial MT,>items and language features. The topics are: <+C><:s><:f240,BArial MT,> <+C><:s><:f240,BArial MT,>Data Representation <+C><:s><:f240,BArial MT,>Procedure Invocations <+C><:s><:f240,BArial MT,>Compilation Options <+C><:f240,BArial MT,>Linkedit Commands <+C><:s><-"><:f240,BArial MT,>Exception Handling <+C><:s><:f240,BArial MT,>Run-time Factors <+C><:s><:f240,BArial MT,>Heap Management <+C><:s><:#283,8280><:f240,BArial MT,>Debugging Tips <+C><:f240,BArial MT,>POSIX Environment <+C><:s><:f240,BArial MT,> <+C><:f240,BArial MT,>This paper will not address the issues of interfacing with the older compatibility mode languages and data types. <+C><:s> <+C><:f240,BArial MT,>That it is possible at all to intermix routines from multiple languages is due to the HP Precision Architecture Procedure Calling Convention as described in the Procedure Calling Conventions Manual, which is listed in the Bibliography. <+C><:s> <+C><:f240,BArial MT,>To permit this paper to address the diverse issues and multiple languages herein, it has been necessary to generalize statements and to omit minor exceptions that might contradict those generalities. The references are the most complete d escription of the topics discussed and should be used as the authoritative source for actual implementation. We intend<:f><:f240,BArial MT,> that this paper will be of use as an overview of the subject. <+C><:s><:f240,BArial MT,> <+C><:s><:f280,BArial MT,><+#><+!>Data Representation<-!><-#><:f> <+C><:s><:f240,BArial MT,> <+C><:s><:f240,BArial MT,><+!>Pitfalls:<-!> <+C><:s><:f240,BArial MT,> <+C><:f240,BArial MT,>Pascal data types not generally supported by other languages include enumerated types, sets, and pointers. <+C><:s><:f240,BArial MT,> <+C><:f240,BArial MT,>Fortran REAL*16 datatype is not supported by other languages. <+C><:s><:f240,BArial MT,> <+C><:f240,BArial MT,>Cobol does not support floating-point data types. <+C><:s><:f240,BArial MT,> <+C><:f240,BArial MT,>Basic DECIMAL format is different from Cobol PACKED-DECIMAL. <+C><:s><:f240,BArial MT,> <+C><:f240,BArial MT,>RPG only passes<:f><:f240,BArial MT,> character and packed decimal parameters<:f><:f240,BArial MT,>. <+C><:s><:f240,BArial MT,> <+C><:f240,BArial MT,>TRANSACT supports several extended precision datatype sizes not available elsewhere. <+C><:s><:f240,BArial MT,> <+C><:s><:f240,BArial MT,>Strings are stored in differing formats by the various languages. Only the simplest character arrays are transferable among most languages. <+C><:s><:f240,BArial MT,> <+C><:s><:f240,BArial MT,><+!>Recommendations: <-!> <+C><:s><:f240,BArial MT,> <+C><:f240,BArial MT,>Use the simple data types (integers, characters, and reals). <+C><:s><:f240,BArial MT,> <+C><:f><:f><:f><:f><:f><:f><:f><:f240,BArial MT,><:p<* >> <+C><:s><:f240,BArial MT,><+!>Details: <-!> <+C><:s><:f240,BArial MT,> <+B><:s><:f240,BArial MT,><+!>Table 1<-!> <+C><:s><:f240,BArial MT,> <+C><:f240,BArial MT,>Data Representation Equivalences Across Languages <:f> <+C><:f220,BArial MT,> <+C><:f220,BArial MT,>Data Types that are highly compatible across many languages: <+C><:f220,BArial MT,> <+C><:f220,BArial MT,>Pascal Fortran Cobol C Basic Transact Note --<:f220,BArial MT,>----------------------------------------------------------------------------------------------------------------- <+C><:f180,BArial MT,>Char <:f><:f180,BArial MT,>CHARACTER PIC X char x$ X(1) <+C><-"><-"><:f180,BArial MT,>Integer INTEGER*4 <:f><:f180,BArial MT,>S9(9)<:f><:f180,BArial MT,>COMP <:f><:f180,BArial MT,> int <:f180,BArial MT,>INTEGER I(9) <+C><:f180,BArial MT,>Longint NA <:f><:f180,BArial MT,>S9(18)<:f><:f180,BArial MT,>COMP <:f><:f180,BArial MT,> NA NA I(18) <+C><:f180,BArial MT,>Longreal REAL*8 NA double REAL R(7) #1 <+C><:f180,BArial MT,>PAC of n CHARACTER*n PIC X(n) char <[>n] x$ X(n) #2 <+C><:f180,BArial MT,>String CHARACTER*(*) NA char <[>n] x$ X(n) #2 <+C><:f180,BArial MT,>Real REAL*4 NA float SHORT REAL R(6) <:f180,BArial MT,> #1 <+C><:f180,BArial MT,>Shortint INTEGER*2 <:f><:f180,BArial MT,>S9(4) <:f><:f180,BArial MT,>COMP <:f><:f180,BArial MT,> short SHORT INTEGER I(4) <:f> <+C><:s><:f240,BArial MT,> <+C><:s><:f240,BArial MT,>NOTES: <+C><:s><:f240,BArial MT,> <:I72,0,0,0><:f240,BArial MT,>#1 Transact also has a type E (Real Scientific Notation) that is the same as REAL in storage. Fortran has a REAL*16 that has no other language equivalents. In Cobol, you can use the Compiler Library routines PEXTIN and HPINEX T to convert real data types to/from data types that Cobol can manipulate. <:s><:f240,BArial MT,> <:f240,BArial MT,>#2 Cobol and Transact support other character data types such as numeric-only and uppercase characters. RPG also supports the character datatype. Strings are stored in different formats that are generally incompatible across languages. <+C><:s><:f220,BArial MT,><:p<* >> <+B><:f240,BArial MT,><+!>Table 2<-!><:f> <+C><:s><:f160,BArial MT,> <+C><:f240,BArial MT,>Data Representation Equivalences Across Languages <:f> <+C><:f240,BArial MT,> <+C><:f240,BArial MT,>Not so compatible data types across languages with best equivalents: <+C><:s><:f240,BArial MT,> (~ denotes size equivalency but not identical computationally) <:f> <+C> <+C><:f220,BArial MT,>Pascal Fortran Cobol C Basic Transact Note --<:f220,BArial MT,>----------------------------------------------------------------------------------------------------------------- <+C><:f160,BArial MT,>Bit16 ~INTEGER*2 <:f><:f160,BArial MT,>9(4) <:f><:f160,BArial MT,>COMP <:f><:f160,BArial MT,> unsigned short ~SHORT INTEGER K(4) <:f><:f160,BArial MT,> #3 <+C><:f160,BArial MT,>Bit32 ~INTEGER*4 <:f><:f160,BArial MT,>9(9) <:f><:f160,BArial MT,>COMP <:f><:f160,BArial MT,> unsigned int ~INTEGER K(9) #3 <+C><:f160,BArial MT,>Bit52 NA <:f><:f160,BArial MT,>9(18) <:f><:f160,BArial MT,>COMP <:f><:f160,BArial MT,> NA NA K(18) #3 <+C><:f160,BArial MT,>Boolean LOGICAL*1 NA ~character NA NA <+C><:f160,BArial MT,>~Record <:f160,BArial MT,>COMPLEX NA ~struct ~SHORT REAL ~R(6) #4 <+C><:f160,BArial MT,>Enum NA NA enum NA NA #5 <+C><:f160,BArial MT,>Pointer NA NA pointer NA NA <+C><:f160,BArial MT,>Record RECORD record struct ~x$ NA #6 <+C><:f160,BArial MT,>Set NA NA ~struct NA NA <+C><:f160,BArial MT,>NA NA COMP-3 NA NA P #7 <+C><:s><:f240,BArial MT,> <+C><:f160,BArial MT,><+#>Subranges <-#> <+C><:s><:f160,BArial MT,> <+C><:f160,BArial MT,>0..255 ~BYTE NA unsigned char NA NA <+C><:f160,BArial MT,>0..65535 ~INTEGER*2 ~COMP 9(4) unsigned short ~SHORT INTEGER <:f160,BArial MT,> K(4) #3 <:f> <+C><:s><:f240,BArial MT,> <+C><:s><:f240,BArial MT,>NOTES: <:f> <+C><:s><:f180,,> <+C><:f240,BArial MT,>#3 Integers may hold unsigned integer values with the first bit being interpreted as a sign rather than the larger unsigned magnitudes. Transact has 12-byte integer types with no equivalents in other languages. <+C><:s><:f240,BArial MT,> <+C><:f240,BArial MT,>#4 COMPLEX storage equivalent is two real numbers in a record/structure or two-element array. Only Fortran supports COMPLEX arithmetic. <+C><:s><:f240,BArial MT,> <+C><:f240,BArial MT,>#5 C enum is always 4 bytes in size, Pascal enum can be 1,2,or 4 bytes. <+C><:s><:f240,BArial MT,> <+C><:f240,BArial MT,>#6 Basic uses PACK and UNPACK to create and decompose structures/records to and from string variables. <+C><:s><:f240,BArial MT,> <+C><:f240,BArial MT,>#7 Packed decimal data type is common to Cobol, RPG, and Transact. <:f><:f240,BArial MT,> Basic's DECIMAL data type is not compatible with other languages. Zoned decimal data type is also common to Cobol and Transact. <+C><:s><:f240,BArial MT,> <+C><:s><:f240,BArial MT,> <+C><:s><:f240,BArial MT,> <+C><:s><:f280,BArial MT,><+#><+!> <+C><:s><+!><+#><:f280,BArial MT,> <+C><:s><+!><+#><:f280,BArial MT,> <+C><:#360,8280><+!><+#><:f280,BArial MT,>Procedure Invocations<-!><-#><:f> <+C><:s><:f240,BArial MT,> <+C><:s><:f240,BArial MT,><+!>Pitfalls: <-!> <+C><:s><:f240,BArial MT,> <+C><:f240,BArial MT,>Procedure name case should be considered carefully as some languages upshift, downshift, or are case sensitive. <+C><:s><:f240,BArial MT,> <+C><:f240,BArial MT,>Procedure names which contain special characters (like underscore, hyphen, apostrophe) will frequently require ALIASing to allow access from other languages. <+C><:s><:f240,BArial MT,> <+C><:f240,BArial MT,>Parameters may be passed by value, by reference, or by descriptor, and the mode of parameter passing differs by language. <+C><:s><:f240,BArial MT,> <+C><:f240,BArial MT,>Parameters other than the simple data types may be difficult to construct and/or process in the various languages. <+C><:s><:f240,BArial MT,> <+C><:f240,BArial MT,>Data alignment can be a problem; use SYNC in Cobol, avoid CRUNCHED in Pascal. <+C><:s> <+C><:s><:f240,BArial MT,>Hidden parameters can cause interfacing problems unless they are properly accounted for in the procedure call. <+C><:s><:f240,BArial MT,> <+C><:s><:f240,BArial MT,>Global and Common data may not be visible to routines written in other languages. <+C><:s><:f240,BArial MT,> <+C><:s><:f240,BArial MT,><+!>Recommendations:<-!> <+C><:s><:f240,BArial MT,> <+C><:s><:f240,BArial MT,>Procedure names should be less than fifteen characters in length, lowercase, with no special characters. <+C><:s><:f240,BArial MT,> <+C><:f240,BArial MT,>Use <:f><:f240,BArial MT,>simple data types whenever possible. <+C><:f><:f><:f><:f240,BArial MT,> <+C><:f240,BArial MT,>Avoid passing structures and arrays. Single dimension arrays of simple data types may be passed by reference. <+C><:f240,BArial MT,> <+C><:s><:f240,BArial MT,>Use parameters to pass shared data rather than global data items. <+C><:s><:f240,BArial MT,> <+C><:f240,BArial MT,>Extensible parameter lists should be avoided, when possible. <+C><:s><:f240,BArial MT,> <+C><:f240,BArial MT,>System Intrinsics (as opposed to language intrinsics) should always be externally defined via the automatic language specification that uses the SYSINTR.PUB.SYS intrinsic specification file. <+C><:s><:f240,BArial MT,> <+C><:f240,BArial MT,><+!> <+C><+!><:f240,BArial MT,>Details: <-!> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#3396,8280><:f240,BArial MT,>Procedure names (except intrinsics) are downshifted by default for all languages except C (which uses mixed-case names). <:f><:f240,BArial MT,>In C, you must write external names exactly as they are to be seen by the linkeditor or loader. For example, the Pascal procedure name 'ProcessNextRecord' would be downshifted by the compiler. To call it from C, you would have to wri te it in lower case 'processnextrecord'. <:f><:f240,BArial MT,>By default, Cobol external names have hyphens converted to underscores. This convention can be defeated by preceding the routine name in a Cobol CALL statement by a backslash. In Pascal and For tran, the ALIAS option may be used to provide access to names that are invalid within the language (eg. names with apostrophes). The LITERAL_ALIAS and UPPERCASE compiler options may be used to reference mixed-case and uppercase routine names. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#1698,8280><:f240,BArial MT,>The default external routine name in Basic can be overridden by providing an alias on the EXTERNAL or GLOBAL EXTERNAL statement. <:f><:f240,BArial MT,>It is not possible in C to create or to call a function with a special character in its name, except for the underscore. RPG uses the EXIT operator to invoke external routines with up to a six character routine name placed in the facto r 2 field - columns 33-42, left-adjusted. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#4245,8280><:f240,BArial MT,>Parameters may be passed by value, by reference, or by descriptor. C passes parameters by value. <:f240,BArial MT,>This is part of the simplicity of design of the C language. Passing by reference involves dealing with pointers, and the C programmer is expected to code pointer operations explicitly. <:f240,BArial MT,>To simulate passing a parameter by reference, explicitly pass the address of the desired object. <:f240,BArial MT,>A Cobol program normally passes parameters by reference, although an HP extension does allow passing by value. A Cobol routine expects its parameters to be passed by reference. <:f240,BArial MT,>Transact uses the "%" option to pass a given parameter by byte address; "#" to pass a parameter by value; "&" to indicate the parameter is a function value return. Fortran passes parameters by reference unless told otherwise. Pointers from another language may be passed by value to Fortran which can treat them as addresses of reference parameters or simply as identifiers to be passed to other languages' routines. Passing function references as parameters is a complex area and should be avoi ded unless required for traps and sorting. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#5094,8280><:f240,BArial MT,>In Basic and Pascal, the EXTERNAL directive allows for the specification of the language in which an external procedure was written. The language specifier will cause certain language specific adjustments to the procedure calling code to b e made, thus facilitating such procedure calls. For example, PASCAL will convert its string format to that of C during a procedure call, and will convert the string back to the Pascal format upon return, thereby updating the string length. In Basic, for BYT E String$ parameters, the address passed is a pointer to the start of the string data. However for String$, if the language specifier is BASIC, the address passed is a pointer to the maximum length. For a non-Basic specifier, the address passed is a point er to the current length, and the value of the maximum length is passed as a hidden parameter immediately following the string address. For Basic, if a called routine written in another language changes the length of a string parameter, the current length o f the string must be updated. This can be done by the called routine or by the SETLEN statement, or automatically (for the Pascal specifier) after returning to the Basic routine. In Fortran, the ALIAS directive includes the external language specifier, and allows specification of individual parameter passing modes of value, reference, and descriptor. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#1132,8280><:f240,BArial MT,>Arrays are normally passed by reference. Within<:f><:f240,BArial MT,> Basic the address passed will be a pointer to the start of the array information block. Otherwise, for other languages the address passed will be a pointer to the star t of the array data. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#2830,8280><:f240,BArial MT,>Arrays of greater than one dimension are frequently a source of parameter passing problems. <:f><:f240,BArial MT,>Fortran stores arrays in <:f><:f240,BArial MT,>column-major order, while other languages use row-major order.<:f><:f240,BArial MT,> When passed as reference parameters, the compilers often add hidden parameters that contain the maximu m indexes and other information. Fortran uses hidden parameters for assumed-size arrays and for extensible parameters lists. <:f><:f240,BArial MT,> Pascal uses hidden parameters for ANYVAR, generic strings, multi-dimensional arrays, and extensible parameter lists. In Pascal, use of the language specifier FTN77 on the EXTERNAL directive will automatically provide the hidden array size for Fortran subroutine calls. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#3396,8280><:f240,BArial MT,>RPG programs may not be compiled as subroutines. Therefore<:f><:f240,BArial MT,>, RPG<:f><:f240,BArial MT,> programs cannot be called from other languages. You may<:f><:f240,BArial MT,> use another language for any external routines. Th e best language to use is Cobol, since it supports data types that match those of RPG. If you use other languages, you will have to do extra work to manipulate numeric data. RPG uses the EXIT operator to call the external routine. It passes parameters to it with RLABL or PARM items. Items declared as RLABLs are global, and are not explicitly passed to the routine. All PARM items are passed by reference; i.e. by a pointer to the item. If you are accessing RLABL items in your routine, you must link it with the RPG program file. If you use only PARM items (or none at all), you may link with the program or create an XL file containing your routine(s). <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#1981,8280><:f240,BArial MT,>Calling Transact from another language requires the calling program to use an architected call interface (ACI) to allocate the entire Transact data register. Values placed in the data buffer must be correct Transact formats and must be do uble-byte aligned. If the data buffer of the calling program is not defined exactly as the Transact routine's data register, an error message, such as DATA MEMORY PROTECTION TRAP, is issued and the program<:f><:f240,BArial MT,> terminates. <+C><:s><:#280,8280><:f240,BArial MT,> <+C><:f240,BArial MT,>The data register space allocated to the Transact routine is determined by the data_length parameter of the ACI intrinsic call, not the DATA=Data_Length option of the SYSTEM statement in the called Transact routine. The DATA=Data_Length op tion of the SYSTEM statement and the ACI data_length parameter differ in how they are declared. The DATA=Data_Length is declared in 16-bit words; the data_length parameter is declared in bytes. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#849,8280><:f240,BArial MT,>When the called Transact routine uses VPLUS forms, it is the responsibility of the calling program to ensure that the terminal is in character mode prior to the call. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#2264,8280><:f240,BArial MT,>In general, the common data types are properly aligned and so no problems will occur. In Pascal, the system programming extension CRUNCHED form of PACKing<:f><:f240,BArial MT,> will generally produce non-aligned data items within a record ; this should be avoided. In Cobol, the SYNCHRONIZED clause may be used to force alignment to standard boundaries, as may the SYNC16 or SYNC32 option. This may be required, as in Cobol, level-01 and level-77 data items outside the Linkage Section are align ed on word boundaries, but the default for other items is byte alignment. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#1698,8280><:f240,BArial MT,>In Transact, use the "%" option to pass a given parameter by byte address; The form "%n" (where the n is either 8, 16, 32, or 64) indicates the bit boundary to align on. When constructing structures, alignment problems may be avoided by p lacing the largest sized data types first, followed by progressively smaller sized data types. This allows the natural alignment of the individual items and avoids the insertion of padding or filler items. <:f> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#2264,8280><:f240,BArial MT,>Calling routines written in other languages from Transact, by default, generates code to make copies of all reference parameters if they are not preceded by "%", "#", or "&". Data is copied to a temporary buffer whose alignment is determi ned from the type and size of the item passed via the PROC call through which the Transact aligned parameters are passed. However, since this copying is inefficient, the compiler options PROCALIGNED_16/32/64 should be used whenever possible to bypass the c opy mechanism. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#3113,8280><:f240,BArial MT,>A future version of <:f><:f240,BArial MT,>Basic will include a new built-in function that returns the byte address of a data item. This will allow the creation of records/structures containing pointers. Until this is available, you can gen erate a pointer by passing the parameter by reference. If you need to save the pointer for further manipulation by Basic (such as to PACK it into a structure), call a helper function that simply returns the address passed to it, and save this value in an I NTEGER variable. You will need to lie to Basic about the type of the return value, and you may need to link the program with PARMCHECK=0. This works because short pointers and integers have the same size and alignment, and are passed the same way in the pr ocedure calling convention. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:f240,BArial MT,>Fortran COMMON blocks are not shareable with other languages, nor is the Basic COM block linkable to global data in other languages. To access Fortran COMMON or Basic COM data from another language, use a reference parameter to pass the fi rst item of the block to the routine in the other language. In the called routine, declare the data as a record/structure with data items that correspond to those for the Fortran or Basic common block. <:p<* >> <+C><:s><:#360,8280><:f280,BArial MT,><+#><+!>Compilation Options<-!><-#><:f> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#280,8280><-!><-#><:f240,BArial MT,><+!>General: <-!> <+C><:#283,8280><:f240,BArial MT,> <+C><:I0,0,0,0><:#1698,8280><:f240,BArial MT,>Frequently, we forget to use the simple compiler options available that provide very useful information for program debugging. TABLE or MAP options can provide symbol lists with type, size, and alignment information. Range checking may b e activated for development testing. Automatic initialization may be selected to avoid those nasty undefined value problems in FORTRAN via the $INIT option. <+C><:I0,0,0,0><:#283,8280><:f240,BArial MT,> <+C><:I0,0,0,0><:#1415,8280><:f240,BArial MT,>If Shared Globals are used extensively, the default limit on the number of global data references of approximately 2000 may be reached. This limit may be removed with the recently introduced compiler options of $MORE_GLOBALS for Pascal, $ CONTROL MOREGLOBALS for Cobol, and the +k pragma for C. <:f> <+C><:#280,8280><+!><+#><:f240,BArial MT,> <+C><:#283,8280><+!><+#><:f240,BArial MT,>C:<-#> <-!> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#566,8280><:f240,BArial MT,>#pragma HP_ALIGN allows you to control the alignment of structure members. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#849,8280><:f240,BArial MT,>The +u option instructs the compiler to assume that pointers may point to objects that are half-word aligned, and generate code accordingly. This will degrade performance and is not recommended if it can be avoided. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#283,8280><:f240,BArial MT,><+!><+#>Cobol:<-#> <-!> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#566,8280><:f240,BArial MT,>$CONTROL OPTFEATURES=CALLALIGNED flags any parameters not on a 32-bit boundary. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#849,8280><:f240,BArial MT,>$CONTROL OPTFEATURES=LINKALIGNED improves performance of a Cobol subprogram. Use only if you know that every parameter passed to the subprogram will be 32-bit aligned. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#566,8280><:f240,BArial MT,>$CONTROL SYNC16 causes the SYNCHRONIZED clause to align on 16-bit boundaries. $CONTROL SYNC32 restores the default, 32-bit alignment. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:I0,0,0,0><:#280,8280><-!><:f240,BArial MT,><+#><+!>Transact:<-!><-#> <+C><:I0,0,0,0><:#283,8280><:f240,BArial MT,> <+C><:I0,0,0,0><:f240,BArial MT,>The Transact PROCINTRINSIC option must be used to call an intrinsic when the intrinsic is not declared with DEFINE(INTRINSIC). If this option is not used, the Transact compiler downshifts any procedure names not found in the SYSINTR.PUB.S YS file which <:f><:f240,BArial MT,>may result in the procedure name not being found. <:p<* >> <+C><:s><:#360,8280><:f280,BArial MT,><+#><+!>Link Editor Considerations<-!><-#><:f> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#283,8280><:f240,BArial MT,><+!>General: <-!> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#283,8280><:f240,BArial MT,>Dependent libraries <+C><:I720,0,0,0><:#1698,8280><:f240,BArial MT,>Dependent libraries will soon be supported on a MPE/iX post-5.0 release. This enhancement will allow a list of library dependencies to be associated with a library. When the library is loaded, its dependent libraries are also loaded . This allows the dependencies to be isolated within the libraries themselves; only the first-level libraries need to be specified when linking or running the program. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#283,8280><:f240,BArial MT,>Parameter type checking <+C><:I720,0,0,0><:#849,8280><:f240,BArial MT,>Different languages have different requirements for parameter type checking. The linker PARMCHECK option can be used to relax the type checking done. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#283,8280><:f240,BArial MT,>Shared globals <+C><:I720,0,0,0><:#1132,8280><:f240,BArial MT,>With MPE/iX 5.0, global data symbols can now be visible from an executable library (XL). This allows sharing data between a program file and XLs, but beware that these symbols could now conflict with definitions in the program or in other XLs. <+C><:s><:I720,0,0,0><:f240,BArial MT,><:p<* >> <+C><:s><:#360,8280><:f280,BArial MT,><+#><+!>Exception Handling<:f280,BArial MT,> <:f240,BArial MT,> <-!><-#> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#283,8280><:f240,BArial MT,><+!>Pitfalls: <-!> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:I0,0,0,0><:#283,8280><:f240,BArial MT,>MPE only allows one active trap procedure per process<:f><:f240,BArial MT,> for each type of trap. <+C><:s><:I0,0,0,0><:#283,8280><:f240,BArial MT,> <+C><:s><:I0,0,0,0><:#566,8280><:f240,BArial MT,>In order for some language features to work properly, the trap handler for that language must be active. <+C><:s><:I0,0,0,0><:#283,8280><:f240,BArial MT,> <+C><:s><:I0,0,0,0><:#566,8280><:f240,BArial MT,>Some languages require explicit initialization of the trap handler when a routine is called from a foreign outer block. <+C><:s><:I0,0,0,0><:#283,8280><:f240,BArial MT,> <+C><:s><:I0,0,0,0><:#566,8280><:f240,BArial MT,>The first call to a Basic routine will automatically set Basic trap handling, overriding any previous trap settings. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#283,8280><:f240,BArial MT,><+!>Recommendations<-!>: <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:I0,0,0,0><:#566,8280><:f240,BArial MT,>If you are using trap handling features in multiple languages, save and restore the traps across each call to a routine in the other language(s). <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#283,8280><:f240,BArial MT,><+!>Details: <-!> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#1132,8280><-!><:f240,BArial MT,>While Cobol code is executing, it expects the Cobol trap mechanism to be armed in order for certain exceptions to be processed correctly. In an all-Cobol environment, this is normally done only once, by the main program. The same i s true for Fortran and Pascal. <+C><:s><:I720,0,0,0><:#283,8280><:f240,BArial MT,> <+C><:I0,0,0,0><:#1415,8280><:f240,BArial MT,>Suppose a Cobol main program calls a Pascal subprogram, but nothing is done to change the trap-handling environment. If a run-time error <:f><:f240,BArial MT,> occurs in the Pascal subprogram, it is likely to be r<:f><:f240,BArial MT,>eported incorrectly. For example, a Pascal file I/O error might be reported with the message "No SIZE ERROR phrase (COBERR 747)". <+C><:s><:I0,0,0,0><:#283,8280><:f240,BArial MT,> <+C><:I0,0,0,0><:#566,8280><:f240,BArial MT,>Likewise, a Cobol subprogram called from a non-Cobol outer block is likely to report errors<:f><:f240,BArial MT,> in mysterious ways. <+C><:s><:I0,0,0,0><:#283,8280><:f240,BArial MT,> <+C><:I0,0,0,0><:#849,8280><:f240,BArial MT,>During a call to a Transact routine, arithmetic trapping is always enabled via calls <:f><:f240,BArial MT,> to HPENBLTRAP, XARITRAP and XLIBTRAP, and is reset to the prior state upon return. <+C><:s><:I720,0,0,0><:#283,8280><:f240,BArial MT,> <+C><:#566,8280><:f240,BArial MT,>To enable Pascal trap handling, call U_INIT_TRAPS prior to calling the first Pascal routine. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#566,8280><:f240,BArial MT,>To enable Fortran trap handling, call FTN_INITRAP prior to calling the first Fortran routine (if e.g. ON statements are used in the Fortran routines). <+C><:#566,8280><:f240,BArial MT,>To enable Cobol trap handling, call COBOLTRAP to arm the Cobol trap mechanism. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#1981,8280><:f240,BArial MT,>When a non-Basic language calls a Basic routine, the traps for the calling language will be changed to Basic trap handling mode. Basic sets up its trap handling with calls to XCONTRAP, XARITRAP, and XLIBTRAP. This is done during progra m initialization, after the SYSTEM or SYSTEMRUN statements, or when the BRK function is called with a positive argument. Program initialization occurs when a Basic main program is run, or on the first call to a Basic routine from a foreign outer block. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#566,8280><:f240,BArial MT,>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. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#1698,8280><:f240,BArial MT,>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. Th erefore, if the HALT occurs when executing a foreign routine, detection of the condition may be delayed until execution resumes in Basic. <+C><:s><:f240,BArial MT,><:p<* >> <+C><:s><:#360,8280><:f280,BArial MT,><+#><+!>Runtime Factors<-!><-#><:f> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#283,8280><:f240,BArial MT,><+!>Pitfalls:<-!> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#566,8280><:f240,BArial MT,>HFS file names may exceed the previous maximum name length for MPE files. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#283,8280><:f240,BArial MT,>Certain file names are used by some languages for special purposes. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#283,8280><:f240,BArial MT,>Special care must be taken when using VPLUS forms with some languages. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#566,8280><:f240,BArial MT,>Some file types and special I/O handling may not be supported by all languages. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#566,8280><:f240,BArial MT,>File I/O cannot readily be shared between C and other languages because I/O in C is buffered internally. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#283,8280><:f240,BArial MT,>Basic may output a terminal status check during initialization. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#566,8280><:f240,BArial MT,>The Basic Report Writer has no knowledge of output generated by intrinsics or by foreign routines. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#283,8280><:f240,BArial MT,><+!>Recommendations: <-!> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#849,8280><:f240,BArial MT,>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. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#566,8280><:f240,BArial MT,>Avoid using file names that conflict with those reserved by any of the languages. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#566,8280><:f240,BArial MT,>Use VPLUS intrinsic calls rather than language form-handling statements if the form must be active across inter-language procedure calls. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#566,8280><:f240,BArial MT,>Make sure that the terminal is in character mode before calling a Transact routine. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#849,8280><:f240,BArial MT,>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. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#566,8280><:f240,BArial MT,>Make sure that the I/O buffer is flushed before calling a foreign routine or intrinsic that accesses shared files.<:f> <+C><:s><:#849,8280><:f240,BArial MT,>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. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#566,8280><:f240,BArial MT,>While a Basic report is active, use only Basic I/O statements to write to the output file. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#283,8280><:f240,BArial MT,><+!>Details: <-!> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#1698,8280><:f240,BArial MT,>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 MP E. 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. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#849,8280><:f240,BArial MT,>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. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#849,8280><:f240,BArial MT,>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. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:I0,0,0,0><:#566,8280><:f240,BArial MT,>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: <+C><:I0,0,0,0><:#283,8280><:f240,BArial MT,> IPxxxxxx - Transact p-code file <+C><:I720,0,0,0><:#283,8280><:f240,BArial MT,>ITxxxxxx - TRANDEBUG file (version A.04.00 and earlier) <+C><:I720,0,0,0><:#283,8280><:f240,BArial MT,>IUxxxxxx - TRANDEBUG file (version A.04.02 and later) <+C><:s><:I720,0,0,0><:#283,8280><:f240,BArial MT,>OUTPUT - Internal file used by Transact <+C><:I720,0,0,0><:#283,8280><:f240,BArial MT,>where xxxxxx is the system name of the Transact program. <+C><:s><:I720,0,0,0><:#283,8280><:f240,BArial MT,> <+C><:#2264,8280><:f240,BArial MT,>When calling a Transact routine, all databases and files specified in the system statement will be opened, <:f><:f240,BArial MT,>whether or not they are accessed by the calling program. No database or file information is preserved during a call to a Transact routine. <:f><:f240,BArial MT,>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. <:f><:f240,BArial MT,>Transact maintains its own copy of the VPLUS comarea, which is not accessible outside the Transact runtime system. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#3113,8280><:f240,BArial MT,>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 B<+,>ASIC<-,>-compatible. Be aware that if the configuration file specifies a B<+,>ASIC<-,>-compatible terminal, the Basic initialization routine will output a terminal status check to qu ery 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 n ot accessible outside the Basic runtime system. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#566,8280><:f240,BArial MT,>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. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#1698,8280><:f240,BArial MT,>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 langua ges, 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. <:f> <+C><:s><:f240,BArial MT,><:p<* >> <+C><:s><:#360,8280><:f280,BArial MT,><+#><+!>Debugging Tips<-!><-#><:f> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#283,8280><:f240,BArial MT,><+!>Pitfalls: <-!> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#1415,8280><:f240,BArial MT,>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. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#283,8280><:f240,BArial MT,><+!>Recommendations<-!>: <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#566,8280><:f240,BArial MT,>Utilize the compiler options for symbol lists, range or overflow checking, and initialization. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#283,8280><:f240,BArial MT,>Turn on range and overflow checking in languages that support it. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#566,8280><:f240,BArial MT,>For languages that support level 2 optimization, the optimizer can sometimes detect uninitialized variables and give a warning. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#566,8280><:f240,BArial MT,>C, Cobol, Fortran and Pascal support the XDB and Toolset symbolic debuggers. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#1132,8280><:f240,BArial MT,>Use compiler options to print code offsets and symbol maps for assembly-level debugging. Symbol maps can also help detect inconsistencies with structure layouts that are shared between multiple languages. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#566,8280><:f240,BArial MT,>Debugging block-mode applications can be done by redirecting I/O to a hardwired terminal or nailed network device. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#283,8280><-!><+!><:f240,BArial MT,>Details: <-!> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#849,8280><:f240,BArial MT,>Some languages have an option to turn on automatic initialization. If the program works with initialization on and fails with it off, this could indicate the problem is due to an uninitialized variable. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#566,8280><:f240,BArial MT,>In the linker, an indirect file can contain options to be passed to the link command. Some useful debugging options are: <+C><:s><:#849,8280><:f240,BArial MT,> -v Display verbose messages during linking. For each library module that is loaded, the linker indicates which symbol caused that module to be loaded. <+C><:s><:#849,8280><:f240,BArial MT,> -y < Indicate each file in which < appears. Many such options can be given to trace many symbols, but -y must precede each one. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#1415,8280><:f240,BArial MT,>Even when the outer block language does not support the Symbolic Debugger (XDB)<:f><:f240,BArial MT,>, routines written in C, Cobol, Fortran and Pascal can be compiled for XDB debugging and linked into the program. This will allow those r outines to be symbolically debugged, while the rest of the program can be debugged at the assembly level. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#566,8280><:f240,BArial MT,>XDB does not currently support debugging code in XLs. Statically link all code you wish to symbolically debug into the program file. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#849,8280><:f240,BArial MT,>By default, XDB uses the language syntax of the current procedure. This can cause confusion when debugging programs written in multiple languages. For example, in XDB C language mode, the command <+C><:s><:#283,8280><:f240,BArial MT,> p x = 0 <+C><:s><:#566,8280><:f240,BArial MT,>will assign 0 to x and print 0, the new value of x. In Pascal mode, it will print 0 if x is not 0, but the value of x will not change. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#283,8280><:f240,BArial MT,> p $lang <+C><:#1132,8280><:f240,BArial MT,>will print the name of the language currently being used. If you explicitly set $lang to a particular language, all debugging commands will use this language syntax regardless of the language of the procedure you are debugging. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#1698,8280><:f240,BArial MT,>RPG has a DEBUG operator which may be used (in the RPG program only, not in the external subroutine) to display indicator settings and the contents of a field wherever it is used in C-specs. This may not be adequate for debugging, particu larly in the external procedure. The only other approach is to use NMDEBUG. RPG does not support XDB or Toolset. RPG RLABL global items can be referenced by name in NMDEBUG. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#1981,8280><:f240,BArial MT,>One place where you can get in trouble is in debugging applications that use RSI or VPLUS. Since these run in block mode, you must redirect I/O to a hardwired terminal before running the program. To redirect I/O for VPLUS applications, ge t the file name used for the terminal (eg., the RPG program F-spec defining the workstation). File equate this name to the LDEV number of the hardwired terminal. For RSI applications, the name RSIIO must <:f><:f240,BArial MT,>be file equated to the hardwired terminal LDEV. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#2830,8280><:f240,BArial MT,>Transact supports its own debugging subsystem, TRANDEBUG. You must compile your program with the "TRANDEBUG" compiler option to allow debugging via TRANDEBUG. TRANDEBUG can be disabled without recompiling the program by setting the syste m variable "TRANDEBUG" off via a SETVAR TRANDEBUG, "OFF" command. <:f><:f240,BArial MT,> TRANDEBUG single-stepping returns control after each Transact statement, except in the case of LIST or DATA statements, which return control after each data item is loaded into the list or data register. TRANDEBUG does not support oth er programming languages, such as Cobol, Fortran or Pascal, but allows you to invoke NMDEBUG for this purpose. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#1132,8280><:f240,BArial MT,>Basic does not support XDB or Toolset. Debug the Basic portion of your program from the interpreter, or use NMDEBUG or XDB to debug compiled code in assembly mode. To do assembly level debugging, use the COPTION LIST,ID,LABEL options when compiling your Basic program. <+C><:s><:#283,8280><:f240,BArial MT,> LIST - enables ID and LABEL. This is the default. <+C><:s><:#283,8280><:f240,BArial MT,> I<:f><:f240,BArial MT,>D - Prints a table of identifiers, types, and addresses. <+C><:#849,8280><:f240,BArial MT,> LABEL - Prints a table of program line numbers and their code offsets. Assembly code can be dumped during compilation using ;info="#-da" in the compiler runstring. <+C><:s><:#283,8280><-!><-#><:f240,BArial MT,> <+C><:s><:#283,8280><:f240,BArial MT,><+!>Pitfalls:<-!> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#849,8280><:f240,BArial MT,>Do not use MARK and RELEASE to free heap space if routines in foreign languages are called. Pascal, C, Fortran, and Basic use the heap to store data that is expected to be preserved between invocations. <+C><:s><:f240,BArial MT,><:p<* >> <+C><:#360,8280><:f280,BArial MT,><+#><+!>Posix Environment<-!><-#><:f> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#283,8280><:f240,BArial MT,><+!>Pitfalls: <-!> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#283,8280><:f240,BArial MT,>New HFS-filenames <:f><:f240,BArial MT,>can cause many <:f><:f240,BArial MT,>problems. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#283,8280><:f240,BArial MT,>Only the C compiler is supported under the MPE/iX <++>Posix<-+> Shell. <+C><:s><:#283,8280><:f240,BArial MT,><+!> <+C><:s><:#283,8280><+!><:f240,BArial MT,>Recommendations: <-!> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#566,8280><:f240,BArial MT,>Except for the C language, language development should be done in the MPE/iX Command Interpreter <:f><:f240,BArial MT,>environment. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#283,8280><:f240,BArial MT,><+!>Details:<-!> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#1132,8280><:f240,BArial MT,>POSIX has introduced the HFS-syntax to file names. Valid file names now allow many combinations that were invalid in the past. Especially beware of file names that use language suffixes (like .c or .p) as these file names are often seen as file.group and the groups C or P generally do not exist. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#849,8280><:f240,BArial MT,>The Pascal compiler does support HFS input and output file names. H<:f><:f240,BArial MT,>owever, the file names are limited to 132 characters. The Pascal Run-time Library is limited to <:f><:f240,BArial MT,>file names of 255 characters. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#566,8280><:f240,BArial MT,>Basic, C<+,>OBOL<-,>, Fortran, RPG, and Transact<:f><:f240,BArial MT,> do not currently support POSIX file naming conventions. <+C><:s><:f240,BArial MT,><:p<* >> <+C><:s><:#283,8280><:f240,BArial MT,><+#><+!>BIBLIOGRAPHY<-#><-!><:f> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#283,8280><+!><+#><:f><:f><:f240,BArial MT,>General Information:<-!><-#> <+C><:I0,0,0,0><:f220,BArial MT,> <+C><:I0,0,0,0><:f240,BArial MT,>Data Types Conversion Programmer's <:f240,BArial MT,> P/N 32650-90015 Oct 1989 <+C><:I0,0,0,0><:f240,BArial MT,>Guide <+C><:I0,0,0,0><:f240,BArial MT,> <+C><:I0,0,0,0><:f240,BArial MT,>Communicator 3000 MPE/iX P/N 30216-90124 Jan 1995 <:f240,BArial MT,> <+C><:I0,0,0,0><:#283,8280><:f240,BArial MT,> <+C><:I0,0,0,0><:#849,8280><:f240,BArial MT,>Compiler Library/XL Reference Manual P/N 32650-90029 Oct1988 Chapter 3: describes procedures for converting numeric data of various types,including floating-point. <+C><:I0,0,0,0><:f240,BArial MT,>Chapter 4: describes procedures for manipulating packed- decimal data in languages that do not support that data type. <+C><:I0,0,0,0><:f240,BArial MT,> <+C><:I0,0,0,0><:#283,8280><:f240,BArial MT,>General Release 5.0 <+C><:I0,0,0,0><:#283,8280><:f240,BArial MT,>Chapter 6. Application Development <+C><:I0,0,0,0><:f240,BArial MT,>Chapter 10. Technical Articles <+C><:I0,0,0,0><:f240,BArial MT,> <+C><:I0,0,0,0><:f240,BArial MT,>HP Link Editor/iX Reference Manual <:f240,BArial MT,>P/N 32650-90030 <+C><:#283,8280><:f240,BArial MT,> <+C><:I0,0,0,0><:#283,8280><:f240,BArial MT,>HP Precision Architecture P/N 09740-90014 <+C><:I0,0,0,0><:#283,8280><:f240,BArial MT,>and Instruction Set Reference Manual <+C><:I0,0,0,0><:f240,BArial MT,> <+C><:I0,0,0,0><:f240,BArial MT,>New Features of MPE/iX: P/N 32650-90351 Apr 1994 <:f240,BArial MT,> <+C><:I0,0,0,0><:#566,8280><:f240,BArial MT,>PA-RISC Procedure Calling Conventions P/N 09740-90015 Reference Manual, <+C><:I0,0,0,0><:f240,BArial MT,> <+C><:I0,0,0,0><:f240,BArial MT,>Symbolic Debugger/iX User's Guide P/N 31508-90003 <+C><:I0,0,0,0><:f240,BArial MT,> <+C><:I0,0,0,0><:f240,BArial MT,>Technical Addendum for HP Link Editor/iX, P/N 32650-90476 <+C><:I0,0,0,0><:#283,8280><:f240,BArial MT,> <+C><:I0,0,0,0><:f240,BArial MT,>Trap Handling Programmer's Guide P/N 32650-90026 Dec 1988 <+C><:I0,0,0,0><:f240,BArial MT,>Using the Hierarchical File System <:f> <+C><:I0,0,0,0><:f220,BArial MT,> <+C><:f240,BArial MT,><+#><+!>Business BASIC/iX:<-!><-#><:f> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:I0,0,0,0><:#566,8280><:f240,BArial MT,>HP Business BASIC/iX Reference <:f><:f240,BArial MT,>P/N 32715-60001 Oct 1989 <:f><:f240,BArial MT,>Manual <+C><:s><:I0,0,0,0><:#283,8280><:f240,BArial MT,> <+C><:I0,0,0,0><:#849,8280><:f240,BArial MT,>Programming in HP Business BASIC/iX, a documentation file provided with the HP Business BASIC/iX product on the subsys tape, currently named Z00Z715A.HP32715.CLL <+C><:#283,8280><:f240,BArial MT,><+#><+!> <+C><+!><+#><:f240,BArial MT,>C/iX:<-!><-#><:f> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#566,8280><:f240,BArial MT,>HP C/iX Reference Manual (part number 31506-90005), June 1992. Chapter 9: describes data representation and alignment. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#566,8280><:f240,BArial MT,>HP C Programmer's Guide (part number 92434-90002), August 1992. Chapter 2: discusses data type alignment on various architectures. <+C><:#566,8280><:f240,BArial MT,>Chapter 3: describes how to call other languages and discusses a number of <:f><:f240,BArial MT,>issues with calls to Pascal and FORTRAN. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#283,8280><:f240,BArial MT,><+#><+!><++>Cobol II<-+>/iX:<-!><:f><-#> <+C><:s><:#283,8280><+#><:f240,BArial MT,> <+C><:I0,0,0,0><:#849,8280><:f240,BArial MT,>HP COBOL II/XL Reference Manual <:f><:f240,BArial MT,> P/N 31500-90001 Jul 1991 Chapter 7: describes data representation. See especially the description of the SYNCHRONIZED clause <+C><:I0,0,0,0><:#283,8280><:f240,BArial MT,> and the USAGE clause. <+C><:I0,0,0,0><:#566,8280><:f240,BArial MT,>Chapter 11: documents the mechanics of procedure calls. Appendix B: describes the various compiler options. <+C><:I0,0,0,0><:#1132,8280><:f240,BArial MT,>Appendix H: contains much useful information for the Cobol programmer making calls to and from other languages. See especially the discussion of the <:f><:f240,BArial MT,>Cobol trap mechanism. <+C><:s><:I0,0,0,0><:#283,8280><:f240,BArial MT,> <+C><:I0,0,0,0><:#566,8280><:f240,BArial MT,>HP COBOL II/XL Programmer's Guide P/N 31500-90002 Jul 1991 Chapter 4: contains vital information about calling <+C><:I0,0,0,0><:#566,8280><:f240,BArial MT,> sub-programs, including a discussion on calling non-Cobol subprograms, with examples in C, Fortran, and PASCAL. <+C><:s><:I0,0,0,0><:#283,8280><:f240,BArial MT,> <+C><:f240,BArial MT,><+#><+!>Fortran 77/iX<-!><-#> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#566,8280><:f240,BArial MT,>HP Fortran 77/iX Reference Manual P/N 31501-90010 Jun 1992 Chapter 8: Interfacing with Non-Fortran Subprograms <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#566,8280><:f240,BArial MT,>HP Fortran 77/iX Programmer's Guide P/N 31501-90011 Jun 1992 Chapter 8: Interfacing with Other Languages <+C><:#283,8280><:f240,BArial MT,><+#><+!> <+C><:#283,8280><+!><+#><:f240,BArial MT,>P<+,>ASCAL<-,>/iX:<-!><-#> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#283,8280><:f240,BArial MT,>HP Pascal/iX Reference Manual P/N 31502-90001 Jun 1992 <+C><:#283,8280><:f240,BArial MT,> <+C><:#566,8280><:f240,BArial MT,>HP Pascal/iX Programmer's Guide P/N 31502-90002 Jun 1992 Chapter 9: External Routines <+C><:#283,8280><:f240,BArial MT,>Chapter 10: Intrinsics <+C><:s><:#283,8280><:f240,BArial MT,> <+C><-!><-#><+!><+#><:f240,BArial MT,>RPG/iX:<-!><-#> <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:#849,8280><:f240,BArial MT,>HP RPG/iX Reference Manual P/N 30318-90003 Nov 1993 Chapter 8: Calculation Specifications. Examples for PARM, RLABL operators. <+C><:#283,8280><:f240,BArial MT,> <+C><:#566,8280><:f240,BArial MT,>HP RPG/XL Programmers Guide P/N 30318-90001 Dec 1988 Chapter 5: <:f><:f240,BArial MT,>Processing Data in an RPG Program. <+C><:s><:#283,8280><:f240,BArial MT,> <+C><:s><:#283,8280><:f240,BArial MT,><+#><+!>Transact:<-!><-#> <+C><:s><:#283,8280><:f240,BArial MT,> <:#283,8280><:f240,BArial MT,>HP TRANSACT Reference Manual P/N 32247-60003 Apr 1994 <:s><:#283,8280><:f240,BArial MT,> <:#288,8280> > [Embedded] 00061689