Re: RESPCODE : Bload

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

At 02:01 AM 6/12/98 -0700, you wrote:

>[ BLOAD ]
>Greame posted
>function bload(sequence path)
>integer fn,c
>sequence r
>
>        r={}
>        fn=open(path,"rb")
>        c=getc(fn)               -- PROBLEM! What if the open failed?
>        while c!=-1 do
>                r=r&c
>                c=getc(fn)
>        end while
>        return r
>        end function
>
>-- This should fix the problem of open failure.
>----- *Untested Code* -----
>function bload(sequence path)
>integer fn,c
>sequence r
>
>        r = {}
>        fn = open(path,"rb")
>        c = fn
>        while c != -1 do
>                c = getc(fn)
>                r = r&c
>        end while
>        return r
>end function

I just typed it into Eudora to
illustrate the principle of loading
data, but that's an elegant solution
for the open fail case. The only
problem with it is that it adds and
extra byte to the file every time
you load it.

Graeme.
----------------------------------------------------

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

Search



Quick Links

User menu

Not signed in.

Misc Menu