Re: What's holding Euphoria back?

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

On Sat, 30 Jan 1999 00:05:41 -0500, Robert Craig <rds at EMAIL.MSN.COM> wrote:

>Irv Mullins writes:
>
>> 3. Abysmal waste of disk space when writing data files.
>> ... We need to store single characters as one byte on
>> disk, not two, three or more
>
>When you write one or more characters to disk using
>puts(), they *are* stored as one byte each. If you think
>that print() to disk is wasteful, don't use it.

Obviously there is something about Euphoria that I don't
understand. Below is a small test program that writes data
to a disk file. Please explain what is wrong.

sequence s
atom fn
constant NAME = 1, AGE = 2, WAGE = 3

fn = open("TEST.DAT","w")

s = {"Sue Smith",32,22.50}
? s
printf(1,"Name: %s \n", {s[NAME]})
printf(1,"Age: %d  \n", s[AGE])
printf(1,"Wage: %4.2f \n", s[WAGE])

-- puts(fn,s) won't work "sequence found inside character string"
-- so we puts it one "field" at a time:

for i = 1 to length(s) do puts(fn,s[i])
end for
close(fn)

fn = open("TEST.DAT","r")
s = gets(fn)
close(fn)

? s
printf(1,"Name: %s \n", {s[NAME]})
printf(1,"Age: %d  \n", s[AGE])
printf(1,"Wage: %4.2f \n", s[WAGE])

-- Sue, now known as "S", is 117 years old, and she makes 101 dollars an hour! 
http://members.aol.com/FilesEu/
-- probably correct - she has lots of experience!
-- Irv

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

Search



Quick Links

User menu

Not signed in.

Misc Menu