RE: Str255 Conversion
RE: Str255 Conversion
- Subject: RE: Str255 Conversion
- From: Jean-Daniel Dupas <email@hidden>
- Date: Wed, 12 Mar 2003 23:26:21 +0100
In fact the Str255 is a Pascal String. You need to convert it into cString
before use it.
You can do this whit the fonction
void CopyPascalStringToC ( ConstStr255Param src, char *dst);
Doc is in the chapter "Text Utilities" in Carbon Doc "Text and other
international services".
After just do a [NSString stringWithcString:dst] to create the NSString.
>
Message: 14
>
Date: Wed, 12 Mar 2003 14:12:13 -0500
>
Subject: Str255 Conversion
>
From: Craig Bakalian <email@hidden>
>
To: email@hidden
>
>
Hi,
>
I need to convert a Str255 to an NSString. I am using voice
>
recognition. All is well, except for the Str255. How do I do it? What
>
exactly is a Str255? I mean, I thought I knew everything :) Thanks in
>
advance...
>
>
pascal OSErr HandleSpeechDoneAppleEvent (const AppleEvent *theAEevt,
>
AppleEvent* reply, unsigned long refcon)
>
{
>
long actualSize;
>
DescType actualType;
>
OSErr status = 0, recStatus = 0;
>
SRRecognitionResult recResult;
>
Str255 str;
>
Size len;
>
>
status = AEGetParamPtr(theAEevt,keySRSpeechStatus,typeShortInteger,
>
&actualType, (Ptr)&recStatus, sizeof(status),
>
&actualSize);
>
if (!status && !recStatus)
>
status = AEGetParamPtr(theAEevt,keySRSpeechResult,
>
typeSRSpeechResult, &actualType, (Ptr)&recResult,
>
sizeof(SRRecognitionResult), &actualSize);
>
>
if (!status)
>
{
>
len = 255;
>
status = SRGetProperty (recResult, kSRTEXTFormat, str+1, &len);
>
if (!status)
>
{
>
str[0] = len;
>
SRReleaseObject (recResult);
>
}
>
}
>
>
if(!status)
>
{
>
NSString *myString;
>
myString = [NSString stringWithFormat: @"%s", str]; //This
>
isn't working!!!!! junk
>
NSLog(myString);
>
}
>
else
>
{
>
NSLog(@"duh?");
>
}
>
return status;
>
}
>
>
>
Craig Bakalian
>
www.eThinkingCap.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.