1. Euphoria, BGET, binary file routines
- Posted by "Boehme, Gabriel" <gboehme at MUSICLAND.COM> Apr 07, 1999
- 379 views
First of all, it's nice to see some actual Euphoria discussion taking place here on the list. I realize this *nix stuff is important to some of you, but it was really getting ridiculous for a while back there. Newcomers must have been wondering if they were even on the right list! Now, in BGET news, I have discovered that the benchmark program I included was being grossly unfair to Ralf's EDOM routines. It turns out EDOM isn't nearly as slow as my benchmark program made it look, so I apologize to Ralf for that. I've also been optimizing BGET, making large and small changes to make things even faster than they already were. The corrected benchmark program and the speeded-up BGET stuff will be posted to the contributions page as soon as they're ready (which may be a while...). In future news, I'm working on a Euphoria library for reading and writing structures from binary files. This will (finally!) allow Euphoria programmers to work comfortably with the binary file storage methods used by QBasic and Pascal (among many others). constant FILE_STRUCT = {B_SIGNED_INT16, B_LENBYTE_STRING(11), -- 1 length, 10 chars B_FLOAT32, B_AREA(17) -- 17 bytes of filler } object x x = get_struct(fn, FILE_STRUCT) if sequence(x) then -- x contains {int16, "string", float32, {17 bytes}} end if Routines will also be included for binary random-access methods: fn = open_random("file.dat", "rb", FILE_STRUCT) x = get_random(fn, 1) -- gets record 1 from the file if sequence(x) then if put_random(fn, 2, x) then -- write to record 2 puts(1, "Cannot write to record 2\n") end if end if A lot of this is just in preliminary stages right now, so any feedback (ideas, suggestions, stories of previous attempts to write the same thing, etc.) would be greatly appreciated! As with BGET, I'm trying to keep things consistent with existing Euphoria conventions, so it fits in as neatly as possible with everything else. This is all kind of funny -- I got into Euphoria to get *away* from all this binary file mess! Now I find myself not only drawn back into binary file handling, but actually writing libraries to drag Euphoria back into it as well... Be seeing you, Gabriel Boehme ------- Nothing worthwhile is achieved suddenly. Robert Fripp -------