Parent Previous Next


var fileResult = TW.readFile("path/to/file.txt");

       relative paths are taken to be relative to the folder containing the
       executing script's file

The return value fileResult is an object (a map) with three member properties.

(You can use any valid variable name and not just fileResult)

status, result, and message




gives you the status code (same as for writeFile).

Upon success       res.status == 0

See Return Values for Status


       fileResult.result  contains the text of the file.

This would be   undefined   if there is no content.


fileResult.message will have one of the following responses in it:

      1. "Reading all files is disabled (see Preferences)"
      2. "The file \"%1\" could not be opened for reading"

And upon successful reading of file content:

      1. undefined


In lua,  fileResult.status

And so on.


In Python, the members are accessed as a dictionary   fileResult['status']

And so on.


There is a setting for 'reading' permissions in the preferences dialog.

By default, global reading is disabled.

Files in the folder containing the

current script (e.g., <resources>/scripts/test/) and its sub folders are

always readable, as are files in the folder containing the current

target (tex/pdf) file's directory, its root (master) file's directory (if

used), and their sub folders.

Reference:        Stefan Löffler

                 Stefan Löffler

               cpp                TWScriptAPI::readFile

Created with the Personal Edition of HelpNDoc: Full featured Documentation generator