1. Reading sequences from a file

Evening all,

I saved a bunch of sequences to a file using open(), etc, and now I want to
read them again but when I do the brackets and commas in the sequences are
being read along with the numeric data within. I have tried gets() and
getc() with no luck. Can anyone suggest a way to read just the numeric data
from the sequences?

Thank God for the mailing list!

Thanks,
David S

new topic     » topic index » view message » categorize

2. Re: Reading sequences from a file

> Evening all,

> I saved a bunch of sequences to a file using open(), etc, and now I want to
> read them again but when I do the brackets and commas in the sequences are
> being read along with the numeric data within. I have tried gets() and
> getc() with no luck. Can anyone suggest a way to read just the numeric data
> from the sequences?

> Thank God for the mailing list!

> Thanks,
> David S

What you want here is the get() function from get.e (see library.doc)...

Thomas Parslow (PatRat) ICQ #:26359483
Rat Software
http://www.rat-software.com/
Please leave quoted text in place when replying

new topic     » goto parent     » topic index » view message » categorize

3. Re: Reading sequences from a file

----- Original Message -----
> Evening all,
>
> I saved a bunch of sequences to a file using open(), etc, and now I want
to
> read them again but when I do the brackets and commas in the sequences are
> being read along with the numeric data within. I have tried gets() and
> getc() with no luck. Can anyone suggest a way to read just the numeric
data
> from the sequences?

You can read or write an entire sequence, no matter how complex or nested it
may be, with one command - print() or get()

include get.e -- where the get() command lives

atom fn
sequence s, x

s = {"Sue","Tim","Bonnie",2,4,15.125}
fn = open("myData","w")
print(fn,s)
close(fn)

fn = open("myData","r")
x = get(fn)
if x[1] = GET_SUCCESS then x = x[2] -- chech for read errors
end if
close(fn)

Note: using Euphoria's standard print() function will save strings to disk
in numeric
form {83,114,123,...   which makes strings hard to read with a text editor.
They
will read back into Euphoria programs correctly, however. If you think you
may
want to be able to read and perhaps edit these disk files, then download
Gabriel
Boheme's replacement print.e from the RDS website. It will write these to
disk
as {"Sue","Tim","Bonnie",2,4,15.125}just as you would expect. And it saves
some
disk space as well. Just add
include print.e
at the top of your file. No other changes are needed.


Regards.
Irv

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu