Re: how get "number" in disk text file read into integer variable?
----- Original Message -----
From: Dan B Moyer <DANMOYER at PRODIGY.NET>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Wednesday, February 02, 2000 7:44 AM
Subject: Re: how get "number" in disk text file read into integer variable?
If you prefer to save your data to disk in human readable (and editable)
form,
try this method:
include get.e
with trace
trace(1)
integer fn, dummy
object item, fontin
sequence fontout
fontout = {1,2,3.1415,100,"SomeTextHere"} -- example data in variable
-- write the data (to two lines)
fn = open("Font.dat","w")
for i = 1 to 2 do
printf(fn,"%d %d %f %d %s\n",fontout ) -- writes: 1 2 3.1415 100
SomeTextHere
end for
close(fn)
-- read the data
fn = open("Font.dat","r")
fontin = {}
for i = 1 to 4 do -- hassle, because you must use different reads depending
item = get(fn) -- upon the type of the variable that was written.
fontin &= item[2] -- using a structure, you could do this in one line.
end for -- too bad there's not a readf() command!
fontin &= {gets(fn)}
close(fn)
printf(1,"%d %d %f %d %s\n",fontin)
if fontin[4] = 100 then -- test to see if retrieved "number" is useable
puts(1,"yes! the retrieved number is useable as an number in program")
end if
puts(1,"\n\n")
puts(1,"(press any key to exit)")
dummy = wait_key() -- lets it stay on screen until key pressed
Regards,
Irv
|
Not Categorized, Please Help
|
|