Jump to page titleUNITED STATES
hp.com home products and services support and drivers solutions how to buy
» contact hp

:

more options
 

hp.com home
End of Jump to page title
Example-PL/I, PASCAL How To Pass A Descriptor To PASCAL From PL/I
Jump to content



» 

business support center

Home & Home Office Support:
» HP branded products
» Presario branded products
» Services & Warranties
Small & Medium Business Support:
» Small & Medium Business products
» Small & Medium Business services
Support for IT Professionals:
» Enterprise products (IT Resource Center)
» NonStop enterprise products
» Business & IT Services
Content starts here
Copyright (c) Digital Equipment Corporation 1987. All rights reserved
DATE: 23-Jan-1987


OVERVIEW:

This article describes how to send a descriptor from a PL/I program to a
PASCAL program.  It is essential that the descriptor in both programs
is the same number of bytes long.  This article contains approximately 90
lines.

CAUTION:  This sample program has been tested using PL/I, V2.4 and PASCAL,
V3.4 on VAX/VMS, V4.5.  However, we cannot guarantee its effectiveness
because of the possibility of error in transmitting or implementing it.
It is meant to be used as a template for writing your own program, and
it may require modification for use on your system.


PROGRAMS:

pl1_calling_pascal:  procedure options(main);
/*
   This program will call a PASCAL subroutine and pass several types of
        parameters to the PASCAL subroutine.  This program in particular
        will demonstrate the passing of a character literal.
*/
declare pascal_routine external entry (
                any);

declare 1 DESC_BLOCK,
          2  db_length  fixed bin (15),
          2  db_type    fixed bin (7) initial (14),
          2  db_class   fixed bin (7) initial (2),
          2  db_addr union,
             3  db_int_addr     fixed bin (31),
             3  db_address      pointer;
declare 1 address_block union,
          2  add1               pointer,
          2  add2               fixed bin (31);

declare  string_to_pass character (10) initial ('abcdefghij');

    address_block.add1 = addr (DESC_BLOCK);
    DESC_BLOCK.db_length = length (string_to_pass);
    DESC_BLOCK.db_address = addr (string_to_pass);

    call pascal_routine (DESC_BLOCK);

    put skip list ( 'After call to the PASCAL routine.');

end pl1_calling_pascal;


MODULE PAS_ROUT (input, output);
{This module is called by the above PL/I program and receives a descriptor
from the program.  It uses the address of a string and the length of the
string to print the string.}

type
     WORDD = [word] -32767..32767;
     BYTEE = [byte] -128..127;
     LINE = packed array[1..65535] of char; {establish the line buffer}
     LINE_PTR = ^LINE;                     {create a pointer to the buffer}
     DESCRIPTOR_TYPE = packed record       {define the descriptor}
          LENGTH  :wordd;
          DTYPE   :bytee;
          CLASS   :bytee;
          ADDRESS :line_ptr;
     end;  {record DESCRIPTOR_TYPE}

[global] PROCEDURE PASCAL_ROUTINE ( var DESCRIPTOR: DESCRIPTOR_TYPE);
var
     MY_LINE: line_ptr;
begin
     writeln ('In the PASCAL subroutine.');
     writeln ('The length of the string is ', DESCRIPTOR.LENGTH);
     MY_LINE := DESCRIPTOR.ADDRESS;
     writeln ('The string passed was: ',MY_LINE^:DESCRIPTOR.LENGTH);
     writeln ('Exiting the PASCAL subroutine!!');
end; {procedure sub_from_pl1}

END.  {module}




buy online or call 1.800.AT.COMPAQ
privacy statementusing this site means you accept its terms