12var fileName = fileName ||
"";
13var maxLines = maxLines || 0;
14var statusStateId = statusStateId ||
"";
15var fsWatch = fsWatch ||
null;
16var fLastMod = fLastMod ||
null;
20export
function tail(file, lines = 6)
32 throw new URIError(
"File not found: " + file);
37 fLastMod =
new Date(0);
40 console.info(`Tailing ${lines} lines from ${fileName}
for state ${
DSE.
INSTANCE_NAME}`);
45 fsWatch.fileChanged.connect(checkFile);
52 if (statusStateId !== newStatusStateId) {
53 statusStateId = newStatusStateId;
75 if (!fsWatch.files().includes(fileName)) {
76 if (!
File.
exists(fileName) || !fsWatch.addPath(fileName))
77 throw new URIError(
"Monitored file has been removed");
82 if (fmod.getTime() === fLastMod.getTime())
94 .catch((ex) => {
throw ex; });
104export
function cancel()
122export
function clear() {
void clear(int mode=Mode.Clipboard)
Clears the system clipboard of all values. The opitonal mode argument is used to control which part...
The DSE object contains constants and functions related to the plugin environment....
Definition: DSE.h:50
string INSTANCE_NAME
The the current script's Instance Name, as specified in the corresponding Touch Portal action which i...
Definition: DSE.h:144
string instanceStateId()
Gets Touch Portal State ID of the current script's instance. This is what Touch Portal actually uses ...
Definition: DSE.h:324
DynamicScript instance(String name)
Returns the script instance with given name, if any, otherwise returns null.
Date prototype extension methods
The FSWatcher class provides an interface for monitoring files and directories for modifications.
Definition: FSWatcher.h:87
The File class provides access to... files!
Definition: File.dox:412
string normFilePath(string &file)
Returns the canonical path including the file name, i.e. an absolute path without symbolic links or r...
Definition: File.h:235
bool exists(string &file)
Returns true if file exists; otherwise returns false.
Definition: File.h:194
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:252
< Promise|void > readLinesAsync(string file, int maxLines,< int|undefined > fromLine=0,< boolean|undefined > trimTrailingNewlines,< Function|undefined > callback)
Asynchronously Reads up to maxLines lines from file starting at fromLine (default = 0,...
The global TP namespace is used as a container for all Touch Portal API methods, which are invoked wi...
Definition: touchportal.dox:6
void stateUpdateById(string id, string value)
Send a State update to Touch Portal for any arbitrary state/value matching the id,...
void stateUpdate(string value)
Send a State update to Touch Portal with given value for the current script instance.
void stateCreate(string id, string parentGroup, string description, string defaultValue="", boolean forceUpdate=false, int delayMs=0)
Create a new Touch Portal dynamic State (if it doesn't already exist).