[comp.sys.mac.hypercard] Reading files containing X'00

psych@watserv1.waterloo.edu (R.Crispin - Psychology) (07/17/90)

I am trying to create a hypercard stack to do some manipulations
on Red Ryder Host. I am specifically trying to access the File
Transfer Sections. When HC reads the files it converts all the
hex 00 to a space (hex 40). This is not cool. A friend suggested
it might do this only at the beginning of variables. I need to know
exactly what HC is doing. Does anyone have a solution?

Thanks in advance.

Richard Crispin              Phone:    (519)888-4781
Dept. of Psychology          Bitnet:   psych@watdcs 
University of Waterloo       Internet: psych@watserv1.UWaterloo.ca 
Waterloo, Ont.   Canada   N2L 3G1

jdevoto@Apple.COM (Jeanne A. E. DeVoto) (07/18/90)

In article <1990Jul17.121924.25050@watserv1.waterloo.edu>
psych@watserv1.waterloo.edu (R.Crispin - Psychology) writes:
> [...]  When HC reads the files it converts all the
>hex 00 to a space (hex 40). This is not cool.

HyperCard uses the null character (ASCII 0) as an end-of-string
marker, which means you cannot use nulls in variables.

Unfortunately, I don't know of any workaround for this.
-- 
========= jeanne a. e. devoto ========================================
 jdevoto@apple.com     |  You may not distribute this article under a
 jdevoto@well.sf.ca.us |  compilation copyright without my permission.
______________________________________________________________________
 Apple Computer and I are not authorized      |        CI$: 72411,165
 to speak for each other.                     |

ccc_ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) (07/20/90)

I think this "feature" of HyperCard (using nulls to terminate strings)
is a pain in the bum and I would really like to know why St Bill
(who otherwise truly deserves his sainthood) chose to do things this way.

Lawrence D'Oliveiro
Computer Services Dept                    fone: +64-71-562-889
University of Waikato                      fax: +64-71-384-066
Hamilton, New Zealand            electric mail: ldo@waikato.ac.nz
To someone with a hammer and a screwdriver, every problem looks
like a nail with threads.

bc@Apple.COM (bill coderre) (07/21/90)

(Lawrence D'Oliveiro, Waikato University) writes:
|I think this "feature" of HyperCard (using nulls to terminate strings)
|is a pain in the bum and I would really like to know why St Bill
|(who otherwise truly deserves his sainthood) chose to do things this way.

Would you rather they used P-strings, which could theoretically
contain 00's (except that certain Toolbox routines (such as all the
Text Edit rouitines) would barf), but which restrict text to 255
characters?

What you really want is a binary-oriented I/O construct, something
Hypercard doesn't provide at this point. Sounds like a really useful
XCMD to me.

It's quite true and well-known that Hypercard has many limitations.
When it first came out, nobody knew just what people would use it for,
so the limitations were not as apparent. Now that people are asking
for new features to expand Hypercard, the HC team is adding some of
them. HC2 adds a whole new level of expressiveness to Hypertalk, in
addition to some much-needed features (such as multiple windows and
menus) AND a speed increase to boot.

I suggest that you send a feature request to the team. They might do
it.

bill coderre,
private consultant

ccc_ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) (07/25/90)

In <43234@apple.Apple.COM>, bc@Apple.COM (bill coderre), says, in
response to my grumble about null-terminated strings in HyperCard,

"Would you rather they used P-strings, which could theoretically
contain 00's (except that certain Toolbox routines (such as all the
Text Edit rouitines) would barf), but which restrict text to 255
characters?"

No, I wouldn't. HyperCard strings are stored as relocatable blocks,
aren't they? Well, what's wrong with GetHandleSize for getting the length
of the string? Granted it can be slow changing the size of the block
all the time, so for compute-intensive operations inside HyperCard
you'd just maintain a separate temporary longword count for each string,
and then do a final SetHandleSize on each string at the end.

There's a bit more detail than that, but you get the idea--use a
count instead of a terminating null.

How about passing this one on to the HyperCard team?

Lawrence D'Oliveiro
Computer Services Dept                    fone: +64-71-562-889
University of Waikato                      fax: +64-71-384-066
Hamilton, New Zealand            electric mail: ldo@waikato.ac.nz

bc@Apple.COM (bill coderre) (07/27/90)

Me:
|"Would you rather they used P-strings, which could theoretically
|contain 00's (except that certain Toolbox routines (such as all the
|Text Edit rouitines) would barf), but which restrict text to 255
|characters?"

Lawrence D'Oliveiro:
|No, I wouldn't. HyperCard strings are stored as relocatable blocks,
|aren't they? Well, what's wrong with GetHandleSize for getting the length
|of the string? Granted it can be slow changing the size of the block
|all the time, so for compute-intensive operations inside HyperCard
|you'd just maintain a separate temporary longword count for each string,
|and then do a final SetHandleSize on each string at the end.

Actually, I don't know a damn thing about the internals of HC, so your
theory might or might not be correct. If it isn't (which, when I
think of it, is likely), you would add a BIG overhead to normal
manipulation.

But let's just compromise, shall we:

Feature Request:
Data blocks similar to strings that can contain NUL (hex 00)
characters. Alternately, extend normal strings to handle NULs.

Rationale:
Use of binary data.

Currently, HC does not allow NUL characters in strings. When using
Read From File, HC converts NULs to spaces. This is unacceptable for
binary data manipulation.
........

I will file this feature request today.

If you have a feature you'd like to see, PLEASE WAIT to see if HC 2.0
adds almost the same feature. Chances are, it does! If it doesn't,
I'll figure out a way to request it.

Note please that I have exactly the same sway you do with the HC team:
none. They listen to requests, but they make NO promises. Got it?

mr HEINOUS
"just a contractor, not a spokesdroid"