Stack Opens Manually But Script Thinks It's Corrupted?

Richard Gaskin ambassador at fourthworld.com
Thu Jul 31 14:39:00 EDT 2003


Dan Shafer wrote:

> The dox "bug" is simply that there's no explicit example of how to do
> this and when you look at the other code examples available, they seem
> to imply that you should use the file: protocol.

When I first started with MetaCard in '97, I was asked to write a routine
that copied files from one directory to another.  With a decade of SuperCard
experience under my belt, I used "open file" to read them, only to find that
the files were unreadable in the target dir.  Looking into it more deeply I
found that I should have useds "open file <filename> for binary read".

Oh, the rant I had in the office that day:  "How dumb!  What the heck's
wrong with that Scott Raney!  Doesn't he know that when we read files we
want the file's actual data unmodified?!?"

Looking further still, I recalled that HyperCard works similarly to MC in
this regard:  it modifies data when reading to remove null bytes.  MC goes
one step further to also convert line endings the to Unix-native form (LF)
used internally within MC.

But MC goes even further than SC or HC by giving us a choice:  you can do a
straight read which assumes text and pretties it up for internal use, or you
can open as binary to read the unadulterated data.

So the central question is: Which shoud be the default, the HC model which
alters the data or the SC model that doesn't?

For whatever reason, probably history and relative installed based, MC (and
now Rev) uses the HC model.  When the url syntax was added in v2.1 (?) it
followed suit, offering "file:" and "binfile" as services (and later
"resfile:" for Mac folks).

The docs could probably clarify this better, and with so many thousands of
pages to write and maintain a note to Jeanne on such things is probably very
helpful.

But in spite of my own initial tantrum I've come to appreciate the
flexibility, and since most of my reads are with text files I love the
platform-independence granted by having the default option take care of line
endings without having to think about it.

-- 
 Richard Gaskin 
 Fourth World Media Corporation
 Developer of WebMerge: Publish any database on any Web site
 ___________________________________________________________
 Ambassador at FourthWorld.com       http://www.FourthWorld.com
 Tel: 323-225-3717                       AIM: FourthWorldInc




More information about the use-livecode mailing list