Sun Microsystems SunSoft Pascal 4.0 User Manual page 120

Hewlett-packard user guide printer printer
Table of Contents

Advertisement

6
The commands to compile and
execute SimVar.p and
SimVarMain.c
The Pascal procedure,
StrVar.p
96
hostname% pc -c SimVar.p
hostname% cc SimVar.o SimVarMain.c
hostname% a.out
00000001 00000000 z 9 9 9.9 9.9
Simple Types with –xl
With the -xl option, the Pascal real must be paired with a C float, and the
Pascal integer must be paired with a C short int.
Strings of Characters
The C counterpart to the Pascal alfa and string types are arrays; C passes
all arrays by reference. The C counterpart to the Pascal varying is a structure;
C passes structures by value.
Before you call Pascal with a null varying string, set the byte count to zero
because that is what Pascal assumes about such strings.
C can pass a structure consisting of a four-byte integer and an array of
characters to a Pascal procedure, expecting a var parameter that is a variable-
length string.
See the following example:
type
TVarStr = varying [25] of char;
procedure StrVar(
var a: alfa;
var s: string;
var v: TVarStr);
begin
a := 'abcdefghi' + chr(0);
s := 'abcdefghijklmnopqrstuvwxyz' + chr(0);
v := 'varstr' + chr(0);
end;
{ StrVar }
Pascal 4.0 User's Guide

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the SunSoft Pascal 4.0 and is the answer not in the manual?

Questions and answers

Table of Contents