xrtn Required functions

External developers... This forum's for you!

xrtn Required functions

Postby bmartin » Sat Oct 16, 2010 5:33 am

Mark,

I'm trying to apply some of what I learned developing for the iPhone to an external, basically and xrtn. I have a question about the template.

Obviously I will be using Objective-C to write this external, which is fine I renamed the main.c to main.m and added the Cocoa framework. But there are two functions in the main.c/m file that I don't think I will need I simply want the user to call my external with a start or stop command and then when needed I will send a message to SuperCard until the stop command is issued. So the question, do I need to keep the RegisterSCEvents function and do I need to do anything in the static short events function. As I said once started the state of SuperCard should not matter to me I will just send a message to SuperCard when an OS event takes place.

Thanks,
Bruce Martin

Mac Os 10.6.3
2.8 Ghz Intel Core 2 Duo
4GB 1067 MHz DDR3
User avatar
bmartin
 
Posts: 149
Joined: Mon Jul 07, 2008 7:26 am
Location: Stroudsburg, PA

Re: xrtn Required functions

Postby codegreen » Sat Oct 16, 2010 6:28 pm

bmartin wrote:I simply want the user to call my external with a start or stop command and then when needed I will send a message to SuperCard until the stop command is issued. So the question, do I need to keep the RegisterSCEvents function and do I need to do anything in the static short events function. As I said once started the state of SuperCard should not matter to me I will just send a message to SuperCard when an OS event takes place.

You can't just send messages to SC whenever you feel like it via an xrtn callback. SC is only set up to handle such callbacks during calls to either your script entry or the events entry points. Depending on what's triggering the code in your xrtn from which you want to send the msg and what that msg is you might possibly be able to get away with it, but as a general rule that's a recipe for disaster.

The simplest workaround for that is to register for the null event and keep a flag somewhere in your xrtn code that you set when your other function decides it needs to send a callback, then check that flag in your null event handler and send the msg if necessary.

Does that make sense to you?

-Mark
codegreen
 
Posts: 1510
Joined: Mon Jul 14, 2008 11:03 pm

Re: xrtn Required functions

Postby Dave_Higgins » Sat Oct 16, 2010 8:23 pm

mark wrote:Does that make sense to you?

It answers something that I was wondering about. ;) Probably saves me a couple hours of testing.
My two favorite teams are Detroit and whoever's playing Chicago.
User avatar
Dave_Higgins
 
Posts: 454
Joined: Mon Jul 07, 2008 9:50 am
Location: Dark Side Of The Moon


Return to Xcode and the Internals Toolbox

Who is online

Users browsing this forum: No registered users and 1 guest