Macro Language Reference > Macros > Document > tfread
  
tfread
Description
Reads document or entity comments from another document. The comment to be read should take the form of a set of variable definitions which begin with a ^ character. These are then used to set the values of script variables.
Syntax
tfread mode:n? filename:s?
mode
Ø|0
Read the document comment from filename
1
Read the first entity comment from filename
filename
The name of the file that contains the comments
Additional Information
The tfread macro provides the facility to examine a set of variables that have been stored with a document or saved entity (tag) so that decisions can be made about the file, for example whether or not to open it.
The set of variables to be stored is placed in the file's document comment (or in a comment stream for the case of a saved entity) as a sequence of ^var_name= value operators. The tfread macro opens the file and finds the document comment (or first tag comment). All lines that begin with ^ are added to the current macro queue, thereby causing all the variables to be set to the stored values.
Nothing happens if tfread does not find the correct comment type or if it contains no variables. This means that all existing variables will remain unchanged. It is therefore a good idea to set all variables of interest to a known value (usually blank) before calling tfread. It will then be much easier to detect that the file did not contain the required variables.
 
The tfread macro is most useful when combined with the tflist macro. Each file could be examined in turn to find a particular set of criteria before a file is opened. Document comments can be added to any document with the tdcom macro. Tag comments are added with the tcom macro. When the tag is saved its comment stream is automatically saved with it. Frame comments added with tfcom are not automatically read by the tfread macro.
Related Links