11var fileName = fileName ||
"";
12var maxLines = maxLines || 0;
13var statusStateId = statusStateId ||
"";
14var fLastMod = fLastMod ||
new Date(0);
15var timerId = timerId === undefined ? -1 : timerId;
20export
function tail(file, lines = 6, interval = 1000)
27 throw new TypeError(`Invalid arguments
for 'tail(${file}, ${lines}, ${interval})' with
instance name ${
DSE.
INSTANCE_NAME}.`);
32 throw new URIError(
"File not found: " + file);
38 fLastMod =
new Date();
40 timerId = setInterval(checkFile, interval);
47 if (statusStateId !== newStatusStateId) {
48 statusStateId = newStatusStateId;
58 console.info(`Tailing ${lines} lines from ${file} every ${interval}ms
for state ${
DSE.
INSTANCE_NAME} with timerId ${timerId}`);
75 if (fmod.getTime() === fLastMod.getTime())
96export
function cancel()
100 clearInterval(timerId);
104 console.info(`Stopped tailing ${fileName}
for state ${
DSE.
INSTANCE_NAME} with timerId ${timerId}`);
The DSE object contains constants and functions related to the plugin environment....
String INSTANCE_NAME
The the current script's Instance Name, as specified in the corresponding Touch Portal action which i...
Definition: DSE.h:161
String instanceStateId()
Gets Touch Portal State ID of the current script's instance. This is what Touch Portal actually uses ...
Definition: DSE.h:337
DynamicScript instance(String name)
Returns the script instance with given name, if any, otherwise returns null.
Date prototype extension methods
The File class provides access to... files. Shocking.
Definition: File.h:58
Date mtime(String &file)
Returns the date and local time when the file was last modified. If the file is not available,...
Definition: File.h:242
bool exists(String &file)
Returns true if the file exists; otherwise returns false.
Definition: File.h:192
String readLines(String &file, int maxLines, int fromLine=0, bool trimTrailingNewlines=true)
Reads up to maxLines lines from file starting at fromLine (default = 0, start of file) and returns th...
Definition: File.h:119
The global TP namespace is used as a container for all Touch Portal API methods, which are invoked wi...
Definition: touchportal.dox:7
void stateCreate(String id, String parentGroup, String desc="", String defaultValue="")
Create a new Touch Portal dynamic State (if it doesn't already exist).
void stateUpdate(String value)
Send a State update to Touch Portal with given value for the current script instance.
void stateUpdateById(String id, String value)
Send a State update to Touch Portal for any arbitrary state/value matching the id,...