On UBUNTU 15.04 and Lazarus 1.6.
So when I try to compile GET or PUT error message is: "Identifier not found". Well of course not. Thgese are FPC statements. So why does'nt FPC know them?
ALSO:
The lazarus 1.6 FPC will not compile the following simple program. FPC gets stuck on the VAR statement "Student: StudentRecord;".
The error is: "Typed files cannot contain reference-counted types" (????????)
This program was obtained from Tutorials Point FILE HANDLING web page who claims it creates a students.dat file.
Thanks for any help you can give.
solsyst
Still working on this as of 5/26/16. Trying it out on my old MT86 Pascal compiler.
program DataFiles;
type
StudentRecord = Record
s_name: String;
s_addr: String;
s_batchcode: String;
end;
var
Student: StudentRecord; <==== Here is the problem.
f: file of StudentRecord;
begin
assign(f, 'students.dat');
reset(f);
while not eof(f) do
Loose the "String" type in type definition.
Replace it with Array of char, eg
TYPE
StudentRecord = Record
s_name: array [1..255] of char;
s_addr: array [1..255] of char;
s_batchcode: array [1..255] of char;
end;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So, the work around to the missing GET and PUT procedures in the Lazarus fpc compiler is nicely explained by the following statements from Wikipedia:
"Pascal files are sequences of components. Every file has a buffer variable which is denoted by f^. The procedures get (for reading) and put (for writing) move the buffer variable to the next element. Read is introduced such that read(f, x) is the same as x := f^; get(f);. Write is introduced such that write(f, x) is the same as f^ := x; put(f); The type text is predefined as file of char. While the buffer variable could be used for inspecting the next character to be used (check for a digit before reading an integer), this leads to serious problems with interactive programs in early implementations, but was solved later with the "lazy I/O" concept."
More on this later.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
On 5/26/16 used my old MT86 Pascal compiler on this simple create a file program. It runs under MS-DOS 3.3.
The program compiled and linked with no errors.
Next I'll try the FPC compiler using terminal commands.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
On UBUNTU 15.04 and Lazarus 1.6.
So when I try to compile GET or PUT error message is: "Identifier not found". Well of course not. Thgese are FPC statements. So why does'nt FPC know them?
ALSO:
The lazarus 1.6 FPC will not compile the following simple program. FPC gets stuck on the VAR statement "Student: StudentRecord;".
The error is: "Typed files cannot contain reference-counted types" (????????)
This program was obtained from Tutorials Point FILE HANDLING web page who claims it creates a students.dat file.
Thanks for any help you can give.
solsyst
Still working on this as of 5/26/16. Trying it out on my old MT86 Pascal compiler.
program DataFiles;
type
StudentRecord = Record
s_name: String;
s_addr: String;
s_batchcode: String;
end;
var
Student: StudentRecord; <==== Here is the problem.
f: file of StudentRecord;
begin
assign(f, 'students.dat');
reset(f);
while not eof(f) do
begin
read(f,Student);
writeln('Name: ',Student.s_name);
writeln('Address: ',Student.s_addr);
writeln('Batch Code: ', Student.s_batchcode);
end;
close(f);
end.
Last edit: solsyst 2016-05-26
Loose the "String" type in type definition.
Replace it with Array of char, eg
TYPE
StudentRecord = Record
s_name: array [1..255] of char;
s_addr: array [1..255] of char;
s_batchcode: array [1..255] of char;
end;
Thanks!
Works quite well.
Sooooo pleased to find helpful geeks out there.
CHEERS
Still working on the missing GET/PUT instruction question. Have found a workaround to the missing PUT problem.
So, the work around to the missing GET and PUT procedures in the Lazarus fpc compiler is nicely explained by the following statements from Wikipedia:
"Pascal files are sequences of components. Every file has a buffer variable which is denoted by f^. The procedures get (for reading) and put (for writing) move the buffer variable to the next element. Read is introduced such that read(f, x) is the same as x := f^; get(f);. Write is introduced such that write(f, x) is the same as f^ := x; put(f); The type text is predefined as file of char. While the buffer variable could be used for inspecting the next character to be used (check for a digit before reading an integer), this leads to serious problems with interactive programs in early implementations, but was solved later with the "lazy I/O" concept."
More on this later.
On 5/26/16 used my old MT86 Pascal compiler on this simple create a file program. It runs under MS-DOS 3.3.
The program compiled and linked with no errors.
Next I'll try the FPC compiler using terminal commands.