[Lazarus] reading FORTRAN-style input in Lazarus

Alexander Klenin klenin at gmail.com
Fri Aug 5 17:03:07 CEST 2011


On Sat, Aug 6, 2011 at 01:46, David M. Lawrence <dave at fuzzo.com> wrote:
> The variables are three-digit country code, seven-digit station code, four
> digit year, and 12 five-digit pressure measurements (-9999 means missing
> data).
>
> Last night I tried the record idea suggested by Klenin and couldn't get it
> to work.  I kept getting "can't read or write variables of this type"
> errors.  It may be because I could not figure out how to read the data as a
> file as a "type of TInputLine."

{$mode objfpc}
type
  TInputLine = packed record
    FCountryCode: array [1..3] of Char;
    FStationCode: array [1..7] of Char;
    FYear: array [1..4] of Char;
    FPressure: array [1..12, 1..5] of Char;
    FEoln: array [1..2] of Char;
  end;

var
  v: TInputLine;
  f: file of TInputLine;
begin
  AssignFile(f, 'input.txt'); Reset(f);
  while not Eof(f) do begin
    Read(f, v);
    Writeln(v.FCountryCode, '#', v.FPressure[12]);
  end;
end.

-- 
Alexander S. Klenin




More information about the Lazarus mailing list