UserProfileOpsDoc.tioga
Copyright (C) 1985, Xerox Corporation. All rights reserved.
Package: UserProfileOps
Maintainer: Lamming
Date: June 28, 1985 1:42:42 pm PDT
DF file: UserProfileOps.df
Purpose: Generate list of filenames from template and user.profile
Description:
This interface is designed to allow clients to generate a list of filenames from a template. Its main purpose is to overcome the difficulty of generating filenames to meet local naming conventions. This is to compensate for our inability to agree on a standard!
For example, a problem occurs with AIS separation files. Normally AIS filenames conform to the template <FileStem>-<SeparationFlag>.<AISExtension>, e.g. foo-grn.ais. Even so at least two different SeparationFlag naming conventions exist and at least two AISExtension naming conventions. For example, one client will use the flag "grn" to name the green separation, another "g" and a third "green". When these options are permuted with the AISExtension naming conventions ".pic", ".ais", ".image", 9 file names are possible.
The procedure Expand provides a simple way of specifying a template containing keys that are to be replaced by ropes extracted from the user.profile. The format rope conforms to the protocol used by the formatting routine PutF in IO. (See IODoc.tioga). In its simplest form Expand can be used like PutFR to generate a single rope from the format rope and the IO.Values: v1..v5. Note that Expand actually returns a list of length 1.
e.g. Expand["File%g.ext", IO.real[99]] => "File99.ext"
To use the user.profile substitution feature a special format sequence introduced by %k is used. The general form of this format sequence is:
%k<c><UserProfileKey><c><Default><c>
where:
<c> is any character used to delimit the following sequences of characters
<UserProfileKey> is a user.profile key as specified by UserProfileDoc.Tioga
<Default> is a default sequence to be used if no corresponding key is found
So the example described earlier would be handled as follows:
list ← Expand["%g%k|AISseparationKeys.green|red|.%k|AISExtensions|ais|", IO.rope[fileStem]]; 
The user profile would be searched for the keys: "AISseparationKeys.green" and "AISExtensions" and every possible permutation of ropes returned. 
If the user profile contained the entries:
AISseparationKeys.green: "-grn" "-green" "-g"
AISExtensions: "ais" "pic" "image"
and fileStem = "Foo", then
list ← ("Foo-grn.ais", "Foo-grn.pic", "Foo-grn.image", "Foo-green.ais", "Foo-green.pic", "Foo-green.image", "Foo-g.ais", "Foo-g.pic", "Foo-g.image")
Note that the first name in the list is built from the first options of each user.profile key. This is handy for creating new files in the locally preferred format. 
If neither key had been present in the user.profile then
list ← ("Foo-red.ais")