我正在尝试编写一个创建和更新库存的过程,但是每次我尝试运行程序时,我都会遇到运行时错误并且程序会自行关闭,并且它似乎没有创建任何文本文件,我是不确定问题可能是什么或如何解决,因此非常感谢您的帮助。
这是程序
procedure inventary(arch:string);
var f:text;
op:char;
key,name,desc:string;
begin
assign (f,arch);
if eof(f) then
rewrite(f)
else
append(f);
writeln('Article key');
readln(key);
writeln('Article name');
readln(name);
writeln('article description');
readln(desc);
write(f,key,',',name,',',desc,',');
op:='s';
while (op <> 'n') or (op <> 'N') do
begin
writeln('add another product? y/n');
readln(op);
if (op = 'y') or (op = 'Y') then
begin
writeln('Article key');
readln(key);
writeln('Article name');
readln(name);
writeln('article description');
readln(desc);
write(f,key,',',name,',',desc,',');
end
else
writeln('bye');
readln();
end;
close(f);
readln();
end;
我用来测试它的程序:
uses proyectounit;
var
arch:string;
c:char;
begin
writeln('Name of the inventary');
readln(arch);
Writeln('Do you wish to add a product');
readln(c);
if c='s' then
inventary(arch+'.txt');
Writeln('Do you wish to change something?');
readln(c);
if c='s' then
cambios(arch+'.txt','001');
writeln('end');
readln;
end.