next up previous
Next: ADDITIONAL FACILITIES
Up: SETTING UP FOR FORMAT CONVERSION
Previous: Resolving Naming Ambiguities

Example: Setting Up a New Format  

The following example shows the C shell commands that might be used on a UNIX system to give NDF-based applications access to a new data format. Typically, commands such as these would appear in a startup file, perhaps packaged as part of a ``driver'' that could be installed to give access to the data format in question:

#  Ensure that the new format and its file extension are recognised on
#  input.
      if ($?NDF_FORMATS_IN) then
         setenv NDF_FORMATS_IN $NDF_FORMATS_IN',NEW(.new)'
      else
         setenv NDF_FORMATS_IN 'NEW(.new)'
      endif

#  Similarly, ensure they are recognised on output.
      if ($?NDF_FORMATS_OUT) then
         setenv NDF_FORMATS_OUT $NDF_FORMATS_OUT',NEW(.new)'
      else
         setenv NDF_FORMATS_OUT '.,NEW(.new)'
      endif

#  Define commands to convert from the new format to NDF format and
#  vice versa.
      setenv NDF_FROM_NEW 'new2ndf in='\'^dir^name^type\'' out='\'^ndf\'
      setenv NDF_TO_NEW   'ndf2new in='\'^ndf\'' out='\'^dir^name^type\'

This example illustrates a couple of points which were not addressed earlier:

1.
We first check to see if the NDF_FORMATS_IN and NDF_FORMATS_OUT environment variables are already defined. If they are, we can append our new format description to them so as not to disturb any definitions already in use. Otherwise we must set them up from scratch.
2.
The environment variable definitions have been written so that single quote characters appear around the names of datasets. For example, the translation of the environment variable NDF_FROM_NEW would be:
new2ndf in='^dir^name^type' out='^ndf'
Although the syntax needed is a bit messy, this does mean that any special characters that appear in dataset names will be handled correctly (i.e. literally), and not expanded by the shell that interprets the command.


next up previous
Next: ADDITIONAL FACILITIES
Up: SETTING UP FOR FORMAT CONVERSION
Previous: Resolving Naming Ambiguities


Starlink System Note 20
R.F.Warren-Smith & D.S.Berry
17th July 2000
E-mail:ussc@star.rl.ac.uk

Copyright © 2000 Council for the Central Laboratory of the Research Councils