Re: What's holding Euphoria back?

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

On Sun, 31 Jan 1999 06:44:43 -0800, jguy <jguy at ALPHALINK.COM.AU> wrote:

>Irv Mullins wrote:
>> Below is a small test program that writes data
>> to a disk file. Please explain what is wrong.
<snip>
>
>you are reading as ONE SINGLE string a sequence the last
>two elements of which you wrote as strings when
>they should have been written respectively as
>integer and real.

>It is very simple:
>
>printf(fn,"\n{\"%s\",%d,%0.2f",{s[1],s[2],s[3]})
>
>You have just written this into that file:
>
>{"Sue Smith",32,22.50}
>
>which you later read back like this:
>
>object buffer
>sequence s
>
>buffer=get(fn)
>s=buffer[2]
>
>
>Simple. It's only a matter of reading the documentation, which
>mercifully, is not overly long. But I/O *is* the trickiest
>part of every language. Likewise random access (which *is*
>true random access).

Except for a couple of things:
 1. Rob said it could be done with puts()
 2. Your code doesn't work. The fix is easy, just a typo in the
    sprintf(), but a beginner wouldn't know where to look.
 3. In Pascal, for example, I could have written it write(fn,s)
    and been done with it. Later I could add to or modify the
    structure 's' without having to change the output formatting
    in the printf(),or worse, printf's in multiple programs which
    write to the same data file.

Actually, I shouldn't complain. There's nice job security in
writing your own i/o routines. Helps if you "forget" to supply
the source.

Irv

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

Search



Quick Links

User menu

Not signed in.

Misc Menu