Macro Language Reference > Macros > Script > tflist
  
tflist
Description
A general-purpose list getter, tflist can generate lists of files, tags, fonts and PTC ALD tokens.
 
Example 188. Load all files with specified extension into current document
The script below will search a particular directory and load all the files with a specified extension that it finds there into your document. In this example, certain file areas and the .sgm extension are defined as the parameters. Note the use of *0 with the tft macro to ensure the text is not assigned to a particular frame, but loaded into the current document:
^text_path={my_area}*.sgm
^blank=
^tflist=
^tflistn
tflist "^text_path"^
:loop_A
?=^tflist,^blank }exit_script
tft *0,"^tflistn",0,"^tflist","e1"^
tflist
{loop_A
:exit_script
trun 0
Syntax
tflist 0:L list_func0:s
tflist 1:L list_func1:s
tflist 2:L list_func2:s
tflist 3:L list_func3:s
tflist 4:L list_func4:s
tflist 5:L list_func5:s
tflist 6:L list_func6:s
tflist 7:L list_func7:s
tflist 8:L list_func8:s
tflist
0
Get a file list using wildcards from list as below. This instructs PTC ALD to prepare and sort a list of files which match the specified wildcard. It also fills in some predefined variables with various parts of the name of the first file in the sorted list.
list_func0
A wildcard filename, including a path name if appropriate.
Example: If the file c:/3d/sample.3d were next in the list, the tflist macro would set up the following variables:
^tflist=C:/3D/SAMPLE.3D
^tflistp=C:/3D/
^tflistn=SAMPLE
^tfliste=.3D
Example: The script below inserts the names of all files that match the specified wildcard into the current stream:
^match=c:/3d/*.3d
^blank=
tflist "^match"^
:loop
?=^tflist,^blank trun -1
@^tflist^tfliste^
#13
tflist
{loop
Similar techniques of looping are frequently used with tflist since it is only very rarely that you actually want the first item in a list to be listed.
1
Get a list of document tags, as specified by one or more options from list below. Each subsequent use of tflist with no parameters will return the next item in the same two variables.
list_func1
The variables filled in for you are ^tflist and ^tflistn. These will be the same unless the T code is used, in which case in ^tflist each tag name will be preceded by a two-character type code (extension) and a space. Please refer to the Reference Chapter: PTC ALD tag types for details of tag extension codes.
Example: If the code used was xT, and the next item in the list is a style tag called body, the ^tflist variable will contain St body and the ^tflistn variable will contain body.
If the T code was not used then both variables would just contain body. The list is always sorted by the contents of ^tflist, so using the T code causes tags to be sorted by their type first.
The example below gets a list of style tags:
tflist 1,"s"
Example: The example below gets a list of all tags, together with their extensions. In ^tflist each tag name will be preceded a two-character type code and a space.
tflist
1,"xT"
Example: Tag types can be combined, e.g. the example below gets a list of reference and text streams, together with their type code:
tflist 1,"rtT"
Example: List all tags except those from the text or color classes, but turn on Perl scripts, as it is one type from the type already turned off.
tflist 1,"x-XtXc-N58"
x
All tags (on)
-
Toggle set mode to off
Xt
Text class (off)
Xc
Color class (off)
-
Toggle set mode to on
N58
Perl scripts (on)
See the section Options for tflist below for further details about the options that can be included in a list request of this type.
2
Generate an original tag name by appending ascending numbers to the part of the name you supply until a name that does not already exist is found. This name is then entered into a list that contains only one item. The unique tag name will be returned in both the ^tflist and ^tflistn variables.
 
Subsequent calls to tflist without parameters will return blank strings as there will be only one item in the list.
list_func2
The part of the tag name to be used as a 'prefix'.
Example: The example below generates a unique tag name starting with og, for example og1. If og1 already exists, then og2 might me returned, and so on.
tflist 2,"og"
3
List installed fonts. Each call to tflist returns a font's long name in the ^tflist variable and its short name code in the ^tflistn variable. Each subsequent call to tflist with no parameters will return the next item in the same two variables.
list_func3
Get a list of typefaces. This is the only string parameter available in this mode.
Example: There is only one possible example, because the string parameter never varies. This gets a list of installed fonts:
tflist 3,"t"
Suppose the next font in the list was Times, these assignments would be made:
^tflist=Times rm (Monotype)
^tflistn=Times
4
List PTC ALD tokens from PTC ALDssys.3ad file. At present, 201 is the only list value which can be used and it returns a list of languages. Each call to tflist returns a language name in both the ^tflist and ^tflistn variables. Each subsequent call to tflist with no parameters will return the next item in the same two variables.
list_func4
201
Get a list of languages
Example: This gets a list of supporting languages in PTC ALD :
tflist 4,"201"
5
List PTC ALD script variables that are named with a given prefix. This option was originally implemented to list PTC ALD file area names that use the prefix "_ar_". Each call to tflist returns a variable name in both the ^tflist and ^tflistn variables, with the given prefix removed. The name in the ^tflist variable will also have curly brackets around it. Each subsequent call to tflist with no parameters will return the next name in the same two variables.
list_func5
A wildcard-style prefix for variable names to be listed: the prefix, followed by a single asterisk.
Example: This example will get a list of Arbortext PTC ALD area names:
tflist 5,"_ar_*"
6
Get a sub-directory list, using wildcards. This instructs PTC ALD to prepare and sort a list of sub-directories which match the specified wildcard. Each call to tflist returns a sub-directory name in the ^tflist variable, without a preceding path name. Each subsequent call to tflist with no parameters will return the next name in the same variable.
list_func6
A wildcard name, including a path name if appropriate.
Example: This example will return a list of all the sub-directories from the root of drive C:
tflist 6,"c:\*.*"
7
List printers available for use with the Windows printer driver. Each subsequent call to tflist with no parameters will return the next printer name in the same variable.
list_func7
Not used with this mode (but needs to be present)
Example: This example lists the printers available to the Windows printer driver:
tflist 7,""
8
List the fonts that have been used in the current document. Each call to tflist returns a long or short font name in the ^tflist variable. Each subsequent call to tflist with no parameters will return the next name in the same variable.
list_func8
l L
Get a list of long font names
s S
Get a list of short font names
Example: This example provides a list of long names of fonts which have been used in the current document:
tflist 8,"L"
Additional Information
Uses of tflist
The lists that PTC ALD prepares for subsequent calls to tflist without parameters share the same space as PTC ALD own internal lists. If any macro is issued which causes PTC ALD to regenerate a list (e.g. for a menu selection, or the style list) then the previously prepared list will be overwritten. Subsequent calls to tflist would therefore give undefined results.
The main use of tflist is in user-written scripts. If you are writing scripts that include dialog boxes, you should note that much of the functionality of tflist can be obtained by adding list boxes to the dialog box.
Depending on which mode parameter is used, up to four variables are automatically filled in, which can then be manipulated within a script. The variables that are automatically filled in on each call are as follows for mode 0:
^tflist
The entire file name (with path)
^tflistp
Path only
^tflistn
Filename only
^tfliste
Extension only
Options for tflist
x
All tags (on)
-
Toggle the set mode. The first occurrence of the option toggles to off, the second to on, and so on.
N[umber]
List tags by number. For example tflist 1 "N1N62" lists all styles and overlays. For a full list of tag type numbers, please refer to Reference Chapter: PTC ALD tag types.
.ext
List tags by extension (e.g. .st, .rf, .po). For example: tflist 1 ".st.pu" lists all styles and overlays. For a full list of tag type extensions, please refer to Reference Chapter: APP tag types
X[number]
List tags by stream class:
0 (t = text class)
1 (o = object graphic tag)
2 (r = raster graphic tag)
3 (p = page associated tag)
5 (m = bookmark)
6 (f = font)
7 (n = namespace)
T
Include type code before name in ^tflist. As an example, the body style in a list of styles will appear as St body.
E
Include type code after name in ^tflist. As an example, the body style in a list of styles will appear as body St.
For more information, see Reference Chapter: Tag Types.