FIGARO: Command sequences

Keith Shortridge, AAO

13th March 1997

1. Introduction

This document is intended as an introduction to the various techniques that can be used to run pre-programmed sequences of Figaro commands. While you may spend a lot of your time using Figaro interactively, there usually comes a time when you would rather just set some automatic sequence going and come back later. Say you have a sequence of 100 images you want to divide by the same flat field frame. It really isn't a good use of your time to sit at a terminal typing in 100 separate `IDIV' commands. Figaro provides a number of ways of setting up pre-programmed sequences, and this document describes them in what it is hoped is sufficient detail to allow you to make use of them for your own particular problems.

At present, there are two main versions of Figaro available, one for VMS and one for various flavours of UNIX. There is also a version, still being developed, for the Apple Macintosh. As will become clear, the Figaro parameter system provides a number of facilities for generating command sequences; these are more or less the same in all versions, although in some cases (mainly UNIX) care has to be taken to prevent special characters such as `{` from being interpreted by the command language before they are even seen by Figaro. When these relatively simple techniques are no longer sufficient, command sequences written in whatever scripting language the operating system provides must be used, and these differ substantially between the various systems.

Note that not all the facilities described here are available in the now rather out-dated VMS-only versions of Figaro such as 3.0. They refer to the VMS version of the `standalone portable Figaro' system -- which, it must be admitted, doesn't exist at the time of writing, but should soon. In the meantime, VMS Figaro 3.0 has on-line help describing the use of batch sequences -- use `Help Figaro techniques batch'.

2. A simple example

