HP SunSoft Pascal 4.0 Manual de usuario Pagina 120

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 333
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 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 }
Vista de pagina 119
1 2 ... 115 116 117 118 119 120 121 122 123 124 125 ... 332 333

Comentarios a estos manuales

Sin comentarios