HP 3000 Manuals

Extensions to ANSI/IEEE and ISO Pascal [ HP Pascal/iX Reference Manual ] MPE/iX 5.0 Documentation


HP Pascal/iX Reference Manual

Extensions to ANSI/IEEE and ISO Pascal 

This section describes HP Pascal features that are extensions of
ANSI/IEEE 770 X3.97-1983 and ISO 7185-1983 Pascal.  For the full
description of a feature, refer to the appropriate keyword or topic in
this manual.

Type Compatibility 


NOTE In the ISO 7185-1983 or ANSI/IEEE 770 X3.97-1983 standards for Pascal, the term "string" refers to any PACKED ARRAY of CHAR with a starting index of 1. HP Pascal, however, supports the standard type string. To avoid confusion, the term PAC is used for the type PACKED ARRAY [1..n] of CHAR with a starting index of 1.
Pascal defines a set of compatibility requirements for the operands of each operator, based both on the operator itself and the types of its operands, and a set of assignment compatibility rules. HP Pascal extends the operator and assignment compatibility rules as follows: * If T1 and T2 are PAC variables or string literals they are compatible. The shorter is padded with blanks for comparison. * If T1 is a PAC variable and T2 is a string literal or PAC variable, then T2 is assignment compatible with T1 provided that T2 is shorter than or equal to T1. If T2 is shorter than T1, T2 is padded with blanks. CASE Statement. In a CASE statement, the reserved word OTHERWISE may precede a list of statements and the reserved word END. If the case selector evaluates to a value not specified in the case constant list, the system executes the statements between OTHERWISE and END. OTHERWISE must follow the last case constant. Also, subranges may appear as case constants. Compiler Options. Compiler options appear between dollar signs ($). HP Pascal has two categories of compiler options: system-independent and system-dependent compiler options. The system-independent category of compiler options are further distinguished by the following categories: HP Standard Options, HP Pascal Options, and System Programming Options. The system-dependent either work on only one operating system, or work differently on HP-UX and MPE/iX. HP Pascal options are not required by the HP Standard, but are available in HP Pascal. An HP Pascal program containing HP Pascal options must be compiled by the HP Pascal compiler. System-Independent Compiler Options: HP Pascal Options MLIBRARY ALIAS NOTES ALIGNMENT OPTIMIZE ARG_RELOCATION OS ASSERT_HALT OVFLCHECK ASSUME PAGEWIDTH BUILDINT POP CHECK_ACTUAL_PARM PUSH CHECK_FORMAL_PARM S300_EXTNAMES CODE SEARCH CODE_OFFSETS SET COPYRIGHT SKIP_TEXT COPYRIGHT_DATE SPLINTR ELSE STATEMENT_NUMBER ENDIF STDPASCAL_WARN EXTERNAL STRINGTEMPLIMIT EXTNADDR SUBPROGRAM GLOBAL SYSINTR HEAP_COMPACT SYSPROG HEAP_DISPOSE TABLES IF TITLE INLINE TYPE_COERCION INTR_NAME UPPERCASE KEEPASMB VERSION LIST_CODE VOLATILE LISTINTR WARN LITERAL_ALIAS WIDTH LOCALITY XREF LONG_CALLS MAPINFO Table 1-0. (cont.) HP Standard Options System Programming Options ANSI EXTNADDR LINES TYPE_COERCION LIST PAGE PARTIAL_EVAL RANGE STANDARD_LEVEL System-Dependent Compiler Options: MPE/iX Only MPE/iX and HP-UX HP-UX Only CALL_PRIVILEGE INCLUDE CONVERT_MPE_NAMES[REV BEG] EXEC_PRIVILEGE INCLUDE_SEARCH GPROF FONT NLS_SOURCE HP_DESTINATION HP3000_16 SYMDEBUG SHLIB_CODE[REV END] HP3000_32 SHLIB_VERSION RLFILE RLINIT Refer to Chapter 12 for details about these options. Conformant Array Parameters. The ISO Level 1 Conformant Array Parameter feature is implemented in HP Standard Pascal. This is the only feature in ISO Pascal that is not in ANSI/IEEE Pascal. This feature allows the user to pass an array as a parameter, whose bounds are determined at run time and which conforms to the conformant array parameter specification. The specification includes the names of the array bounds. The values of the bounds of the actual array are given when it is passed. Constant Expressions. The value of a declared constant may be specified with a constant expression. A constant expression returns an ordinal or real value and can contain only declared constants, literals, calls to the functions ord, chr, pred, succ, hex, octal, binary, strlen, odd, and the operators +, -, *, DIV, and MOD. Note that a constant expression can appear anywhere that a constant can appear. Constructors (Structured Constants). The value of a declared constant can be specified with a constructor. A constructor establishes values for the components of a previously declared structured type. Constructors can only appear in a CONST section of a declaration part of a block. Set constructors can appear either in a CONST section or in expressions in executable statements. Declaration Part. In the declaration part of a block, CONST, TYPE, VAR, MODULE, and IMPORT sections can be repeated and intermixed. Halt Procedure. The halt procedure causes an abnormal termination of a program. Heap Procedures. The procedure mark saves the allocation state of the heap. The procedure release restores the allocation state of the heap to a state previously marked. This has the effect of deallocating all storage allocated by the procedure new since the time mark was called. Identifiers. The underscore character (_) can appear in identifiers, but not as the first character. File Input/Output. A file can be opened for direct access with the procedure open. Direct access files have a maximum number of components indicated by the function maxpos and have a current number of written components, indicated by the function lastpos. The procedure seek places the current position of a direct access file at a specified component. Data can be read from a direct access file or written to it with the procedures readdir or writedir that are combinations of seek and the standard procedures read or write. A textfile cannot be used as a direct access file. A file can be opened in the "write-only" state without altering its contents by using the procedure append. The current position is set to the end of the file. Any file can be explicitly closed with the procedure close. To permit interactive input, the system defines the primitive file operation get as "deferred get." Refer to get in Chapter 10 for more information. The procedure read accepts any ordinal type as input from text files. Therefore, it is possible to read a Boolean or enumerated value from a text file. It is also possible to read a value that is of type PAC or string. The procedure write writes expressions to a text file. Any ordinal type can be a parameter. An enumerated constant can be written directly to a text file. Write also writes expressions of type string or PAC. The function position returns the index of the current position for any file that is not a textfile. The routines page, overprint, prompt, and linepos operate on textfiles. The following lists what each routine does: * Linepos returns the integer number of characters that the program has read from or written to a textfile since the last end-of-line marker. * Page causes a page eject when a text file is printed. * Overprint causes the printer to perform a carriage return without a line feed, effectively overprinting a line. * Prompt displays the output buffer without writing a line marker. This allows the cursor to remain on the same screen line when output is directed to a terminal. The routine associate allows Pascal input/output operations on files that have been opened by the operating system. The routine disassociate disallows these operations. Function Return. A function can return any structured type, except those containing files. That is, a function may return an array, record, set, or string. Longreal Numbers. The type longreal is identical to the type real except that it provides greater precision. The letter "L" precedes the scale factor in a longreal literal. Minint. The standard constant minint is defined in HP Pascal. The value is implementation dependent. The type integer is defined as a subrange minint...maxint. Minint is less than or equal to maxint. Formal Parameter Congruency. Two formal parameter lists are congruent if they contain an equal number of parameters and each parameter in one list is equivalent to the parameter in the same position in the other list. The formal parameter lists do not need to be syntactically the same. Record Variant Declaration. The variant part of a record field list may have a subrange as a case constant and need not specify all the case constants for the tag type. String or Character Literals. HP Pascal permits the encoding of control characters or any other single ASCII character after the sharp symbol (#). For example, the string literal #G represents CTRL-G (or the bell). A character can also be encoded by specifying its ASCII ordinal value (0..255) after the sharp symbol. For example, #7 represents CTRL-G. These characters can be included in string literals by directly appending them in front of or behind a string literal. String Type. HP Pascal supports the predefined type string. A string type is a PACKED ARRAY of CHAR with a declared maximum length and an actual length that may vary at run time. All HP Pascal implementations have maximum lengths of at least 255 characters. A variable of type string can be compared with a similar variable or a string literal or can be assigned to a variable of type string. A string literal can be assigned to a variable of type string. The following standard procedures and functions manipulate strings: * Setstrlen sets the current length of a string without changing its contents. * Str returns a specified portion of a string, such as a substring. * Strappend appends one string to another. * Strdelete deletes a specified number of characters from a string. * Strinsert inserts one string into another. * Strlen returns the current length of a string. * Strltrim and strrtrim trim leading and trailing blanks, respectively, from a string. * Strmax returns the maximum length of a string. * Strmove copies a substring from a source string to a destination string. * Strpos returns the position of the first occurrence of a specified string within another string. * Strread reads one or more values from a string. * Strrpt returns a string composed of a designated string repeated a specified number of times. * Strwrite writes one or more values to a string. WITH Statement. The record designator in a WITH statement can be a call to a function that returns a record as its result, or a structured constant. Numeric Conversion Functions. The functions binary, octal, and hex convert a parameter of type string or PAC, or a string literal, to an integer. These functions interpret the parameter the following ways: * Binary interprets the parameter as a binary value. * Octal interprets the parameter as an octal value. * Hex interprets the parameter as a hexadecimal value. Modules. HP Pascal supports separately compiled program fragments called modules. Modules can be used to satisfy the unresolved references of another program or module. Typically, a module "exports" types, constants, variables, procedures, and functions. A program can then "import" a module to satisfy its own references. This mechanism allows commonly used procedures and functions to be compiled separately and used by more than one program without having to include them in each program.


MPE/iX 5.0 Documentation