------------------------------------------------------------------------ -- -- Sample AppleScript script for fv 2.6 -- -- This script will open 2 sample files (available online and distributed -- with the fv executables) and displays their contents in several forms... -- header keyword list, a curve, and an image. -- -- USAGE: -- -- Load this file into Apple's "Script Editor" (or similar product) and -- either run it from there or compile it into an application then run it -- from the Finder. fv does not have to be running before running this -- script. -- -- Another version of this script (TclScript.tcl) uses the XPA TCL interface -- which allows other Tcl programs to control fv remotely. -- ------------------------------------------------------------------------ (* IMPORTANT NOTE: Unlike the other script interfaces to fv, AppleScript commands get executed in the global namespace instead of within the particular namespace which holds fv's scripting commands. Because of this, all of fv's commands must be explicitly run inside the "fvCmds" namespace. For individual commands, this just means prefixing the command with the string "fvCmds::". Or, if you have several commands to be run in sequence, you can do "namespace eval fvCmds { put commands here }". *) -- -- Start fv and bring it to the front -- tell application "fv" activate -- -- Set a variable here which points to the fits files to be opened. -- This is just to make it easier to specify files later. -- display dialog "Would you like to open the files via FTP or locally" buttons {"FTP", "Local"} default button "Local" if button returned of the result is "FTP" then set fitsDir to "ftp://heasarc.gsfc.nasa.gov/software/ftools/release/other/pdw/" else set fitsDir to text 1 thru -3 of (path to application "fv" as string) set fitsDir to fitsDir & "sample data:" end if -- -- Open 2 sample files (allow up to 5 minutes in case downloading) -- with timeout of 300 seconds do script "fvCmds::open {" & fitsDir & "ngc1316r.fit} {" & fitsDir & "rate.fit}" end timeout -- -- Select one of the files and open a header window of extension #1 -- do script "fvCmds::select rate.fit" do script "fvCmds::display header 1" -- -- Plot a curve of Time vs Rate in POW and alter the graph's appearance -- do script "fvCmds::display curve 1 time rate" do script "fvCmds::pow bounds 770 -30 1070 300" do script "fvCmds::pow curve pDisp No lDisp Yes lColor Blue" -- -- Select the other file and plot an image, setting its colormap to histogram -- do script "fvCmds::select ngc1316r.fit" do script "fvCmds::display image 0" do script "fvCmds::pow colormap scale histo" end tell