views:

22

answers:

1

Ok, so I've got an application, and I want to make it scriptable. I set up the plist, I set up the sdef file.

So far I have only one apple Event command: gotoPage. it takes an integer. and returns a boolean.

The relevant XML is:

    <command name="gotoPage" code="dcvwgoto" description="Goto a specified page">
        <cocoa class="AEGoto"/>
        <direct-parameter description="Page Number" type="integer"/>
        <result description="True if the page exists, False othrewise" type="boolean"/>
    </command>

I have an Objective-C class AEGoto.h:

@interface AEGoto :NSScriptCommand {
}
- (id)performDefaultImplementation;


- (id)performDefaultImplementation
{
    int page = [[self directParameter] intValue];
    Boolean retval = [gController setPage: page];
    return retval? @"YES" : @"NO";
}

setPage: (int) is correct, and works fine.

When I call this, my program seems to work correctly. But then I get the error:

error "DocView got an error: 4 doesn’t understand the gotoPage message." number -1708 from 4

I also get, in my DocView output:

Error while returning the result of a script command: the result object... YES ...could not be converted to an Apple event descriptor of type 'boolean'. This instance of the class 'NSCFString' doesn't respond to -scriptingBooleanDescriptor messages.

However, if I return just the straight Boolean, I get:

Single stepping until exit from function -[NSScriptingAppleEventHandler handleCommandEvent:withReplyEvent:], which has no line number information. Program received signal: “EXC_BAD_ACCESS”.

so, I guess I've got 2 questions: 1) Why does it think it wants to tell 3 to goto a page? and 2) what is the correct way to return a Boolean from the applescript?

thanks.

+2  A: 

return [NSNumber numberWithBool:retval];

Wevah
So, I guess I only had ONE question then... thanks.
Brian Postow
(Whoops, I skipped right to the bottom of the question in my rush.)
Wevah