HP SunSoft Pascal 4.0 Instrukcja Użytkownika Strona 120

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 333
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 119
96 Pascal 4.0 Users Guide
6
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:
The commands to compile and
execute SimVar.p and
SimVarMain.c
hostname% pc -c SimVar.p
hostname% cc SimVar.o SimVarMain.c
hostname% a.out
00000001 00000000 z 9 9 9.9 9.9
The Pascal procedure,
StrVar.p
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 }
Przeglądanie stron 119
1 2 ... 115 116 117 118 119 120 121 122 123 124 125 ... 332 333

Komentarze do niniejszej Instrukcji

Brak uwag