Re: Saving sequences

new topic     » goto parent     » topic index » view thread      » older message » newer message
mattlewis said...
znorq2 said...

Is there a set of routines that saves and loads sequences? (Eu v3) I want to be able to save it in a binary file format, and then restore it in it's original form...

This is basically what EDS does. I used that in ooeu. You can get the code here:

http://ooeu.svn.sourceforge.net/viewvc/ooeu/trunk/sequencef.e

Just use the compress() and decompress() functions to turn the sequence into a stream of bytes and vice versa. This is essentially the same code available in the 4.0 standard library.

To read the sequence, you need to set current_db to the file handle. You can see how I wrapped decompress() for the files I needed to use. compress() simply returns the byte stream, which you can write to the file using puts(). Make sure that you're reading and writing in binary mode if you're on windows or DOS.

Matt

Hi Matt,

Sorry, but I'm not quite following you on this one.. However, if I'm not mistaking, you're right about EDS storing the orginal structure of a sequence. I'm pretty familiar with EDS.

m_sabal said...

The simplest method is print() and get(). If you want your file to be human readable, you could use pretty_print() instead. If you'd rather store your sequences in a database, Euphoria's database.e handles this natively. The library.doc file that comes with the Euphoria distribution has all the details and examples you need.

Hi Sabal,

I thought print() and get() where only able to store/retrieve data in a flat format, meaning that the sequence structure would be lost? Am I wrong?

As for pretty_print(), I know of this, and it's not quite what I'm looking for as I want the data to be stored in a binary format that is compact and isn't easily readable. However, if I wanted to store the data using pretty_print() - how would I be able to read the data back in the original sequence structure without having to create my own routine?

These questions might seem abit silly, if so, you'll just have to forgive me... :p

DerekParnell said...
bernie said...

You can also save sequences in ver4.0 using map functions.

Though the new serialization routine in v4.0 are even easier, IMHO.

dump(sequence data, sequence filename) 
 
data = load(sequence filename) 

Sounds good, but unfortunately I'm still stuck at v3 @ work; I dare not change to v4 as I'm maintaining old apps there.

Kenneth / ZNorQ

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu