[comp.sys.apple2] GSOS Strings vs. Pascal Strings: Help!

ghost@bucsf.BU.EDU (Jay Adelson) (05/30/90)

Is it possible to set a GSString255 to a pascal string of 255 characters?
I know the difference of the two strings (that is, what makes them 
incompatible..) and I'm looking for some way to convert from one to the
other...

  -Jay

 _____________________________________________________________________________
|-----------------------------------------------------------------------------|
| Jay Adelson           | Phantasmagoric Designs | "If you think things are   |
| ghost@bucsf.bu.edu    | 829 Beacon St.  APT 3B |  going great, you've       |
| J.ADELSON1 (GEnie)    | Boston, MA.      02115 |  forgotten something." -JB |
|_______________________|________________________|____________________________|

shawn@marilyn.UUCP (Shawn P. Stanley) (06/07/90)

In article <57874@bu.edu.bu.edu> ghost@bucsf.UUCP (Jay Adelson) writes:
>I know the difference of the two strings (that is, what makes them 
>incompatible..) and I'm looking for some way to convert from one to the
>other...

No problem.  Since GS/OS strings start with a length word, and Pascal
strings start with a length byte, to convert from one to the other,
all you have to do is skip the second byte in the length.  (As long as
the string is 255 characters or less!)

If you want to use the same string buffer for the conversion, either
move the first byte of the length into the second byte's location and
then reference the string starting from the second byte for Pascal
usage, or copy the string characters byte-by-byte backward one character.
--
Shawn P. Stanley         shawn@marilyn.marilyn.mn.org
bungia!marilyn!shawn     {rosevax,crash}!orbit!marilyn!shawn