<< I often need to store a lot of strings, and don't want to waste the space allocated to a String(255) for each one. With "short" strings, I just allocate memory (with the Mac system NewPtr routine, not with the Pascal New routine) for Length(s)+1 bytes, and then BlockMove the string in. This has the advantage that the string can be references as just Str255Ptr(s)^ (sometimes the size needs to be aligned to 2 or 4 bytes, depending on the platform). >>
The Pascal Macro Compiler has a set of macros that will pack character strings without any wasted space between them The macros can be downloaded directly from the webpage http://www.contestcen.com/paskey.htm which has both the source code and a detailed description.
Frank Rubin Master Software Corp.
Contestcen@aol.com wrote (bogus quoting fixed):
I often need to store a lot of strings, and don't want to waste the space allocated to a String(255) for each one. With "short" strings, I just allocate memory (with the Mac system NewPtr routine, not with the Pascal New routine) for Length(s)+1 bytes, and then BlockMove the string in. This has the advantage that the string can be references as just Str255Ptr(s)^ (sometimes the size needs to be aligned to 2 or 4 bytes, depending on the platform).
The Pascal Macro Compiler has a set of macros that will pack character strings without any wasted space between them The macros can be downloaded directly from the webpage http://www.contestcen.com/paskey.htm which has both the source code and a detailed description.
How can a preprocessor (macro compiler) help here, when it runs at compile time, while time question was clearly about runtime storing of strings (mentioning New and block moves etc.)?
Frank