🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Joel West Wed, 20 Mar 1985 16:47
C-style string resources
#867
Author: Joel West
Date: Wed, 20 Mar 1985 16:47
48 lines
3121 bytes
I am using Megamax C release 2.0 and trying to get the skeleton application 
posted recently to work.  Unfortunately, I am getting one too many conflicts 
between C strings (which end in a 0) and Pascal "str255" (which are preceeded
by a length byte).

As distributed, the skeleton app uses GetString() to fetch a Pascal string
and then stuffs it in a dialog box with ParamString().  However, Megamax
converts all strings from C-style to Pascal style as you pass them to toolbox 
routines.  (One could debate this approach, but it does appear to be a 
reasonably justifiable solution to the problem.)  ParamString might not have 
done this conversion before 2.0, but it sure does now.

Being a reasonably clever fellow, I have tried a variety of approaches, being
careful not to stray beyond the bounds of good taste.  I have tried:
 (1) Using the distributed version.
     RESULT: Garbage leading character, random (varying) garbage
	     trailing character(s).
 (2) Using the distributed .c files, adding trailing "\0" to the declaration
	of the Pascal string resources.
     RESULT: No trailing garbage, still leading garbage (the length byte).
 (3) Using "Type GNRL = CSTR" and the ".S" data type in my resource file.
     RESULT: Undistinguishable from (2).  A friend said he'd found using
	     ResEdit that the ".S" strings don't seem to do what you'd
	     expect, i.e., a naked string without a length byte.
 (4) Revert to std. resource declarations; produce a modified getCstring()
	which converts C strings in place after calling GetString().
     RESULT: Works beautifully the first time.  However, the second time the
	     same string is used, a Pascal string is expected by getCstring()
	     (but it's actually in C form already) and all hell breaks loose.
 (5) Go back to (2).  Write a getCstring() that takes the GetString() and
	then bumps the pointer referenced by the handle.
     RESULT: Beautiful.  The strings show up perfect every time.  However,
	     Quit crashes the system.

Any ideas?  Declaring null-terminated C strings in the resource file would be 
nice, but I can't figure out how to do it.  Or, SuMacC allows you to fool
the interface string converter with "isapstr(..)", which indicates the string
is already Pascal-like and thus suppresses conversion.

Mail responses to me and I'll post the revised Skeleton with the winning entry 
to net.sources.mac.
-- 
	Joel West				     (619) 457-9681
	CACI, Inc. - Federal 3344 N. Torrey Pines Ct La Jolla 92037
	jww@bonnie.UUCP (ihnp4!bonnie!jww)
	westjw@nosc.ARPA

   "The best is the enemy of the good" - A. Mullarney
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads