[futurebasic] Re: [FB] [X-FB] RealBasic, etc. is now...

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 2013 : Group Archive : Group : All Groups

From: Robert Covington <artlythere@...>
Date: Fri, 21 Jun 2013 10:51:04 -0400
On Jun 21, 2013, at 10:37 AM, Brian S <fblistserve@...> wrote:

> 
> On Jun 21, 2013, at 4:28 AM, Bernie <fblist.bw@...> wrote:
> 
>> 
>> Steve wrote:
>> 
>>> 
>>> I am a registered Apple developer on MacOS and iOS and currently using xCode for two projects using Cocoa and iOS now.
>>> Money is not an issue.  Faster development time is!
>>> 
>> 
>> Spent a couple hours playing with Xojo yesterday and I must agree that development time is probably faster.
>> 
>>   try
>> 
>>   end try
> 
> 
> Thanks for posting Bernie. What is the purpose of the try/end try block? Same as curly brackets in C? ( or something else? )
> 
> Brian S. 

That might be like a try test in Objective C? I had to come up with this when working with Cocoa menus because if the menu wasn't already there, you'd get a boom-boom, and I didn't know how to find out if it was made yet (is for FB syntax compatible Cocoa Menu statement for my FBCocoa Runtime)

But I found a way around it?

rc


Local Fn CocoaMenuExists(menuID as long) as Boolean
dim as boolean exists
dim as short count
BeginCCode
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
    NSMenu *mainMenu = [[NSApplication sharedApplication] mainMenu];
    count = [mainMenu numberOfItems];
    [pool drain];
EndC
 
exists = (menuID < count)

// Originally
/*BeginCCode
    @try 
    {
     NSMenu *existingMenu = [[mainMenu itemAtIndex:menuID] submenu]; 
     exists = (existingMenu != 0);
    } 

    @catch (NSException *exception) {
    exists = NO;
    NSLog(@"CocoaMenu: Handled Nil Menu %@: %@", [exception name], [exception reason]);
    }

    @finally
    { 
     
    }
    [pool drain];
EndC*/

end fn = exists