I have been having problems calling my Cocoa app with Python scripts through the Scripting Bridge. To test further, I wrote the following Cocoa code to use the Scripting Bridge. For a large file (over 7000 elements in the SBElementArray recs variable) it runs smoothly until 77% completion and then stops. I thought it had crashed, but one time I waited and after a 2 minute pause, it starts up again and runs smoothly to 100% completion.

So what is wrong with the Scripting Bridge in long scripts? I get these pauses in many scripts and thus is not related to the specific calls in the sample script. I test some I thought were crashing again and so far all start up again, but some pause for over 5 minutes.

        // get application, front document, and list of some app objects
id gedit = [SBApplication applicationWithBundleIdentifier:@"com.geditcom.GEDitCOMII"];
        id gdoc = [[gedit documents] objectAtIndex:0];
        id recs = [gdoc individuals];

        // loop and do something minor
        int i, numBdate=0, numIndi=0, numRecs=[recs count];
        float fractionStepSize=0.01, nextFraction=0.01;
        for(i=0;i<numRecs;i++)
        {       id indi=[recs objectAtIndex:i];
                if([[indi recordType] isEqualToString:@"INDI"])
                {       numIndi+=1;
                        int emin=[indi birthSDN];
                        int emax=[indi birthSDNMax];
                        if(emin!=0 && emin==emax) numBdate+=1;
                        // print progress
                        fractionDone = (float)i/(float)numRecs;
                        if(fractionDone > nextFraction)
                        {       NSLog(@"%f ",fractionDone);
                                nextFraction = nextFraction+fractionStepSize;
                        }
                }
        }

------------
John Nairn
http://www.geditcom.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to