Let's take the case mentioned above of 100 frames to be divided by a flat field. For the purposes of this example, we need to pick on names for the disk files in question, so let's assume they're called `run1', `run2', `run3', etc. up to `run100'. (This regular naming scheme makes some particularly simple sequences possible, and it's usually a good idea to have some such regular scheme.) Say the flat field in question is called `flatfield'. Say we want to put the resulting divided images into new files called `run1_ff', `run2_ff', etc. through to `run100_ff'.

So what we want to do is generate a sequence of Figaro commands:

idiv run1 flatfield run1_ff

idiv run2 flatfield run2_ff


idiv run100 flatfield run200_ff

Let's look at the various ways in which this problem can be solved in Figaro.

2.1 Sequences of parameter values

This is such an easy problem (it's been contrived to be!) that it can be solved in one simple line:

idiv `run{1:100}' flatfield `run{1:}_ff' (UNIX)

idiv run{1:100} flatfield run{1:}_ff (VMS, Macintosh)

(The only difference between the UNIX and VMS commands are that the UNIX shell will normally get in the way and try to interpret the `{` characters for itself. Putting the parameter values in `quotes' prevents that.)

What's happening here is that the `{1:100}' syntax is interpreted as a specification that specifies a sequence of values (1,2,3...100). In this case, Figaro will re-run the command, each time using the next value in the sequence. The same happens for the `{1:}' specification, except that this specifies an open-ended sequence of values which keep on being generated as long as they're needed. (I could just as easily have used `{1:100}' in both cases, but I wanted to demonstrate the two different forms.)

A Figaro feature that you could have made use of here is that you can include the value of one, already evaluated, parameter in the specification of another. The first parameter of `IDIV' is called `image', which you can find out by doing `man idiv' (UNIX) or `help idiv' (VMS). This means that you could have specified:

idiv `run{1:100}' flatfield `{image}_ff' (UNIX)

idiv run{1:100} flatfield {image}_ff (VMS, Macintosh)

since the `{image}' in the specification of the output file will be replaced by the value of the parameter called `image', which has already been set to `run1' or whatever image in the sequence has been reached. Note that this feature is actually making use of the interaction between the parameter system and the `Figaro user variables' maintained by the system. This topic is explored in more detail in the document describing the Figaro parameter system.

2.2 Reading parameter values from files

A solution that takes very slightly more work to set up makes use of the fact that sequences of parameter values can be read from files. If you can get one file -- call it `input.lis' -- that contains all the input file names, one to a line, and a similar file with all the required output file names -- call it `output.lis' -- ie

input.lis output.lis

run1 run1_ff

run2 run2_ff

run3 run3_ff

run4 run4_ff

...etc... ...etc...

then you can give the single line Figaro command:

idiv @input flatfield @output

The `@' syntax tells Figaro to read the values for the specified parameters from the files in question. (The default file extension used for this purpose is `.lis'.)

Of course, you still have the problem of generating the files with the parameter values in them. This usually involves some fancy footwork with directory listing commands and an editor. In this case, you could do:

ls run*.sdf > input.lis (UNIX)

cp input.lis output.lis (UNIX)

or, under VMS:

dir/col=1/nohead/notrail/out=input.lis run*.sdf (VMS)

copy input.lis output.lis (VMS)

which will give you a file `input.lis' that contains all the required filenames. (The examples shown here are for UNIX; under VMS version numbers are included, but this does not affect the example.) There is no easy way to get this effect on a Macintosh, and a script must be used, as described later.






and an identical file called `output.lis'. It should now be easy to fire up your favourite editor to change every `.sdf' in `output.lis' into `_ff.sdf'. You now have

input.lis output.lis

image1.sdf image1_ff.sdf

image2.sdf image2_ff.sdf

image3.sdf image3_ff.sdf


And this is good enough, since Figaro allows you to give the full name of the file in question, including the extension (and version number under VMS) when specifying a parameter. So you can specify `run1.sdf' -- or `run1.dst' if you have .dst files -- instead of just `run1'. (Note that earlier versions of Figaro did not allow this, and would have thought `run1.sdf' meant a `.sdf' structure within a file called `run1.sdf' -- this is not sensible, and this `feature' was eventually made to work more rationally.)

Unfortunately, if your `input.lis' file does have the `.sdf' file extensions included in the parameter values, you can't use the feature mentioned at the end of the last section -- substitution of the value of an already evaluated parameter -- to specify:

idiv @input flatfield `{run}_ff' (Doesn't work!)

since this will generate a sequence of commands that starts:

idiv run1.sdf flatfield run1.sdf_ff

and Figaro is not clever enough to understand the `.sdf_ff' specification for the output file.

2.3 Purely sequential command language scripts

By a `command language script', I mean a sequence of commands in a file that is read by the command language of the system you are using. Under UNIX this is a shell script, under VMS it is a DCL command procedure (a .com file). For the UNIX case, the examples given here are for the c-shell (`csh'), although they can be run by any compatible shell such as `tcsh'. There are advantages to using other UNIX shells for writing scripts (even if you normally use `csh' or one of its kin), but this is not the place for a detailed course on writing UNIX scripts. For the Macintosh you can use a script written in the AppleScript scripting language.

For the problem we have here, the simplest such script is, of course, just the literal sequence of commands you want executing. I describe this as a `purely sequential' script, since it is executed just as a straight sequence of commands, with no looping or conditional constructs used at all. How you produce these files is not immediately obvious, it must be said, and I am not seriously suggesting their use. They are included here mainly to introduce the topic of command language scripts. However, it might be that such a script might be generated by some purpose-written program.

2.3.1 UNIX

Under UNIX you could have a file called, say, `commands' containing

commands (UNIX)

idiv run1 flatfield run1_ff

idiv run2 flatfield run2_ff


idiv run100 flatfield run200_ff

and you could execute it just by using:

source commands (UNIX)

This isn't a true shell script, however, since `source' is just a way of redirecting the input of the command shell. You could be more subtle and produce a true command script such as:

commands (UNIX)


idiv run1 flatfield run1_ff

idiv run2 flatfield run2_ff


idiv run100 flatfield run200_ff

The `#!/bin/csh' indicates that this file is a script to be executed by the `csh' shell. You can make this into an executable file by

chmod +x commands (UNIX)

and can then execute it just by typing its name, ie

commands (UNIX)

One advantage of using a proper shell script like this is that you can run it in the background by appending an ampersand to the command, eg:

commands & (UNIX)

This will keep running even if you log out of the machine completely. If you're going to do this, it would be as well to keep a record of any messages it outputs. You do this by redirecting both ordinary output and error output to a file, say `commands.log'.

commands >& commands.log & (UNIX)

If you are going to walk away from a long job like this, you might consider adding a `nice' command at the start in order to reduce the priority of this unattended job. See `man nice' for more details.

2.3.2 VMS

Under VMS, you can have a file called, say `' which contains the lines: (VMS)

$idiv run1 flatfield run1_ff

$idiv run2 flatfield run2_ff


$idiv run100 flatfield run200_ff

Note that the `$' is needed at the start of each line of a DCL procedure. You can execute this easily enough just by the command:

@commands (VMS)

If you want to run this as a batch job, in the background, you need to remember that this is run as a completely separate program -- not as part of your current login session -- and so needs to be prefaced by various initialisation steps, at a minimum probably including the `figaro' command to define the Figaro commands, and some command to set the proper default directory. Something like: (VMS)


$set def mydisk:[mydirectory]

$idiv run1 flatfield run1_ff

$idiv run2 flatfield run2_ff


$idiv run100 flatfield run200_ff

and you can then set this to run in batch mode using:

submit (VMS)

You probably need to specify the batch queue to use, but you need to discuss this with your system manager. The way batch queues are set up varies from machine to machine, different queues often having different priorities and limits.

2.3.3 Macintosh

One of the best kept secrets of the Macintosh is the existence of the AppleScript system, probably because it came out relatively late in the history of the Macintosh. Although amazingly powerful it is not easy to learn, there being little readily available documentation for it. There are a few books that describe it, and these are worth looking at. The usual main source of computer information, namely other users, is not always useful in this case, since so few Mac users are au fait with the system. If you have a recent version of the Mac OS, you should have a program called ScriptEditor on your system. ScriptEditor provides the Macintosh with that dreaded thing: a command line interface! But it is more than just that; it provides a comprehensive programming language that can interact with applications at a level that can include concepts such as `copy word 1 from paragraph 2 of word processor document such and such to column 1 row 3 of spreadsheet document such and such', if these are supported by the applications being run. You can run this and type command sequences into it, or read them in from text files, and can then execute them by clicking on the `run' button.

The key command for Mac Figaro is `do', which takes a string containing a standard Figaro command as a string argument. You can, for example, enter the following command into ScriptEditor:

tell application "FigaroPPC" to do "idiv run1 flatfield run1_ff"

although for our purposes the following alternative form will be more convenient for longer sequences:

	tell application "FigaroPPC"
		do "idiv run1 flatfield run1_ff"
	end tell
You could, of course, have a long sequence of such commands:

	tell application "FigaroPPC"
		do "idiv run1 flatfield run1_ff"
		do "idiv run2 flatfield run2_ff"
		do "idiv run100 flatfield run100_ff"
	end tell

Note that if you are using the 68K version of Figaro, you need to refer to the application "Figaro68K", unless you have renamed the version for your system to "Figaro", which might be more convenient.

2.4 Iterative command language scripts

A much more sensible solution, particularly in this case, is to write a command language script that makes use of the iterative features provided by the command language. All command languages provide some form of loop control; primitive in some cases, but primitive is good enough to handle our example problem.

Command languages provide command language variables, which can be set to some initial value, incremented, tested against some final value, and whose values can be substituted into commands. That's all that's needed in this case. The syntax for handling command language variables and the loop constructs offered differ from system to system (and from command shell to command shell in UNIX).

2.4.1 UNIX

The `csh' command shell provides command shell variables that are set using the `set' command, are substituted in commands when preceded by a `$' symbol, and which can take integer or character values. Integer arithmetic can be performed through the use of the `expr' expression evaluator, and a number of looping and conditional constructs such as `while', and `if..else..endif' are available.

A solution to our flat field division sequence under UNIX would be a shell script that looks like this:

	#!/bin/csh					(UNIX)
	set i = 1
	while ($i <= 100)
		idiv run$i flatfield run$i_ff
		set i = `expr $i + 1`

While we're looking at what `csh' can do, look at this example:

	#!/bin/csh					(UNIX)
	foreach i (run*) 
		idiv $i flatfield $i

Here, the `foreach' loop runs through once for each file in the default directory that matches the `run*' specification -- and so will find all the ones in our list or `run1.sdf', `run2.sdf' etc. This means that what is executed here is:

idiv run1.sdf flatfield run1.sdf

idiv run2.sdf flatfield run2.sdf


which is almost what we want, except that the operation is being performed in situ instead of generating files with `_ff'. But it is an elegant little script, and it's worth knowing that this sort of operation is easily programmed in UNIX shells.

Note that it doesn't actually matter what shell you are using interactively. Because the script starts with a line identifying the shell that is to run it, this will be executed by `csh' when it is invoked, no matter what interactive shell you are using.

2.4.2 VMS

The DCL command processor used by VMS provides DCL variables that are substituted in commands when enclosed in `quotes', and which can take integer or character values. Integer arithmetic can be performed on them by DCL. An `IF..THEN..ELSE..END' syntax is available, and a simple `GOTO' facility can be used to generate crude loop constructs.

One possible solution to our flat field division sequence under VMS would be a DCL procedure that looks like this:

	$ I = 1					(VMS)
	$ LOOP:
	$	I = I + 1
	$	IF (I LE 100) GOTO LOOP

2.4.3 Macintosh

The command string passed to the Figaro application can be a string variable in the AppleScript command language, and this can be manipulated using the various string handling functions provided by AppleScript. You can also have integer variables that can be used in some quite sophisticated looping constructs. A simple script that generates our flat field division sequence might be:

	repeat with Counter from 1 to 100
		copy Counter as string to Cstring
		copy "idiv run" & Cstring " flatfield run" & Cstring 
                                                        & "_ff to Command
		tell application "FigaroPPC" to do Command
	end repeat

In this script, the string concatenation operator `&' is used to generate the command strings, and the `copy ... as ...' construct is used to convert the loop variable Counter to a character string that can be used in the concatenation.

2.5 Callable Figaro

One further option is to use the `Callable Figaro' system. In this case, you write a Fortran program that makes repeated calls to a subroutine called `Figaro' in each case passing it a new Figaro command to execute. This has the advantage that it involves programming in a language that most Figaro users are familiar with, and the disadvantage that it requires a deal of character string manipulation in Fortran to generate the required Figaro command strings. However, this is made as easy as possible by the `Callable Figaro' system.

Here is a `Callable Figaro' program, called `commands.for', that handles our flat field division example:

	DO I=1,100
		CALL FIGARO (`idiv run//', CI(I),
     :				'flatfield run//' CI(I), `//_ff')
The `figaro' subroutine can take any number of arguments, and it normally makes each one a separate word in the Figaro command it forms from these arguments. The concatenation symbol `//' is used to force arguments to be concatenated into one word instead of being kept separate. The routine `CI' takes an integer and returns it as a formatted string. Note that all the arguments to `Figaro' have to be character strings, so integers have to be formatted using `CI' -- which is part of the Callable Figaro system, as are its floating point and double precision counterparts `CF' and `CD'.

Running this program in the file `commands.for' is made easy by the `figlink' command.

figlink commands

will compile and link `commands.for' and will also define `commands' in such a way that it becomes a command recognised by the command language, so that


is all that is needed to run the program. This is the case for both UNIX and VMS versions of Figaro.

3. User variables

Most Figaro sequences make use of `Figaro user variables'. These are named, global, variables that can be character strings, single floating point numbers, or arrays of numbers. They are made use of in various ways in Figaro.

* Some Figaro programs set specific user variables to record the results they have obtained. For example, the cross-correlation program `scross' records the shift it calculates in a user variable called `shift'.

* Some Figaro programs make use of specific user variables. For example, `icur' needs to know the details of the display put up by `image'. `Image' sets these details in a set of user variables that all begin with `tv..', and `icur' reads these as soon as it starts up. If points are selected using `icur', these are recorded in arrays called `xpixels' and `ypixels' and these are used by `sdist' as starting points for its S-distortion mapping.

* When the Figaro parameter system evaluates a parameter, it immediately sets the parameter value into a user variable with the same name as the parameter. It will then usually use this as the default value for the parameter when it is needed again.

* The parameter system can accept the name of a user variable in most places it would accept a literal value. It can also evaluate expressions involving numeric user variables. This is what was going on in the earlier example

idiv `run{1:100}' flatfield `{image}_ff' (UNIX)

where the `{image}' appearing in the third parameter is the user variable `image' which has been set by the parameter system to the value used for the first parameter (which is called `image').

* The `vshow' command can be used to list the values of all or a selection of the user variables.

* `Let' can be used to set user variables to specified values, and these values can themselves be expressions involving user variables and constants. It can also be used to set command language variables.

As an example of user variables in action, the following sequence runs `istat' on one of our `run' images. `Istat' sets the user variable `stat_mean' to the mean value of the data in the image. This is then used in the subsequent `icsub' command which subtracts this value from the image.

istat run1 reset \\

icsub run1 stat_mean run1

For a more complex example, somewhat contrived, assume you wanted not to use the mean value of the data but some value half way in between the mean and the median. `Istat' calculates a median value if the `median' keyword is specified, and sets the user variable `stat_median' to the result.

istat run1 median reset \\

icsub run1 `{(stat_mean+stat_median)/2}' run1 (UNIX)

(The VMS version omits the `quotes' around the {braced expression}.)

That example used the parameter system to perform the evaluation for you. If you want the mean-median average value saved for later use, you could use `let' to do the calculation, setting a user variable `med_mean' to the value used.

istat run1 median reset \\ (UNIX)

let `med_mean={(stat_mean+stat_median)/2}`

icsub run1 med_mean run1

or under VMS:

istat run1 median reset \ (VMS)

let med_mean={(stat_mean+stat_median)/2}

icsub run1 med_mean run1

4. Setting and using command language variables

Suppose in the previous example that you wanted to make use of the median value in your command language script. For the sake of making our example simple, let's assume that all we want to so is output its value to the user. The various command languages all have ways of doing this, once you have the value in question in a command language variable. The way you do this, of course, varies from system to system. Both VMS and UNIX make use of the Figaro LET command for this purpose, although the UNIX syntax is a little convoluted. The Macintosh system provides a special command, `vget' for this purpose.

Under VMS using the LET command with an ampersand in front of the name of a variables makes LET set a command language variable rather than an internal Figaro user variable. For example, if we want to get the value of the Figaro user variable `med_mean', we do:

let &value_used = med_mean (VMS)

write sys$output "Value of med_mean was ",value_used

under UNIX, the LET command is also used. If it is used to set a variable with an ampersand in front of its name it does not in fact set any variable; instead it outputs the value to standard output. (This may seem an odd convention; it comes from an attempt to look like the older VMS syntax, but on a system where an application cannot directly set command language variables). This can then be combined with the use of back quotes to run a command and put the output from that command into the command line, in this case as part of a `set' command. Unfortunately the ampersand itself needs to be escaped with a preceding backslash or it will be interpreted by the command language rather than being passed on to Figaro. The resulting sequence looks like:

set value_used = `let \&value_used = med_mean` (UNIX)

echo Value of med_mean was $value_used

On the Macintosh, Figaro supports a `vget' command that can be used to obtain the value of a Figaro variable. The example below then inserts this into a dialogue box with a single `OK' button.

tell application "FigaroPPC" (Macintosh)

copy (vget "med_mean") to value_used

end tell

display dialog ("Value of med_mean was " & value_used as string)

buttons {"OK"} default button "OK"

Note that most command languages provide only limited operations on floating point numbers. If you need, for example, to make a test on a floating point number you may find yourself forced to use Figaro to do the test -- since the parameter sysyem's expression handler does work in floating point -- and set a Figaro variable to indicate the result. For example, if you wanted to test whether the value of `med_mean' was more than 0.5, you could get it into a command language variable as shown above, but the command language might not then be able to test this against a flotaing point number. You would do better to do the test in Figaro, as follows:

The basic command is:

let test_value = {med_mean>0.5}

This sets the Figaro variable `test_value' to 1 if `med_mean' is greater than 0.5 and to zero if it is not.

(Note that in UNIX the use of special chartacters such as `{` and `}' means either that each such character has to be escaped, or the whole expression has to be enclosed in double quotes. So either of

let "test_value = {med_mean>0.5}"

let test_value = \{med_mean>0.5\}

will do.)

Having got a simple integer value to use in this way, you can then get its value into a command language variable as shown previously and can test this in the command language.

5. The FIGSET command

In a command script some systems will allow you to change the default directory directly through the command language. This is very useful in a script, since one often wants to switch over to a different directory in the course of a command sequence. Even more common is the case where the command script is in the default directory but the data files on which it is to operate are in another directory. In this case the first line of the command script is often one that changes the default directory.

Under VMS one simply uses the command


Similarly, under UNIX one uses the `cd' command, or example

cd /Disk/Directory/SubDirectory

However, there are cases where the command language cannot be used for this purpose. If your are running a Callable Figaro program, for exmple, the command language is simply not being used. If your are running a Macintosh script, each program has its own default directory. which needs to be set individually. For these cases, there is a Figaro command `FIGSET'. This can be used to set the default directory as follows:

figset default directory_specification

where `directory_specification' is a string specifying a directory in whatever format is needed by the system on which it is running.

6. Choosing between the options

The previous sections gave a brief overview of how to generate a sequence of `idiv' commands, using a number of different techniques available under Figaro. The question that needs to be answered, for each particular problem that arises, is `which one should I use?'. In many cases, of course, the best answer is to use whatever you happen to be familiar with, even if it isn't the most efficient. Still, there are a number of considerations that need to be borne in mind.

One is that the options that involve being clever with repeated parameter values, whether read from a file or generated as part of an interactive specification such as `{1:100}', can only be used if it is the same Figaro command that is to be constantly repeated. If you want to run a sequence with more than one command involved, you will probably not be able to do it using repeated parameter values and will have to use one of the other options.

Callable Figaro provides the advantage of programming in a language you are probably already familiar with, namely Fortran. However, it has the disadvantage that it is harder to include normal UNIX or VMS commands in the program you write. If you suddenly want to change the directory you're in, for example, that gets more complicated than just inserting a `cd' (UNIX) or a `set def' (VMS) into a command language script. On the other hand, it is just the environment you want to be in if you are planning on complicated arithmetic operations in the middle of your program -- doing something clever with the shifts calculated by `scross', for example to wrap up an automatic focus procedure. Callable Figaro is much faster than a command language script. This is less true under UNIX than under VMS, but it can still be significant.

If you are already good at UNIX shell programming, or at writing VMS DCL procedures, that will be the obvious way to go. However, note that a DCL procedure written for VMS will not run without substantial modification under a UNIX shell, and vice-versa. Shell programming is a somewhat arcane art, whether you are using UNIX shells (any on them!) or DCL.

Don't forget that the various options can be combined. If you have a Callable Figaro program, you can run it as part of a command language script. Command language scripts or calls in Callable Figaro can make use of the iterative features of the Figaro parameter system, or can specify files as sources of sequences of parameter values.

7. Finding out more

This has been a very brief introduction to the subject of Figaro sequence programming. More details about the parameter system can be found in the document `The Figaro parameter system', which goes into considerable detail about the way repeated sequences of parameter values can be generated from expressions or from files.

The `let' command has a whole section to itself in the `Figaro Techniques' document.

`Callable Figaro' has a whole document to itself, in which it is described in considerable detail.

Programming using UNIX shells is the subject of a number of books. Most of them concentrate on the Bourne shell (`sh') rather than `csh' as used here. However, there is no reason not to use `sh' if that is what you prefer to program with, even if you use `csh' or one of its releatives interactively. There was no particular reason -- other than habit -- for using `csh' in the examples here. The on-line help you get from `man csh' or `man sh' is of limited use -- what you really need are good examples. Programming DCL command procedures is described in detail in the VMS manuals.

8. Appendix: Applescript

AppleScript is described in a number of books. I learned it from `The TAO of AppleScript' by Schneider, Hansen and Holmes (Hayden Books, 1994. If you have an older system -- older than System 7.5, I believe, you may not have AppleScript on your system; most books also come with a copy on floppy or CD-ROM. A lot of the power of the system comes from the way it interacts with the Finder, but to make use of this you need the later versions of the Finder that supported scripting. If you have an older version you can either get the new one or use something like the `Finder liaison' application included in `The TAO of AppleScript'.

As an example of a script that combines Figaro and the finder, and to whet the appetite, I append the following sample program:

-- This example script  runs through all the .sdf files in a 
-- specified folder. For each file, it puts up a dialogue box 
-- with "OK" and "skip" buttons. If the "OK" button is selected
-- the script does a Figaro "exam" command on the file in question.

-- Set the name of the folder in question, and set it as 
-- the Figaro default folder using the Figaro "Figset default"
-- command

copy "Macintosh HD:Scrap" to FolderNameString
copy "figset default \"" & FolderNameString & "\"" to Command
tell application "FigaroPPC" to do Command

-- Get all the files in the folder into FileList

tell application "Finder"
	copy (a reference to folder FolderNameString) to FolderName
	copy (get files in FolderName) to FileList
end tell

-- Run through each file in turn. If it ends with .sds, clip 
-- off the folder part of name and put up a dialogue for it.
-- If accepted, generate and issue a Figaro "exam" command.

repeat with CurrentFile in FileList
	if CurrentFile ends with ".sdf" then
		set FileName to ClipFileName(CurrentFile)
		copy (display dialog "File " & FileName buttons
			 {"OK", "Skip"} default button "OK") to DialogResults
		if the button returned of DialogResults is "OK" then
			copy "exam \"" & FileName & "...\"" to Command
			tell application "FigaroPPC" to do Command
		end if
	end if
end repeat

-- -----------------------------------------------------------------

-- This subroutine, ClipFileName, takes the full path name of 
-- a file and the file name, ie with the folder specification removed. 
-- (In this script we don't have to do this, since we could use
-- the full file names, but it looks messy to have them in
-- the dialogues.

on ClipFileName(CurrentFile)
	copy CurrentFile as string to CurrentFileName
	copy the number of characters in CurrentFileName to NameLength
	repeat with I from 1 to NameLength
		if item I of CurrentFileName is ":" then
			set NameOffset to I
		end if
	end repeat
	set FileName to (characters (NameOffset + 1) thru
					 (NameLength) of CurrentFileName)
	return FileName
end ClipFileName