Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Getting a 102 runtime error on the pascal program.

+4 votes
asked Jul 18, 2023 by Gary Ohm (450 points)
edited Jul 18, 2023 by Gary Ohm

Getting a 102 runtime error on the pascal program.  Any ideas of why?

Program test (Output, DataIn, DataOut);

var
  Num : Integer;
  DataIn, DataOut : Text;
  
begin
  Reset(DataIn);
  Rewrite(DataOut);
  Read(DataIn, Num);
  Writeln(DataOut, Num);
end.

https://onlinegdb.com/mcSfBaXd8

2 Answers

+1 vote
answered Jul 18, 2023 by Peter Minarik (86,240 points)
selected Jul 19, 2023 by Gary Ohm
 
Best answer

You have not assigned the text files DataIn and DataOut to their file names. Use

Assign(DataIn, 'myFile.dat');

Also, the link you provided does not work. Click on the SHARE button (3 to the right of the RUN button) and use the link there to share your project.

Read this article on file handling: 

commented Sep 27, 2023 by root (810 points)
It is worth noting this is a Delphi (and FreePascal) peculiarity. Technically speaking Gary’s program is correct and complies with ISO standard 7185 (and 10206).  The GNU Pascal Compiler will successfully compile this program and it is usable.
commented Sep 27, 2023 by Peter Minarik (86,240 points)
That's a useful information. I only had experience with Turbo Pascal (about 20 years ago, Jeese, I'm old) as a student.

Thank you for the details!
+1 vote
answered Jul 19, 2023 by Gary Ohm (450 points)
Thank you very much. The Weems/Dale Pascal text book I was using uses the ISO standard of Pascal. It does not define the nonstandard procedure 'Assign'. However, their other book "Turbo Pascal" does.
commented Jul 19, 2023 by Peter Minarik (86,240 points)
If I'm not mistaken, OnlineGDB runs Turbo Pascal, so that's why you definitely need Assign for this online compiler.
commented Jul 19, 2023 by Gary Ohm (450 points)
Turbo Pascal seems to be the popular version of Pascal. Thanks for your comment regarding Assign. It fixed my problem of reading and writing to external files.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...