home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff339.lzh / PCQ / Examples / Structures.p < prev    next >
Text File  |  1990-03-19  |  2KB  |  56 lines

  1. program test;
  2.  
  3. {
  4.     This is the most ridiculous jumble of records, arrays and strings
  5. I could keep track of.  If this works, all the addressing stuff must work.
  6. This is the test that the 1.0b compiler failed, which prompted me to re-
  7. write the Selector() routine.
  8. }
  9.  
  10. {$I ":Include/StringLib.i"}
  11.  
  12. type
  13.     BigArray = Array [5..63] of String;
  14.     BigRecord= Record
  15.            First : Integer;
  16.            Second : String;
  17.            Third  : BigArray;
  18.         end;
  19.     BigPtr = ^BigRecord;
  20.     SmallArray = Array [-4..16] of BigPtr;
  21.  
  22. var
  23.     s : SmallArray;
  24.     i : Short;
  25.     s1 : String;
  26.     s2 : Array [1..4] of String;
  27. begin
  28.     new(s[-2]);
  29.     s[-2]^.Second := AllocString(80);
  30.     s[-2]^.Third[11] := AllocString(80);
  31.     write('Enter String 1 : ');
  32.     ReadLn(s[-2]^.Second);
  33.     write('Enter String 2 : ');
  34.     ReadLn(s[-2]^.Third[11]);
  35.     writeln(s[-2]^.Second);
  36.     writeln(s[-2]^.Third[11]);
  37.     i := 0;
  38.     while s[-2]^.Second[i] <> Chr(0) do begin
  39.     write(s[-2]^.Second[i]);
  40.     i := Succ(i);
  41.     end;
  42.     writeln;
  43.     i := 0;
  44.     while s[-2]^.Third[11][i] <> Chr(0) do begin
  45.     write(s[-2]^.Third[11][i]);
  46.     i := Succ(i);
  47.     end;
  48.     writeln;
  49.     writeln('Adr s[-2]^.Second is    ', Integer(Adr(s[-2]^.Second)));
  50.     writeln('Adr s[-2]^.Second[2] is ', Integer(Adr(s[-2]^.Second[2])));
  51.     writeln('Adr s[-2]^.Second^ is   ', Integer(Adr(s[-2]^.Second^)));
  52.     writeln('Adr s[-2]^.Third[11] is ', Integer(Adr(s[-2]^.Third[11])));
  53.     writeln('Adr s[-2]^.Third[11][2] ', Integer(Adr(s[-2]^.Third[11][2])));
  54.     writeln('Adr s[-2]^.Third[11]^   ', Integer(Adr(s[-2]^.Third[11]^)));
  55. end.
  56.