: Here is some sample code... but I get an error and it's been too long since I've delt with records to figure what I'm doing wrong.
:
:
: Type
: ..rooms = Record
: ....name : String[20];
: ....descpt1, descpt2 : String;
: ..end;
:
: Var
: ..fname : file;
:
: Begin
: ..assign(fname, 'rooms.dat');
: ..readln(rooms.name); <---- This is were I get my error, it says it is expecting a '(' after the word 'rooms'. I'm attempting to read input to store into rooms.name... what's going on here?? What am I missing?
: end;
:
:
: Any help will be appreciated... thanks!
:
: Mr. El Moe
:
Your problem is that you've declared a type called rooms, but you've not
declared a variable based on that type.
Pascal works with variables only.
TYPE Rooms = RECORD
Name, Descrpt1, Descrpt2 : STRING;
END; { of type declaration}
Now you should declare variable based on that type :
VAR MyRoom : Rooms;
BEGIN
Assign(FName, 'rooms.DAT');
Reset(FName);
ReadLN(FName, MyRoom);
{reads the entire record from file}
END.