2
database : array [1..3] of string = ('QA.db','Level.db','Highscore.db');
type QA = record
Question : string[255];
Options : array['A'..'D'] of string[255];
Answer : char;
end;
type level = record
money: longint;
safe: boolean;
end;
type score = record
name : string[255];
reward : longint;
end;
var
f1:file of QA;
ftemp1: QA;
f2 : file of level;
ftemp2: level;
f3 : file of score;
ftemp3: score;
//Database Operation
procedure print, change, etc.
begin reset(f1); ....; write(f,ftemp); close(f1); end; etc.
我这里有问题,我应该申报为每一个数据库2个不同的变量,整个数据库的程序操作。
我想用动态的变量,以简化我的代码,例如
更改记录类型的动态可变文件帕斯卡
var
f:file of VAR;
ftemp: VAR;
procedure Add;
begin
reset(f);
....
write(f,ftemp);
close(f);
end;
begin
VAR:QA;
Add;
VAR:level;
Change;
end;
有了这个代码,我只能宣布对所有数据库中的一个数据库操作,我怎么能这样做呢?我正在使用lazarus IDE。
[BlockRead](http://www.freepascal.org/docs-html/rtl/system/blockread.html ),[BlockWrite](http://www.freepascal.org/docs-html/rtl/system/blockwrite.html),[untyped files](http://wiki.freepascal.org/File#Untyped_binary) – Abelisto
你想给我一个例子吗?我不明白有无类型或类型的文件,内存之间的关系是什么? – Newbie123
如何将非类型化文件传递给过程或函数? @Abelisto – Newbie123