2

Is there any way in Free Pascal/Delphi to reset the standard Input file back to console window after it was assigned to a 'real file' temporarily?

     AssignFile(Input, 'stdin.txt');
     ...
     CloseFile(Input);
     // ??
     ReadLn(x); // I/O error
1
  • 2
    Have you tried Assignfile(Input, '') ? Commented Nov 4, 2023 at 15:11

1 Answer 1

4

Per Delphi's documentation:

https://docwiki.embarcadero.com/Libraries/en/System.AssignFile

When the FileName parameter is empty, AssignFile associates F with the standard input or standard output file. If assigned an empty name, after a call to Reset (F), F refers to the standard input file, and after a call to Rewrite (F), F refers to the standard output file.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.