HP SunSoft Pascal 4.0 Uživatelský manuál Strana 200

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 333
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 199
176 Pascal 4.0 Users Guide
8
A Pascal record of an integer and a character string matches a FORTRAN
structure of the same. Consider these examples:
The Pascal procedure,
StruChr.p
type
lenstr =
record
nbytes: integer;
chrstr: array [0..25] of char
end;
procedure struchr_(var v: lenstr);
begin
v.chrstr := 'oyvay';
v.nbytes := 5
end; { struchr_ }
The FORTRAN main program,
StruChrmain.f
structure /VarLenStr/
integer nbytes
character a*25
end structure
record /VarLenStr/ vls
character s25*25
vls.nbytes = 0
Call StruChr( vls )
s25(1:5) = vls.a(1:vls.nbytes)
write ( *, 1 ) s25
1 format("s25='", A, "'" )
stop
end
The commands to compile and
execute Struchr.p and
StruChrmain.f
hostname% pc -c StruChr.p
hostname% f77 StruChr.o StruChrmain.f -lpfc -lpc
StruChrmain.f:
MAIN:
hostname% a.out
s25='oyvay'
Zobrazit stránku 199
1 2 ... 195 196 197 198 199 200 201 202 203 204 205 ... 332 333

Komentáře k této Příručce

Žádné komentáře