dmmg1176@uxa.cso.uiuc.edu (David M Marcovitz) (01/31/91)
I am using Think C 4.0 with TCL. I am trying to use the gBartender class to change menus. On page 246 of the manual, it gives an example: gBartender->SetCmdText(cmdCopy, "\pCopy Picture"); The second argument is supposed to be a Str255. If I use the command just like this, the compiler doesn't recognize the second argument as being the right type. I can get around this by creating a variable of type Str255 and copying "\pCopy Picture" into that variable. This is ok, but according to the documentation, I shouldn't have to do that. I have two questions: (1) Am I doing something wrong, or is the documentation messed up? (2) Is there a way to do this without declaring a variable? Thanks. -- David M. Marcovitz | internet: marcovitz@uiuc.edu Computer-based Education Research Lab | dmmg1176@uxa.cso.uiuc.edu University of Illinois | novanet: marco / cca / cerl
bin@primate.wisc.edu (Brain in Neutral) (01/31/91)
From article <1991Jan31.061259.20093@ux1.cso.uiuc.edu>, by dmmg1176@uxa.cso.uiuc.edu (David M Marcovitz): | | I am using Think C 4.0 with TCL. I am trying to use the gBartender | class to change menus. On page 246 of the manual, it gives an | example: | | gBartender->SetCmdText(cmdCopy, "\pCopy Picture"); | | The second argument is supposed to be a Str255. If I use the command | just like this, the compiler doesn't recognize the second argument as | being the right type. | | (2) Is there a way to do this without declaring a variable? How about: gBartender->SetCmdText(cmdCopy, (StringPtr) "\pCopy Picture"); The disparity comes about because literal "...." constructs are considered char arrays, whereas Str255 are array of unsigned chars. This is really a pain, but necessary, because otherwise operations using the length byte of Str255 variables are dangerous in that you can get sign-extension if the length of the string is > 127. -- Paul DuBois dubois@primate.wisc.edu
dmmg1176@uxa.cso.uiuc.edu (David M Marcovitz) (02/01/91)
bin@primate.wisc.edu (Brain in Neutral) writes: >How about: > gBartender->SetCmdText(cmdCopy, (StringPtr) "\pCopy Picture"); >The disparity comes about because literal "...." constructs are >considered char arrays, whereas Str255 are array of unsigned chars. >This is really a pain, but necessary, because otherwise operations >using the length byte of Str255 variables are dangerous in that you >can get sign-extension if the length of the string is > 127. >-- >Paul DuBois >dubois@primate.wisc.edu Thanks. I tried casting with Str255, and it didn't like that. I'll try StringPtr. -- David M. Marcovitz | internet: marcovitz@uiuc.edu Computer-based Education Research Lab | dmmg1176@uxa.cso.uiuc.edu University of Illinois | novanet: marco / cca / cerl
dmmg1176@uxa.cso.uiuc.edu (David M Marcovitz) (02/01/91)
>bin@primate.wisc.edu (Brain in Neutral) writes: >>How about: >> gBartender->SetCmdText(cmdCopy, (StringPtr) "\pCopy Picture"); >>The disparity comes about because literal "...." constructs are >>considered char arrays, whereas Str255 are array of unsigned chars. >>This is really a pain, but necessary, because otherwise operations >>using the length byte of Str255 variables are dangerous in that you >>can get sign-extension if the length of the string is > 127. >>-- >>Paul DuBois >>dubois@primate.wisc.edu Thanks. I tried it, and it worked. I know I shouldn't get annoyed by these things, but I'm still disturbed that the manual was wrong. -- David M. Marcovitz | internet: marcovitz@uiuc.edu Computer-based Education Research Lab | dmmg1176@uxa.cso.uiuc.edu University of Illinois | novanet: marco / cca / cerl