Re: Passing a "record" to an AppleScript subroutine
Re: Passing a "record" to an AppleScript subroutine
- Subject: Re: Passing a "record" to an AppleScript subroutine
- From: David Cittadini <email@hidden>
- Date: Sat, 19 Apr 2003 00:59:35 +1000
Thanks. That was very useful and made me think of a few other things.
However, the problem I have is that I am calling external scripts and
for various reasons I need to use NSAppleEventDescriptor in order to
pass the arguments. NSAppleEventDescriptor has a recordDescriptor
method, which I imagine I could use in order to call subroutines with a
record argument. However, that is just a guess. The problem is that I
cannot test to see if this is the case as I don't really know how to
use setAttributeDescriptor/setDescriptor/setParamDescriptor in order to
populate the record descriptor. I managed to get listDescriptor
working well but I don't really know how to use recordDescriptor to
pass records. Any help would be most welcome :-)
David.
On Friday, April 18, 2003, at 01:29 PM, Nate Alf wrote:
>
New to Cocoa, old to AppleScript, but this might help - just remember
>
that you are always passing
>
an NSString that is compiled on the fly and interpreted by AppleScript.
>
>
-----------------------------------------------------------
>
Cocoa code:
>
>
NSMutableString *kAppleScriptLibString = [[NSMutableString alloc]
>
initWithString:@"(load script (POSIX file \""];
>
[kAppleScriptLibString appendString: kCompiledScript];
>
[kAppleScriptLibString appendString: @"\"))"];
>
>
NSMutableString *kHandler1 = [[NSMutableString alloc]
>
initWithString:kAppleScriptLibString];
>
>
[kHandler1 insertString:@"kTest3({x:\"valueX\", y:\"valueY\",
>
z:\"valueZ\"}) of " atIndex: 0];
>
>
NSAppleScript *kAppleScript = [[NSAppleScript alloc]
>
initWithSource:kHandler1];
>
NSString *kResult=[[NSString alloc] initWithString:[[kAppleScript
>
executeAndReturnError:nil] stringValue]];
>
-----------------------------------------------------------
>
AppleScript handler code:
>
>
on kTest3(kRecord)
>
activate
>
display dialog ((class of kRecord) & return & (z of kRecord) as
>
string)
>
return "YES"
>
end kTest3
>
-----------------------------------------------------------
>
>
Nate
>
>
On Wednesday, April 16, 2003, at 05:34 AM, David Cittadini wrote:
>
>
> I am just learning how to call external AppleScripts from within
>
> Cocoa. I am doing this via NSAppleScript and it is working well. So
>
> far I can pass ints, strings and lists to an AppleScript subroutine
>
> but how do I construct and pass a record? Any help would be most
>
> appreciated.
_______________________________________________
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.