Thanks for the suggestion of using FILE variable and the SEEK function.
I have a little problem with my another program.
PROBLEM:
Let me explain.
During name creation, if I enter <3 letters, program closes.
No error in login process.
PROGRAM test_1;
USES crt;
VAR IOcode: integer;
name, name2: STRING;
error: boolean;
save: text;
BEGIN
assign(save, 'C:\save.txt');
REPEAT
{$I-} reset(save); {$I+}
IOcode:= IOresult;
IF IOcode=2 THEN writeln('Create') ELSE IF IOcode=0 THEN writeln('Login');
write('Name: '); readln(name);
IF length(name)>=3 THEN BEGIN
error:= FALSE;
IF IOcode=2 THEN BEGIN rewrite(save); writeln(save, name); writeln('Done!!!'); delay(500) END ELSE
IF IOcode=0 THEN BEGIN readln(save, name2) END
END ELSE
IF length(name)<3 THEN BEGIN error:= TRUE; writeln('>=3 letters please!'); delay(500) END;
close(save); clrscr
UNTIL (name=name2) AND NOT error
END.
Here's a screenshot (not exactly the same as the one above):
I find out that the error code for File Not Open is 103.
My informal solution is to change the IF condition from IOcode=2 to IOcode<>0, also place close(save); between {$I-} {$I-}.
When I create a new name, the program flow is THE SAME as the following;
assign(save, 'C:\save.txt');
{$I-} reset(save); {$I+} {IOresult=2}
close(save);
But I don't know why the exe gives me error code 103 instead of 2.