PsiFS: File Format Converters

!ChangeFSI Example

!ChangeFSI Example

An example file format converter configuration for !ChangeFSI has been included in the directory !PsiFS.Converters.!ChangeFSI. This allows common graphics formats (GIF, PCX, BMP, PBM, JPEG, TIFF, and Sprite files) to be converted to either Sprite or JPEG files with a selectable number of bits per pixel and processing options.

The following sections describe each of the files within the sub-directory.

!PsiFS

The !PsiFS file tells PsiFS all of the important characteristics of the file format converter.

The first section of the file sets default conversion options for all of the supported file types. This is followed by a separate converter configuration for each output format. Note that both of the converters in this example support the same input file types, so these are defined once within the shared characteristics section.

The PsiFSChangeFSI alias defined within the !Boot file is used to perform all of the conversions, with additional parameters specifying the required behaviour.

The command line argument to !ChangeFSI used to specify the output file format is not prefixed by a "-" (minus-hyphen), so the arguments supplied by PsiFS need to be modified. To allow easy manipulation within the !Run file requires this argument to be in a fixed position. This is achieved by relying on the sorting order: options starting with numbers or upper case letters are always placed before options starting with lower case letters.

!PsiFSRes

The !PsiFSRes file contains the two toolbox templates used to select the conversion options.

Radio buttons are used to allow selection of a single output format. A String Set gadget could have been used for the same purpose, but the returned arguments would have required greater pre-processing to convert them into a suitable form for passing to !ChangeFSI.

!Boot

The !Boot file is run by PsiFS at start-up using Wimp_StartTask.

This starts by defining the textual version of all the supported file types to ensure that the !PsiFS file can be correctly parsed. Next, the file format converter is registered by defining the system variable PsiFSConverter$ChangeFSI to point to the current directory. Finally, an alias for PsiFSChangeFSI is defined to run the !Run file, enabling simpler commands to be used within the !PsiFS file.

!Run

The !Run file is run by PsiFS using Wimp_StartTask when the converter is called via the PsiFSChangeFSI alias.

It starts by checking that it has been supplied with parameters and ensuring that there is sufficient memory to run ChangeFSI. If necessary, the FindFSI BASIC program is then used to locate !ChangeFSI if has not already been seen by the filer.

A temporary alias Alias$PsiFSChangeFSITemp is used to allow easy manipulation of the arguments to remove the "-" (minus-hyphen) from the output format specifier. Finally, the ChangeFSI executable is run to perform the required conversion, and any error is reported.

FindFSI

The FindFSI file is a simple BASIC program that searches for !ChangeFSI in likely locations. If a copy is found then its !Boot file is run to set the necessary system variables.

This program is only required because the file format converter is not contained within the same directory as the configuration files.


[Contents] [Up] Copyright © Alexander Thoukydides, 1998, 1999, 2000