TextDocFromTagFile Function Block

Help Contents


The TextDocFromTagFile Function Block creates a TextDocument object from a file associated with a Database Tag.

The function block provides status information to:

Functions and Function Blocks

The TextDocFromTagFile Function Block is intended for use in a Program Tag that runs on the Fernhill SCADA Server. A Program Tag uses a continuous execution model, where the program code runs at a fixed interval. A program uses the function block to sample the state of the SQL Command as it executes.

To create a text document from a file associated with a database tag in an Operator Action, use the TextDocFromTagFile Function.


The TextDocFromTagFile Function Block has this syntax:

        ERRORMSG=>Variable-Reference );

Note: All parameters are optional.


Parameter Type Direction Description
REQ BOOL R_EDGE Input A rising edge triggers the reading of the tag file.
TAGNAME STRING Input The name of the database tag to retrieve the file from. This can be an absolute tag name, or a relative tag name. Relative tag names are resolved relative to the full name of the host program.
FILETYPE STRING Input The type of file to retrieve from the database tag.
BUSY BOOL Output Set to TRUE while the configuration change is in progress.
DOCUMENTID UDINT Output The identifier of the TextDocument Object. Note: This value is only valid while the DONE output parameter is TRUE.
DONE BOOL Output Set to TRUE for 1 execution after the configuration change has completed.
ERROR BOOL Output Set to TRUE if there was an error executing the configuration change.
ERRORMSG WSTRING Output If ERROR is TRUE, the reason why the configuration change failed.


Once the function block starts, additional requests from the input signal REQ are ignored until the configuration change completes.

These timing diagrams show the relationship of the REQ, BUSY, DONE, and ERROR signals processing two requests. The first request completes with an error, the second request completes normally:

        +--------+     +-+ +------+
  REQ   |        |     | | |      |
      --+        +-----+ +-+      +------

        +------+       +------+
 BUSY   |      |       |      |
      --+      +-------+      +----------

               ++             ++
 DONE          ||             ||

ERROR          |       |
      ---------+       +-----------------

The BUSY signal is TRUE while the configuration change is in progress. The DONE signal is TRUE for 1 execution after the completion of the configuration change.

The TextDocFromTagFile Function Block is only available to IEC 61131-3 code in an IEC 61131-3 Program Tag.

To create a TextDocument object in an Operator Action, use the TextDocFromTagFile Function.


  1. Read the contents of a Text Document Tag:
    Program Main
        TextDoc : TextDocFromTagFile;
        Trigger AT %"Trigger Tag" : BOOL;
        DocumentId : UDINT;
            REQ := Trigger,
            TAGNAME := 'Text Document',
            FILETYPE := 'Text' );
        IF TextDoc.DONE THEN
            IF TextDoc.ERROR THEN
                (* Handle the error *)
                (* Get the text document identifier *)
                DocumentId := TextDoc.DOCUMENTID;
                (* Process the data:
                    Use TextDocGetValue() to retrieve values from the Text Document.
                    Use TextDocWriteToUrl() to write the data to an external URL

Further Information

TextDocument Functions

For information about functions to manage TextDocument data objects.

Data Objects

For information about all Data Objects supported by Fernhill SCADA.

IEC 61131-3

To learn how IEC 61131-3 is used in Fernhill SCADA.


For the meaning of terms used in Fernhill SCADA.