Read variables from text file? 
Author Message
 Read variables from text file?

Is there a way to get a Pascal program to read variables from a text
file(instead of within the program), or from the command line, or some other
place?


Fri, 20 Apr 2001 03:00:00 GMT  
 Read variables from text file?
Wow!  This is the first time I've posted a response to help someone with
PASCAL!  I'm so pleased with myself ^_^

Anyway, back to topic!

First you need to declare a variable for the file like:

var  inputfile : text;

Then, you need to assign the file in the body of your program like:

assign (inputfile, 'c:\pascal\inputfile.txt');

Then you need to input what mode you want to have, just for reading, use:

reset (inputfile);

Then, when you actually do the reading:

readln (inputfile, variablename);

You can also used read instead of readln too ^_~

Oh, and if any of you PASCAL pros out there found any mistakes in this post,
do please tell me since this afterall IS my first time posting a reply ^_^

And there's a little thing I want to ask you all...  Umm, anybody out there
know how to open jpeg and gif files with PASCAL?  I got a source code for
gif, but it needs an INC file to run (which I don't have)...  Can anybody
help me here?

--
Rayearth

Quote:

>Is there a way to get a pascal program to read variables from a text
>file(instead of within the program), or from the command line, or some
other
>place?



Sat, 21 Apr 2001 03:00:00 GMT  
 Read variables from text file?

Quote:

> Then, you need to assign the file in the body of your program like:

> assign (inputfile, 'c:\pascal\inputfile.txt');

This is for a macintosh???
--
Al Gunther, Kingston, WA  <---- 47 52.7'N, 122 30.9'W


Sat, 21 Apr 2001 03:00:00 GMT  
 Read variables from text file?
Hey "Rick! Ik doe eens eng, en schrijf een berichtje aan je :)

Ongeveer op 03 November 1998 schreef "Rick een meeltje. Hierop ga ik
antwoorden!

 RC> Is there a way to get a pascal program to read variables from a text
 RC> file(instead of within the program), or from the command line, or some
 RC> other place?

From file:

{Example}

Var     F:Text;
        A,B,C,D:Integer;
        E,F,G:String;

Begin
Assign(F,'TESTFILE.VAR');
Reset(F);
Readln(F,A);
Readln(F,B);
Readln(F,C);
...
Readln(F,G);
Close(F);
End.

Hope I helped you :)

For command-line there is ParamStr and ParamCount....

                       See ya later, "Rick

                        Signed,
                            Rene

     +----------+-----------------------------------------------------+
     |Fidonet   | 2:2802/396                                          |
     |Raptornet | 710:100/0                                           |
     |Whizznet  | 38:600/0                                            |
     |Klippernet| 215:312/0                                           |
     |NZN       | 171:2000/300                                        |


     +----------+-----------------------------------------------------+

... Ben jij een vampier? (c) Thea Brokke



Sat, 21 Apr 2001 03:00:00 GMT  
 Read variables from text file?
No, it's for a PC.  Why ask?  At least this is the way I was taught...

--
Rayearth

Quote:



>> Then, you need to assign the file in the body of your program like:

>> assign (inputfile, 'c:\pascal\inputfile.txt');

>This is for a macintosh???
>--
>Al Gunther, Kingston, WA  <---- 47 52.7'N, 122 30.9'W



Sun, 22 Apr 2001 03:00:00 GMT  
 Read variables from text file?

Quote:

> No, it's for a PC.  Why ask?  At least this is the way I was taught...

You were taught to post PC answers to Macintosh newsgroups?  This is why
Al questioned your reply.

Quote:



> >> Then, you need to assign the file in the body of your program like:

> >> assign (inputfile, 'c:\pascal\inputfile.txt');

> >This is for a macintosh???

----
 oBo   Koryn Grant            Catapultam habeo.  Nisi pecuniam omnem mihi
/ X    A Kiwi in the UK        dabis ad caput tuum saxum immane mittam.


Sun, 22 Apr 2001 03:00:00 GMT  
 Read variables from text file?
But I'm posting this at comp.lang.pascal.misc...  AI did send me an e-mail
about me posting a message on a Mac group, but the address he gave me was
comp.lang.pascal.mac...

--
Rayearth

Quote:


>> No, it's for a PC.  Why ask?  At least this is the way I was taught...

>You were taught to post PC answers to Macintosh newsgroups?  This is why
>Al questioned your reply.




>> >> Then, you need to assign the file in the body of your program like:

>> >> assign (inputfile, 'c:\pascal\inputfile.txt');

>> >This is for a macintosh???

>----
> oBo   Koryn Grant            Catapultam habeo.  Nisi pecuniam omnem mihi
>/ X    A Kiwi in the UK        dabis ad caput tuum saxum immane mittam.



Mon, 23 Apr 2001 03:00:00 GMT  
 Read variables from text file?

Quote:

> But I'm posting this at comp.lang.pascal.misc...  AI did send me an e-mail
> about me posting a message on a Mac group, but the address he gave me was
> comp.lang.pascal.mac...

-snip-

You are posting this to *both* (and so am I).

Quote:
> Newsgroups: comp.lang.pascal.mac,comp.lang.pascal.misc

                              ^^^^
Followups set so that to respond in comp.lang.pascal.mac you will have
to take deliberate action.

--
John Moreno



Mon, 23 Apr 2001 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. How can I read text files into variables?

2. Text File Read / Dbase file Write

3. Reading different size variables from same open file in Turbo Pascal 3.0

4. Save/read variable values in a file

5. reading a Unix Generated text file

6. How can read a text file?

7. Reading a text file

8. Read an external TEXT files and store info in 2 Separate ARRAYS

9. read text file

10. How to be reading a text file

11. Reading info from text file...

12. reading from text files

 

 
Powered by phpBB® Forum Software