1. Write Binary
- Posted by Arthur Adamson <euclid at ISOC.NET> Jun 03, 1998
- 659 views
I thought I read that opening a file as "wb" would permit writing any object, even though complicated, in one command such as : integer fnOut fnOut = open("file.out", "wb") put(fnOut, o) or write(fnOut, o) or some such. Now that I want to do it, I haven't found the right command. Is there a way? Thanks for your help, Art Adamson Arthur P. Adamson, The Engine Man, euclid at isoc.net
2. Re: Write Binary
- Posted by "Graeme." <hmi at POWERUP.COM.AU> Jun 04, 1998
- 609 views
At 05:33 PM 6/3/98 -0400, Art wrote: > > I thought I read that opening a file as "wb" would permit writing >any object, even though complicated, in one command such as : > >integer fnOut >fnOut = open("file.out", "wb") >put(fnOut, o) or >write(fnOut, o) or some such. > > Now that I want to do it, I haven't found the right command. Is >there a way? > Thanks for your help, Art Adamson You're looking for: puts(fnout,someInteger) Graeme. ----------------------------------------------------
3. Re: Write Binary
- Posted by mountains at MINDSPRING.COM Jun 03, 1998
- 611 views
At 05:33 PM 6/3/98 -0400, you wrote: > I thought I read that opening a file as "wb" would permit writing >any object, even though complicated, in one command such as : > >integer fnOut >fnOut = open("file.out", "wb") >put(fnOut, o) or >write(fnOut, o) or some such. > > Now that I want to do it, I haven't found the right command. Is >there a way? > Thanks for your help, Art Adamson > > > >Arthur P. Adamson, The Engine Man, euclid at isoc.net > Write Binary just sends 8bit values out (0..255decimal) while the other write modes add c/r codes, and interpret control-z to indicate end-of-file. If you're writing stuff that might have a control-z (Ascii 26) imbedded in it, you have to use binary writes. Hope I'm right about that. Irv
4. Re: Write Binary
- Posted by mountains at MINDSPRING.COM Jun 03, 1998
- 619 views
At 05:33 PM 6/3/98 -0400, you wrote: > I thought I read that opening a file as "wb" would permit writing >any object, even though complicated, in one command such as : > >integer fnOut >fnOut = open("file.out", "wb") >put(fnOut, o) or >write(fnOut, o) or some such. > > Now that I want to do it, I haven't found the right command. Is >there a way? > Thanks for your help, Art Adamson > > > >Arthur P. Adamson, The Engine Man, euclid at isoc.net > I guess I should finish writing my e-mails before I click "send". Anyway, I think you want print(o) It will write any kind of sequence along with the braces... o = {1,2,4,{3,1},"Hello"} print will send just that to disk as {1,2,3,{4,2},{72,101,108,108,111}} You read it back with get. Irv
5. Re: Write Binary
- Posted by Michael Sabal <mjs at OSA.ATT.NE.JP> Jun 04, 1998
- 606 views
---------- From: Arthur Adamson[SMTP:euclid at ISOC.NET] Sent: Thursday, 04 June, 1998 6:33 AM To: EUPHORIA at LISTSERV.MUOHIO.EDU Subject: Write Binary I thought I read that opening a file as "wb" would permit = writing any object, even though complicated, in one command such as : integer fnOut fnOut =3D open("file.out", "wb") put(fnOut, o) or write(fnOut, o) or some such. Now that I want to do it, I haven't found the right command. Is there a way? Thanks for your help, Art Adamson Arthur P. Adamson, The Engine Man, euclid at isoc.net ----------------- Graeme responded by suggesting puts(file,integerData), but I get the = feeling that's not what you had in mind. If file size isn't an issue, = you could just use print(file,objectData) and get(file,objectData) since = it prints the Euphoria sequence, squiggly brackets and atoms, exactly as = you'd see it in the trace window. Very simple. However, if you're = working with very large sequences, you might be better off using Ralf's = EDOM2. Michael J. Sabal mjs at osa.att.ne.jp http://home.att.ne.jp/gold/mjs/
6. Re: Write Binary
- Posted by Arthur Adamson <euclid at ISOC.NET> Jun 03, 1998
- 652 views
- Last edited Jun 04, 1998
>> I thought I read that opening a file as "wb" would permit writing >>any object, even though complicated, in one command such as : >> >>integer fnOut >>fnOut = open("file.out", "wb") >>put(fnOut, o) or >>write(fnOut, o) or some such. >> >> Now that I want to do it, I haven't found the right command. Is >>there a way? >> Thanks for your help, Art Adamson >You're looking for: >puts(fnout,someInteger) >Graeme. >---------------------------------------------------- Graeme, not quite, if I understand you. I want o to be some complicated sequence with various different objects at various index locations, some of them integers, some sequences of different lengths, some atoms, some floats. I can take it apart but was hoping I didn't need to. Thanks for the quick answer. Bye, Art Irv, your suggestion re print(fnOut, o) does the job, Thanks. I should have known, but sometimes with my nose up against a tree trunk, I forget to back off and walk around the tree. Bye, Art Arthur P. Adamson, The Engine Man, euclid at isoc.net
7. Re: Write Binary
- Posted by Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL> Jun 04, 1998
- 635 views
> I thought I read that opening a file as "wb" would permit writing >any object, even though complicated, in one command such as : > >integer fnOut >fnOut = open("file.out", "wb") >put(fnOut, o) or >write(fnOut, o) or some such. > > Now that I want to do it, I haven't found the right command. Is >there a way? > Thanks for your help, Art Adamson You want to write an object ? So, it could be a sequence or an atom ? And the sequence could contain *any* type of data ? Get my EDOM2, it will allow you to store *any* sequence you want. -- Saving include edom.e object x x = {"Euphoria Rulez", {12345.12345, -123}} err = edo_save ("file.out", x, CP_NONE) if err then puts(1,EDO_ERRORS[err]) abort(1) end if --Loading include edom.e object x x = edo_load ("file.out", CP_NONE) if integer (x) then -- Error code returned puts(1,EDO_ERRORS[x]) abort(1) end if -- X should now contain {"Euphoria Rulez", {12345.12345, -123}} You can do this without EDOM, then you have to use print () and get () but they are *much* slower, and extremely inefficient, they will write something like this: "{ { 70 , 87 , 82 , 81.... } , {" However, this kind of file can be modified with any tex editor. The format EDOM uses to save them is very efficient, but completely unreadable for a human. It is efficient, not only the *way* it stores the structure of your sequence, but values of 1 and 0 are stored binairr and values above -255 and below 257 are stored as bytes. Like the use of bytes, many different data types are used to store your sequence efficiently. You can set custom I/O handlers if you want, to apply compression or data encryption. You can use sequence optimizers to convert you sequence to an easier to save sequence. (but those are just for those, who wish to be extremely efficient. The thing is, it is easy to use this way, without having to write a routine to save your data in a special format that only your program can read.) You can get it at Irv's Archive or at the Archive at RDS ("Saving compressed sequences") Ralf Nieuwenhuijsen nieuwen at xs4all.nl
8. Re: Write Binary
- Posted by Daniel Berstein <daber at PAIR.COM> Jun 04, 1998
- 612 views
-----Original Message----- De: Graeme. <hmi at POWERUP.COM.AU> Para: EUPHORIA at cwisserver1.mcs.muohio.edu <EUPHORIA at cwisserver1.mcs.muohio.edu> Fecha: miércoles 3 de junio de 1998 19:32 Asunto: Re: Write Binary >At 05:33 PM 6/3/98 -0400, Art wrote: > >> >> I thought I read that opening a file as "wb" would permit writing >>any object, even though complicated, in one command such as : >> >>integer fnOut >>fnOut = open("file.out", "wb") >>put(fnOut, o) or >>write(fnOut, o) or some such. >> >> Now that I want to do it, I haven't found the right command. Is >>there a way? >> Thanks for your help, Art Adamson > > >You're looking for: > >puts(fnout,someInteger) You meant puts(fnOut,someSequence or someAtom) You can also use print(fnOut, someObject). print() will write a representation of an Euphoria object, you can later use gets() (or was it get()?) to "reload" the object into memory. Regards, Daniel Berstein daber at pair.com
9. Re: Write Binary
- Posted by "Graeme." <hmi at POWERUP.COM.AU> Jun 05, 1998
- 625 views
> Graeme, not quite, if I understand you. I want o to be some >complicated sequence with various different objects at various index >locations, some of them integers, some sequences of different lengths, >some atoms, some floats. I can take it apart but was hoping I didn't >need to. Thanks for the quick answer. Bye, Art Sorry, I mis-read your question (just woke up) (|~{})* Graeme. *Attempt at new symbol - The "scrunched up face, bleary-eyed yawny" (don't think it'll catch on) ----------------------------------------------------
10. Re: Write Binary
- Posted by Arthur Adamson <euclid at ISOC.NET> Jun 04, 1998
- 615 views
- Last edited Jun 05, 1998
indow. Very simple. However, if you're working with very large sequences, you might be better off using Ralf's EDOM2. > >Michael J. Sabal Michael, thanks, I'll give it a try. Art Arthur P. Adamson, The Engine Man, euclid at isoc.net