【发布时间】:2023-01-22 10:05:58
【问题描述】:
好的 ?我想在 Linux 上仅在纯 Pascal 中创建一个简单的文本编辑器,这样我就可以打开一个文件并在程序本身中编辑它,或者在其中创建一个文件并完成已经提到的其余部分。到目前为止我得到的是以下内容:
在下面的代码中,我创建了一个文件,然后在不退出程序的情况下向其中添加了我想要的文本,我只使用 CTRL-Z 退出,但是没有方向箭头的交互作用,无法根据需要编辑文件:
program textos;
uses crt;
var
file_name: string;
f: text;
c: char;
s: string;
begin
writeln('Enter the name of the file to create');
readln(file_name);
writeln('Enter your text to be recorded in the file ', file_name);
writeln('End with CTRL-Z followed by ENTER');writeln;
assign(f, file_name);
rewrite(f);
repeat;
read(c);
write(f,c);
until c=#26; {is equivalent to chr(26), which is CTRL-Z}
close(f);
writeln('Now look at the file ', file_name, ' in your directory');
writeln;
writeln('Reading now from disk line by line and putting on screen:');
reset(f); {opening for reading}
while (not eof(f)) do
begin
readln(f,s);
writeln(s);
end;
end.
我已经搜索过了,但没有找到任何相关的东西,我只是在最后一个案例中才把它留在这里。如果有人可以帮助我,我将不胜感激,谢谢...
【问题讨论】: