[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP Pascal for OpenVMS
User Manual


Previous Contents Index


Chapter 4
Programming Tools

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:

4.1 Debugger Support for HP Pascal

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;

4.2 Language-Sensitive Editor/Source Code Analyzer Support for HP Pascal

This section describes HP Pascal specific information for the following Language-Sensitive Editor/Source Code Analyzer (LSE/SCA) features:

  • Programming language placeholders and tokens
  • Placeholder processing
  • Design comment processing (OpenVMS VAX systems)

4.2.1 Programming Language Placeholders and Tokens

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

4.2.2 Placeholder and Design Comment Processing

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.

Table 4-1 Placeholders Within the Declaration Section
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.

Table 4-2 Placeholders Within the Executable Section
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:

  • Pseudocode placeholders are designated with double left- and right-angle brackets (<< >>) or the 8 bit format (« »).
  • The compiler produces an empty object file when it encounters pseudocode or LSE placeholders within a source program.
  • Comment processing is limited to the declaration section.

4.2.3 LSE and SCA Examples

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.

  1. As you begin the executable section of your program, the cursor rests on the placeholder %[statement_list]%. Type the token FOR over this placeholder and expand FOR.
  2. LSE provides the FOR statement template. Select a FOR variable option from the menu. Expand the %{iteration_clause}% placeholder and expand the %{statement}% placeholder.
  3. LSE displays a menu, from which you can select the %{simple_statement}% option. A further menu appears, from which you select the ASSIGNMENT statement option.
  4. LSE provides the assignment statement template. Type an appropriate identifer or value expression over each placeholder.
  5. The completed FOR statement appears in your buffer.

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.

  1. These comments, which could be placed at the beginning of the program, are tagged comments. The comment begins with a predefined term called a tag. The tag is followed by a tag terminator symbol (:) and free text.
  2. These comments, which do not contain tags, are called remark comments. A remark comment consists of free text.
  3. This structured comment contains both a tag (the identifier parameters) and subtags (the identifiers Grd_Arry and Sum). A tag terminator and a blank comment line separate the two subtags from each other.

4.3 Accessing CDD/Repository from HP Pascal

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).

For More Information:

  • On CDD/Repository (CDD/Repository CDO Reference Manual, Using CDD/Repository on VMS Systems, and CDD/Administrator User's Guide)
  • On the HP Pascal %DICTIONARY directive (HP Pascal for OpenVMS Language Reference Manual)

4.3.1 Equivalent HP Pascal and CDDL Data Types

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.

NOTE

Although this practice is discouraged, you can use both D_floating and G_floating data types in the same compilation unit; however, both types cannot be handled in the same expression. Not all processors support the G_floating and H_floating types.

Table 4-3 Equivalent CDD/Repository Language and 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

4.3.2 CDD/Repository Example

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.

Note

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