ArborX


tflist

Longname: t f ile list er   Open the Documentation Legend
Released: not available 
Created: not available 

Summary
A general-purpose list getter, tflist can generate lists of files, tags, fonts, and 3B2 tokens.
Example extract

The script below will load all the files in a directory with the specified extension into your document. In this example we use file area's and the .sgm extension. Note the *0 with the tftext macro so the text is not assigned to a particular frame, but loaded into the document:

 ^text_path={my_area}*.sgm 3
 ^blank= 5
 ^tflist= 7
 ^tflistn 9
 tflist "^text_path"^ 11
 :loop_A 13
 ?=^tflist,^blank }exit_script 15
 tft *0,"^tflistn",0,"^tflist","e1"^ 17
 tflist 19
 {loop_A 21
 :exit_script 23
 trun 0 25

Syntax (SVNNA)
tflist Ø
0:L

Get a file list, using wildcards from list as below. This instructs 3B2 to prepare and sort a list of files which match the specified wildcard. It also fills in some pre-defined variables with various parts of the name of the first file in the sorted list.

list_func0:s

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 3
 ^tflistp=C:/3D/ 5
 ^tflistn=SAMPLE 7
 ^tfliste=.3D 9
Example

The script below inserts the names of all files that match the specified wildcard into the current stream:

 ^match=c:/3d/*.3d 3
 ^blank= 5
 tflist "^match"^ 7
 :loop 9
 ?=^tflist,^blank trun -1 11
 @^tflist^tfliste^ 13
 #13 15
 tflist 17
 {loop 19

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:L

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:s Tag types

The variables filled in for you are ^tflist and ^tflistn. These will be the same unless the T code is used, in which case the ^tflist version of the tag name will be preceded by one of the two-character type codes above and a space.

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. The ^tflist version of the tag name will be preceded by one of the two-character type codes above 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

Lists all tags except those from the text or colour classes, but turn on perl scripts, as it is one type from the already turned off.

x

All tags (on)

-

Toggle set mode to off

Xt

Text class (off)

Xc

Colour class (off)

-

Toggle set mode to on

N58

Perl Scripts (on)

 tflist 1,"x-XtXc-N58"
2:L

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 ^tflist and ^tflistn. Subsequent calls to tflist without parameters will return blank strings as there will be only one item in the list.

list_func2:s

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:L

Lists 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:s

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) 5
 ^tflistn=Times 7
4:L

Lists 3B2 tokens from 3B2's ssys.3ad file. At present, the only list value which can be used is 201 which 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:s
201  Get a list of languages.
Example

This simply get a list of supporting languages in 3B2:

 tflist 4,"201"
5:L

Lists 3B2 script variables that are named with a given prefix. This option was originally implemented to list 3B2 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:s

A Wildcard-style prefix for variable names to be listed. That is, the prefix, followed by a single asterisk.

Example

This example will get a list of Arbortext APP area names:

 tflist 5,"_ar_*"
6:L

Get a sub-directory list, using wildcards. This instructs 3B2 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:s

A wildcard name, including a path name if appropriate.

Example

This example will return a list of all the sub-directories off the root of drive C:

 tflist 6,"c:\*.*"
7:L

Lists printers which are available for use with the Windows printer driver. Each subsequent call to tflistwith no parameters will return the next printer name in the same variable.

list_func7:s

Not used with this mode (but needs to be present)

Example

Lists the printers available to the windows printer driver:

 tflist 7," "
8:L

Lists fonts which 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:s
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"

Uses of tflist

The lists that 3B2 prepares for subsequent calls to tflist without parameters share the same space as 3B2's own internal lists. If any macro is issued which causes 3B2 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 which include dialogue boxes, you should note that much of the functionality of tflist can be obtained by adding list boxes to the dialogue 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

Just the path.

^tflistn

Just the filename.

^tfliste

Just the extension.


Document created on 2001-Jan-01 (revision 1)