HP OpenVMS Systems Documentation |
HP Pascal for OpenVMS
|
Previous | Contents | Index |
This chapter describes some Pascal-specific assistance provided in the set of Hewlett-Packard CASE tools. For general information on each tool, see the documentation for the tool.
This chapter provides information on:
In general, the debugger supports the data types and operators of HP Pascal and the other debugger-supported languages. However, there are important language-specific limitations. (To get information on the supported data types and operators of any of the languages, enter the HELP LANGUAGE command at the DBG> prompt.)
In general, you can examine, evaluate, and deposit into variables, record fields, and array components. An exception to this occurs under the following circumstances: if a variable is not referenced in a program, the HP Pascal compiler may not allocate the variable. If the variable is not allocated and you try to examine it or deposit into it, you will receive an error message.
When depositing data into variables, the debugger truncates the high-order bits if the value being deposited is larger than the variable; it fills the high-order bits with zeros if the value being deposited is smaller than the variable. If the deposit violates the rules of assignment compatibility, the debugger displays an informational message.
Automatic variables (within any active block) can be examined and can have values deposited into them; however, since automatic variables are allocated in stack storage and are contained in registers, their values are considered undefined until the variables are initialized or assigned a value. For example:
DBG> EXAMINE X MAINP\X: 2147287308 |
In this example, the value of variable X should be considered undefined until after a value has been assigned to X.
In addition, you may examine a VARYING OF CHAR string, but it is not possible to examine the LENGTH field. For example, the following is not supported:
DBG> EXAMINE VARY_STRING.LENGTH |
Because the current LENGTH of a VARYING string is the first word, you should do the following to examine the LENGTH:
DBG> EXAMINE/WORD VARY_STRING |
It should also be noted that the type cast operator (::) is not permitted when evaluating HP Pascal expressions.
Pointers to undiscriminated schema cannot be correctly described to the debugger at this time since the type of the pointer is dependent upon the value pointed to by the pointer. They are described as pointers to UNSIGNED integers. For example,
TYPE S(I:INTEGER) = ARRAY [1..I] OF INTEGER; VAR P : ^S; BEGIN NEW(P,expression); END; |
This section describes HP Pascal specific information for the following Language-Sensitive Editor/Source Code Analyzer (LSE/SCA) features:
LSE accepts keywords, or tokens, for all languages with LSE support, but the specific tokens themselves are language-defined. For example, you can expand the %INCLUDE token only when using HP Pascal.
Likewise, LSE provides placeholders, or prompt markers, for all languages with LSE support, but the specific text or choices these markers call for are language-defined. For example, you see the %{environ_name_string}% placeholder only when using HP Pascal.
Some HP Pascal keywords, like TYPE, VAR, IF, and FOR, can be placeholders as well as tokens. LSE supplies language constructs for these keywords when they appear on your screen as placeholders. You can also type the keywords into the buffer yourself, enter the EXPAND command, and see the same language constructs appear on your screen.
You can use the SHOW TOKEN and SHOW PLACEHOLDER commands to display a list of all HP Pascal tokens and placeholders, or a particular token or placeholder. For example:
LSE> SHOW TOKEN IF {lists the token IF} LSE> SHOW TOKEN {lists all tokens } |
To copy the listed information into a separate file, first enter the appropriate SHOW command to put the list into the $SHOW buffer. Then enter the following command:
LSE> GOTO BUFFER $SHOW LSE> SAVE FILE filename.filetype |
While all languages with LSE support provide placeholder processing, each language defines specific contexts in which placeholders can be accepted as valid program code. HP Pascal defines contexts for declaration section placeholders and executable section placeholders. Table 4-1 lists the valid contexts within an HP Pascal declaration section where you can insert placeholders.
Can Replace | Cannot Replace |
---|---|
PROGRAM or
MODULE identifier |
Directive |
Program parameter | Attribute |
Identifier | Declaration-begin reserved word |
Data type | Complete declaration |
Value | |
Complete variant within the variant part of record |
Table 4-2 lists valid contexts within an HP Pascal executable section where you can insert placeholders.
Can Replace | Cannot Replace |
---|---|
Statement | LABEL identifier |
Variable | TO|DOWNTO within a FOR statement |
Expression | |
Case label | |
Complete case expression | |
Iteration variable within a
FOR statement |
HP Pascal support for placeholder and design comment processing includes the following language-specific stipulations:
Example 4-1 shows how you can use LSE tokens and placeholders to create a FOR statement within an HP Pascal program. The callout numbers identify the steps in this process, which are detailed in the notes appearing after the example.
Example 4-1 Using LSE to Create a FOR Statement |
---|
BEGIN (1) %[statement_list]%... END. . . . BEGIN (2) FOR %{control_var}% %{iteration_clause}% DO %{statement}%; %[statement_list]%... END. . . . BEGIN FOR INDEX := 1 TO MAX DO (3) %{statement}%; %[statement_list]%... END. . . . BEGIN FOR INDEX := 1 TO MAX DO (4) %{variable | func_id}% := %{value_expr}%; %[statement_list]%... END. . . . BEGIN (5) FOR INDEX := 1 TO MAX DO ARR[INDEX] := 0; %[statement_list]%... END. |
Example 4-2 shows some contexts in which LSE placeholders and design comments might appear in the design of an HP Pascal program. Placeholder contexts are self-explanatory; the callout numbers identify types of comments, which are detailed in the notes following the example.
Example 4-2 Using LSE Comments in Program Design ( OpenVMS VAX systems) |
---|
PROGRAM Semester_Grades ( input,output ) ; (1) { Author : P. Knox } { Creation Date : 03/03/89 } { Functional Description : This program calculates the numerical semester grade and determines the corresponding alphabetic grade for each student in a class. } { Nonlocal References : None } { Included Files : None } { Keywords : Grade array procedures, semester grade file } CONST «number of students» = %{compile_time_exp}%; «number of semester grades» = %{compile_time_exp}%; TYPE «grade array» = ARRAY [ 1..«number of semester grades»] OF «integer or real? determine later»; «grade range» = 0 .. 100; (2) VAR A_Grade_Array : «grade array» ; { var for array of grades } A_Grade : «grade range» ; { var for individual grade } Total : «grade range» ; { var for semester grade } %{variable}% : INTEGER; { control var, FOR loops } PROCEDURE «compute semester grade» ( VAR Grd_Arry : «grade array» ; VAR Sum : «grade range» ) ; (3) { Parameters : Grd_Arry : value parameter, array of semester grades for one student: Sum : variable parameter, returns the semester grade } BEGIN FOR %{control_var}% %{iteration_clause}% DO «sum the grades in Grd_Arry» «Sum gets Sum divided by number of grades in array» «write student's semester grade» END; PROCEDURE «assign letter grade» ( Semester_Grade : «grade range» ) ; BEGIN CASE %{case_selector}% OF %{case_labels}%... : %{statement}%; %{case_labels}%... : %{statement}%; %{case_labels}%... : %{statement}%; %{case_labels}%... : %{statement}% OTHERWISE %{statement_list}%... END END; BEGIN FOR «number of students» DO BEGIN «enter semester grades for student» ; FOR %{control_var}% := %{value_expr}% TO «number of semester grades» DO BEGIN «read grades and load into array» END; Total := 0; «compute routine» ( Grade_Array, Total ); «assign_letter routine» ( Total ) END END. |
The Oracle CDD/Repository (CDD/Repository) must be purchased separately. The CDD/Repository allows language-independent structure declarations that can be shared by many OpenVMS layered products. HP Pascal support of the CDD/Repository allows HP Pascal programmers to share common record and data definitions with other Hewlett-Packard languages and data management products.
A system manager or data administrator creates the CDD/Repository's directory hierarchies, history lists, and access control lists with the Dictionary Management Utility (DMU). Once record paths are established, you can enter data definitions into and extract them from the CDD/Repository.
To enter data definitions into the CDD/Repository, you first create CDD/Repository source files written in the Common Data Dictionary Language (CDDL). The CDDL compiler converts the definitions to an internal form---making them independent of the language used to access them.
To extract data definitions from the CDD/Repository, include the %DICTIONARY directive in your HP Pascal source program. If the data attributes of the data definitions are consistent with HP Pascal requirements, the data definitions are included in the HP Pascal program during compilation.
The %DICTIONARY directive incorporates CDD/Repository data definitions into the current HP Pascal source file during compilation.
This directive can appear only in the TYPE section of an HP Pascal program, not in the executable section. For example:
PROGRAM SAMPLE1; TYPE %DICTIONARY 'Pascal_SALESMAN_RECORD/LIST' . . . |
A /LIST option in the %DICTIONARY directive (or the /SHOW= DICTIONARY qualifier on the Pascal command line) includes the translated record in the program's listing. For example:
TYPE %DICTIONARY 'PASCAL_SALESMAN_RECORD/LIST' { CDD Path Name => PASCAL_SALESMAN_RECORD } PAYROLL_RECORD = PACKED RECORD SALESMAN : PACKED RECORD NAME : PACKED ARRAY [1..30] OF CHAR; ADDRESS : PACKED ARRAY [1..40] OF CHAR; SALESMAN_ID : [BYTE(5)] RECORD END; { numeric string, unsigned } END; { record salesman } END; { record payroll_record } |
The option (/LIST or /NOLIST) overrides the qualifier
(/SHOW=NODICTIONARY or /SHOW=DICTIONARY).
The CDD/Repository supports some data types that are not native to HP Pascal. If a data definition contains a field declared with an unsupported data type, HP Pascal replaces the field with one declared as a [BYTE(n)] RECORD END, where n is the appropriate length in bytes. By making the data addressable in this way, you are able to manipulate the data either by passing it to external routines as variables or by using the HP Pascal type casting capabilities to perform an assignment.
However, because these empty records do not have fields, the size of the record is 0 bits. They should not be used in expressions or passed to formal value parameters. Recall that a size attribute used on a type definition has no effect on fetches. When fetching from these records, the compiler will fetch the actual size of the record, 0 bits.
Table 4-3 summarizes the mapping between CDDL data types and the corresponding HP Pascal data types.
CDDL Data Type | HP Pascal Data Type |
---|---|
Unspecified | [BYTE(n)] RECORD END |
Byte logical | [BYTE] 0..255 |
Word logical | [WORD] 0..65535 |
Longword logical | UNSIGNED |
Quadword logical | [BYTE(8)] RECORD END |
Octaword logical | [BYTE(16)] RECORD END |
Byte integer | [BYTE] --128..127 |
Word integer | [WORD] --32768..32767 |
Longword integer | INTEGER |
Quadword integer | [BYTE(8)] RECORD END |
Octaword integer | [BYTE(16)] RECORD END |
F_floating | SINGLE |
D_floating | DOUBLE (/NOG_FLOATING) |
G_floating | DOUBLE (/G_FLOATING) |
H_floating (OpenVMS VAX systems) | QUADRUPLE |
F_floating complex | [BYTE (8)] RECORD END |
D_floating complex | [BYTE(16)] RECORD END |
G_floating complex | [BYTE(16)] RECORD END |
H_floating complex | [BYTE(32)] RECORD END |
Text | PACKED ARRAY [l..u] OF CHAR |
Varying text | VARYING [u] OF CHAR |
Numeric string,
unsigned |
[BYTE(n)] RECORD END |
Numeric string,
left separate |
[BYTE(n)] RECORD END |
Numeric string,
left overpunch |
[BYTE(n)] RECORD END |
Numeric string,
right separate |
[BYTE(n)] RECORD END |
Numeric string,
right overpunch |
[BYTE(n)] RECORD END |
Numeric string,
zoned sign |
[BYTE(n)] RECORD END |
Bit |
[BIT(n)] 0..((2
n)--1) or
[BIT(32)]UNSIGNED or [BIT(N)] RECORD END or ignored |
Bit unaligned |
[BIT(n), POS(x)] 0..((2
n)n--1) or
[BIT(32), POS(x)] UNSIGNED or [BIT(n), POS(x)] RECORD END or ignored |
Date and time
Date |
[BYTE(n)] RECORD END
[BYTE(n)] RECORD END |
Virtual field | Ignored |
Varying string | VARYING [u] OF CHAR |
Overlay | Variant record |
Pointer | Pointer type |
In Example 4-3, the %DICTIONARY directive is used to access the CDD/Repository record definition Mail_Order_Info. With this definition, the HP Pascal program Show_Keys performs ISAM file manipulation on an existing indexed file, CUSTOMERS.DAT. Assume that CUSTOMERS.DAT has the primary key Order_Num and a field name called Zip_Code.
Oracle CDD/Repository has no equivalent for the HP Pascal KEY attribute, which is required to create new indexed files. You can use Oracle CDD/Repository data definitions to open existing indexed files (as in this example) but not new indexed files. |
Example 4-3 Using%DICTIONARY to Access a Oracle CDD/Repository Record Definition |
---|
Program Show_Keys(OUTPUT); TYPE %DICTIONARY 'Mail_Order_Info/LIST' VAR Old_Customer_File : FILE OF Mail_Order; Order_Rec : Mail_Order; Continue : BOOLEAN; BEGIN OPEN( File_Variable := Old_Customer_File, File_Name := 'Customers.Dat', History := OLD, Organization := Indexed, Access_Method := Keyed ); FINDK(Old_Customer_File, 1, '1000', NXTEQL); Continue := TRUE; WHILE Continue and NOT UFB(Old_Customer_File) DO BEGIN READ(Old_Customer_File, Order_Rec); IF Order_Rec.Zip_Code < '5000' THEN WRITELN('Order number', Order_Rec.Order_Num, 'has zip code', Order_Rec.Zip_Code) ELSE Continue := False; END; END. |
During the compilation of Show_Keys, the record definition Mail_Order_Info is extracted from the CDD/Repository. Show_Keys prints the order number and zip code of each file component that has a zip code greater than or equal to 1000 but less than 5000.
Previous | Next | Contents | Index |