[comp.sys.mac.hypercard] HyperCard NumToChar bug

sinteur@uvabick.UUCP (John Sinteur) (08/06/89)

I recently ran into a bug in HyperCard:
NumtoChar does not function if you pass a zero as a parameter,
that is, if you want to write a hex $00 to a disk file, you can't.
Instead, you get a $20 on disk.
The same goes for reading a $00. it reads a 'space' instead, so if you
do a 'chartonum', a 32 results.

I already told Apple about this (the AppleLink address HYPERBUG$),
but I would really like to know if somebody has a workaround for this
sort of thing, as the next 'bugfixing release' probably will never
exist (version 2.0 is what I expect to be the next release. This bug
will probably be solved, but I can't wait for that).

Any ideas?

-John Sinteur
sinteur@uvabick
adegroot@hroeur5.bitnet
john sinteur, 2:512/114 @fidonet

sirkm@ssyx.ucsc.edu (Greg Anderson) (08/08/89)

In article <2332@uvabick.UUCP> sinteur@uvabick.UUCP (John Sinteur) writes:
>I recently ran into a bug in HyperCard:
>NumtoChar does not function if you pass a zero as a parameter,
>that is, if you want to write a hex $00 to a disk file, you can't.
>Instead, you get a $20 on disk.
>The same goes for reading a $00. it reads a 'space' instead, so if you
>do a 'chartonum', a 32 results.

(stuff deleted)

>This bug will probably be solved, but I can't wait for that).
>
>Any ideas?
>
>-John Sinteur
>sinteur@uvabick
>adegroot@hroeur5.bitnet
>john sinteur, 2:512/114 @fidonet

Don't wait, the 'bug' you describe will never be fixed: it's not a bug,
it's a feature.

HyperCard variables and fields are null-terminated; this means that the
last character of any variable or field is a null (hex $00).  If you
were to place a null in the middle of a variable or field, HyperCard
would think that it signified the end of the contents of the text; everything
that followed would be truncated.

HyperCard is by design a text-only system.  There isn't any way to
process nulls with HyperCard; you must either change your design so
you do not need to process nulls (the best solution), or do all of
your processing outside of HyperCard (in an XCMD, perhaps).


  ___\    /___               Greg Anderson              ___\    /___ 
  \   \  /   /         Social Sciences Computing        \   \  /   /
   \  /\/\  /    University of California, Santa Cruz    \  /\/\  /
    \/    \/              sirkm@ssyx.ucsc.edu             \/    \/