Board index » delphi » Saving variable info

Saving variable info

Hi.... I would greatly appreciate it if someone could help me on
how to save information stored in variables to files.  For example I
assign certain variables (age, height, etc..) values based on a
individual. I would then like to save them to an file on the hard drive.
How do I do this?

                                        ThaNks,
Smitten-

Smitt...@juno.com

 

Re:Saving variable info


Quote
Brent wrote:
>Hi.... I would greatly appreciate it if someone could help me on
>how to save information stored in variables to files.  For example I
>assign certain variables (age, height, etc..) values based on a

ASSIGN is the right way!

Quote
>individual. I would then like to save them to an file on the hard drive.
>How do I do this?
>                                    ThaNks,
>Smitten-
>Smitt...@juno.com

How to do:

VAR
   f : text;
   i : integer;
   a : ARRAY [1..10] of integer;
BEGIN
   FOR i:=1 TO 10 DO a[i]:=i; {creat some senseless variables...}
   (*...*)
   assign (f,'C:\varibles.dat');  {path and filename where to store variables}
   rewrite (f); {write access enabled}
   FOR i:=1 TO 10 DO writeln (f,a[i]);
   close (f);
end.

How to get them back (read access)?
VAR
   f : text;
   i : integer;
   a : ARRAY [1..10] of integer;
BEGIN
   assign (f,'C:\varibles.dat');  {path and filename where to store variables}
   reset (f); {read access enabled}
   FOR i:=1 TO 10 DO readln (f,a[i]);
   close (f);
   (*...*)  {process them}
end.

A proven and maybe better example you will find with help on "assign" - provided
that you are using BP or TP. Or in your documentation - provided that you have a
legal version... .

Armin

Re:Saving variable info


Try writeln  (f, variables ) or blockwrite. Check them in
your help. Neat examples too.

Re:Saving variable info


Quote
Brent Smith <Smitt...@juno.com> wrote:
>how to save information stored in variables to files.  For example I
>Smitt...@juno.com

In BPW I use WritePrivateProfileString();

Regards

Leonardo

Other Threads