![]() To achieve this goal, many scripts will have an option to be on the entire file or on just the selected records. But, it can be helpful to focus a report on a subset of your file. You will often want to run reports on your entire file. This script also requires version 1.5 or newer of GEDitCOM II (because it uses some commands first defined in version 1.5) you can verify version number when the script is packaged into an extension. This script, for example, requires a document to be open. The subroutine returns 1 if it is OK to proceed or 0 to exit. All the work is done in the CheckAvailable() subroutine (see utility subroutines). The first step is to verify it makes sense to run this script. This approach will make parts of your script more reusable in other scripts. Any place you need to refer to the script by name, use this variable rather than literal text of the name. The scriptName holds the name of the script. These commands load modules needed to allow Ruby scripts to interact with GEDitCOM II. The Prepare to use section must start all Ruby scripts. If you share your scripts with other GEDitCOM II users or revisit a script written a while ago, these comments can document use of the script. It is a good idea to start all scripts with comments. The script starts with comment lines beginning in "#". This section describes the logic of the main script. Listing 1 shows the entire main script, although crucial components of the script are done in subroutines that are given below. # Collect all report data in a subroutine # No report if no family records were found # Get of list of the chosen family records "Get report for All or just Selected family records",\ WhichOnes = erOptionTitle_buttons_message_(\ # choose all or currently selected family records # verify document is open and version is acceptable Gedit = OSX::SBApplication.applicationWithBundleIdentifier_(\ # Define the script name in a global variable # Prepare to use Apple's Scripting Bridge for Python # spouses in the currently selected family records. # The report can be for all spouses in the file or just for # when they got married and when their children were born. # This script generates a report of average ages of all spouses The details for packaging scripts in extensions are provided in the GEDitCOM Editor help. The tutorial still works, but when creating your own reports and is preferrable to package the scripts in an extension. This tutorial was written prior to GEDitCOM II, version 2.0 where scripts were converted to extensions. Downloadable Script: Generation Ages to Report (Ruby).When you are done this tutorial, you should be able to create your own custom reports using Python by changing the type of data collected and the format of the output report. ![]() The report output is to a built-in GEDitCOM II report. It reproduces the AppleScript report using the Ruby language. This tutorial describes a report that will read data in your file and calculate the average age at which males and females were married and the average age of fathers and mothers when their children were born.
0 Comments
Leave a Reply. |