on clicked theObject
if the name of theObject is "doSearch" then
if (invocation = "") then
set url to call method "URLWithString:" of class "NSURL" with
parameter scriptUrl
--set invocation to call method "invocationWithURL:" with parameter
url
end if
--set x to call method "invokeWithSelector:arguments:" of invocation
with parameters {"get_page_record", 4903}
--display dialog page_number of x as string
end if
end clicked
The weird thing is, I wrote a Cocoa controller class that wraps up all
that stuff into a single method call and that works but it doesn't
seem to work when the return type isn't a "normal" AppleScript type
like string (NSString) , array (NSArray), record (NSDicrtionary). I
even tried to add a method to my Cocoa controller that encapsulates
the calls to NSURL and PHPInvocation but those fail with the same
compile errors.
Here's the Cocoa controller
@implementation NSApplication (PHPController)
// This one compiles and works
- (id) invokeScript:(NSString *) inURL
withSelector:(NSString *) inSelector
arguments:(id) inArgs
{
NSURL *url = [NSURL URLWithString: inURL];
PHPInvocation *invocation = [PHPInvocation invocationWithURL: url];
id result = [invocation invokeWithSelector: inSelector
arguments: inArgs];
return result;
}
// These both fail with the above compile error
- (id) urlWithString:(NSString *) inString
{
return [NSURL URLWithString: inString];
}
Do you know if return types from any called method must be one of the
basic types like NSString, NSArray, NSDictionary etc...?
On Nov 10, 2008, at 7:34 AM, HAMSoft Admin wrote:
I haven't tested this, but the first line should look like this...
notice you missed the ":" and then the variable you input is done
with "with parameter"...
The other call method lines have the same problem. The colon is part
of the method name so you need those. The colon tells the method
that there is a parameter needed. Methods without a colon have no
parameter. Methods with multiple parameters, such as NSFont's
"fontWithName:size:" have 2 colon's. These require you put the
parameters in with the wording "with parameters" as opposed to "with
parameter". And when you use "with parameters" you have to put the
variables in as a list. This method would look like the following...
set myNSFont to call method "fontWithName:size:" of class "NSFont"
with parameters {"Helvetica", 12.0}
I wrote a Cocoa class that enable the easy query of PHP scripts but
am finding that when I switch over to AppleScript, I can't figure
out how to initialize it.
I tried to do something similar in AppleScript but am stuck on how
to create Cocoa objects from within it. Here's what I tried so far:
property invocation : ""
on clicked theObject
if the name of theObject is "doSearch" then
if (invocation = "") then
set url to call method "URLWithString" of class "NSURL" with "http://localhost/Test/TestPHPScript.php
"
--set invocation to call method "invocationWithURL" of class
"PHPInvocation" with url
end if
--set x to get_page_record
call method "uppercaseString" of (contents of text field
"inputField" of window "myWindow")
end if
end clicked
When I go to build the project however, I'm getting the following
compile error
Expected “into”, variable name, class name, other parameter name or
property but found “"”. (-2741)
Is it even possible to create new Cocoa objects within AppleScript
and if so, how does one go about doing it?
Thanks for any help
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Studio mailing list (email@hidden
)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Studio mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden