I'm currently having trouble with these errors and can't seem to get through them, I've attached below my errors as well as my code, thank you.
Errors:
Free Pascal Compiler version 2.6.4 [2014/02/26] for i386 Copyright (c) 1993-2014 by Florian Klaempfl and others Target OS: Darwin for i386 Compiling BasicReadWrite.pas BasicReadWrite.pas(22,30) Error: Incompatible types: got "personArray" expected "LongInt" BasicReadWrite.pas(25,8) Error: No default property available BasicReadWrite.pas(25,8) Fatal: Syntax error, ";" expected but "[" found Fatal: Compilation aborted Error: /usr/local/bin/ppc386 returned an error exitcode (normal if you did not specify a source file to be compiled)
program BasicReadWrite;
type
Person = record
name: String;
age: String; // Should this be an integer? Why/Why not?
end;
personArray = array of Person;
procedure WriteLinesToFile(var myFile: TextFile; const pe: Person);
begin
WriteLn(myFile, pe.age);
WriteLn(myFile, pe.name);
end;
procedure PrintRecords(const ArrayOfPersons: personArray; count: Integer);
var
p: Person;
begin
setLength(p, ArrayOfPersons);
for count:= 0 to high(ArrayOfPersons) do
begin
p[count] := WriteLinesToFile();
end;
end;
procedure ReadLinesFromFile(var myFile: TextFile);
var
p: Person;
number: Integer;
ArrayOfPersons: personArray;
begin
for number:= 0 to 20 do
begin
PrintRecords([number]);
end;
end;
procedure Main();
var
myFile: TextFile;
begin
AssignFile(myFile, 'mytestfile.dat');
ReWrite(myFile); // Use ReWrite to open a file for writing
WriteLinesToFile(myFile);
Close(myFile); // We need to close the file and re-open it, as Pascal
// will not let you Read and write from a file at the same time.
AssignFile(myFile, 'mytestfile.dat');
Reset(myFile); // Open the file for reading.
ReadLinesFromFile(myFile);
Close(myFile);
end;
begin
Main();
end.