Frank Heckenbach wrote:
BTW, I'm wondering what these files actually do. GPCStringsAll defines 216 operators for `+' and relations for various string types. GPC has those operations built-in already and they work with any string type (not just the selection defined here)? Also, GPC allows assignments between string types, so the `StrXX[In]ToStrYY' routines are redundant.
I remember we (i.e., Peter N Lewis and me) talked about such operators for "emulating" short strings last year. But this unit uses the regular GPC string types, so it all seems quite pointless to me.
Frank, I think you missed something in your examination of the GPCStringsAll unit. It actually is a helper/glue unit for emulating short strings along with support for copying to and from GPC's native schema based strings and packed array of char with length byte short strings.
Although it doesn't cover every possible short string size, it does cover those sizes needed to call the Apple defined Mac OS interface routines. All the StrXX types are short string types and the type declarations for those can be found in MacTypes.pas (they are also in the gigantic, include everything GPCMacOSAll.pas). The StringXX types are GPC native string types with capacities set to match the maximum length capability of the corresponding StrXX type.
For an example, the Str15 "short string" type is declared in MacTypes.pas (and also GPCMacOSAll.pas) as:
Str15 = record sLength: Byte; sChars: packed array[1..15] of char; end;
and the String15 "GPC string" type is declared in GPCStringsAll.pas as:
String15 = String(15);
The code in GPCStringsAll.pas does exploit GPC's support for Extended Pascal's substring function access for copying the fixed string sChars field of the "short string" record which may give the impression that it is just duplicating what GPC already provides. However, a closer inspection will reveal that there is additional code to handle the sLength field of the "short string" record which GPC doesn't have any built-in support for. In particular, `StrXX[In]ToStrYY' routines which you think are redundant aren't redundant since those routines have the additioal code needed to correctly set the sLength field of the "short string" record.
Gale Paeper gpaeper@empirenet.com