The System object allows access to functions that are global to Tcc or the computer. There is one system object predefined and no declarations are necessary.
The command and status functions warrant some explanation. The main portion of the status bar (at the bottom of the main Tcc window) is shared between command entry and status display. Normally it will display the last message given to the status() method. If the keyboard is used to enter a command then this area shows the command being entered, and backspace can be used in the normal manner. Command entry is completed with ENTER in the usual manner at which time the display returns to showing the status message and the variable commandCount is incremented (to alert the script to the command being available).
Commands are entered whenever keyboard input is not expected elsewhere. So when a cell in a debug window is expecting a value, or the CTC text editor is open the keyboard entry goes to those functions. Otherwise all regular keyboard activity is assumed to be command entry.
Note that to invoke any of these methods you need to prepend 'System.'. So to bring CTC2 to the front you might use System.windowFront (2)
Method |
Use |
windowFront (window) |
Move the specified window in front of other windows. The window parameter can be either a ctc number, or a title string. |
windowBack (window) |
Move the specified window to the back, behind all others. The window parameter can be either a ctc number, or a title string. |
windowShow (window) |
Open the specified CTC window. Presently this method can only open CTC windows, |
windowHide (window) |
Close the specified window. The window parameter can be either a ctc number, or a title string. |
windowSetTitle (window, title) |
Sets the title of the specified window. Note that once you have changed the title of a window future window manipulation methods must use the new title. The window parameter can be either a ctc number, or a title string. |
beep () |
Activate the standard system beep. |
playSound ("filename") |
Start playing the specified sound file. At present there is no mechanism to control volume or stop the sound later. Several sounds can be playing at once. Supported file formats are system dependant. |
x = ctcTag ("meta name")
x = ctcTag () |
Retrieve the numeric, or string value stored against a META name in the ctc file. META names and values must be edited into the ctc file manually. The META names are normally used in ColourTrack, ColourBlock and Switch actions but the associated numeric value might be useful occasionally. The type of return value depends upon the type stored in the file. If a numeric value is stored then a number is returned. If a string is stored then a reference to a temporary string variable holding that string is returned. If no parameter is given retrieve the numeric or string value stored against the cell last clicked in. If no click has been made, or no cell defined, or no meta data defined for the cell then zero is returned. |
x = mouseMeta () |
Returns the meta name of the last CTC cell the mouse was clicked in. If no click has been made, or no cell defined at the location clicked, or no meta data defined then 0 is returned. |
status ("message") status ("message", foregroundColour) status ("message", fgColour, backgroundColour) |
Update the status bar (along the bottom of the Tcc window) to display the "message". This allows the script to indicate problems or its current operational state without relying upon windows being visible. If foreground (and optionally, background) colours are specified then they take effect. If omitted the colours remain what they were previously. |
str = command () |
Retrieve the last entered keyboard command. Use the commandCount variable to discover when a new command has been entered. This method returns a string. |
readCommandFile (filename) |
Opens a disk file and reads it in one line every 500ms. The lines are treated as if each were typed and so are available to System.command () |
log (string) |
Add the string to tcc.log. This always works, regardless of the setting in the configure logging window. |
dumpLog () |
Saves the entire log to date to tcc.log. This clears out the log window which normally retains the last 1000 to 2000 lines. |
x=queryChoice (x, y, question, button, …) |
Create a dialogue window to ask the operator which ONE of a selection of choices to use. The x and y parameters are optional and are percentages of x and y for positioning on the desktop, the default is 50, 50 (centred in the Tcc desktop). Question is a string parameter and is the question you are asking the operator. After the question is any number (at least 1) of button labels which itemise the possible choices. The result (see queryResult below) from a choice dialogue is 1 for the first button, 2 from the second and so on. The window closes when a button is pressed. |
x=querySelect (x, y, question, button, ...) |
Create a dialogue window to ask the operator which of a selection of choices to use. Each selection is a checkbox and any number may be checked and unchecked. The result is a bitmap where the first button has value 1, the second 2, the third 4 and so on. The result is available as soon as the window opens (and is value 0 of course, until some boxes are checked). The window is closed when the OK button is pressed. The optional x & y parameters function as above. This window is limited to 32 selections because Tcc values are 32 bits wide. |
queryBusy (x) |
Test to see if a query dialogue is still visible (still busy). Returns zero if not busy. The optional parameter is a value returned when creating a dialogue, and tests that window. If no parameter is given then the last dialogue opened is tested. |
result =queryResponse (x) |
Fetch the result from the specified dialogue, if available. Undefined if a querySelect dialogue and still open (busy). If no parameter is given then the last dialogue opened is examined. |
n=getTxCount (id) n=getRxCount (id) |
Get the count of transmitted or received messages on the interface 'id'. If 'id' is missing it means the first interface, if a number then 1 means the first interface. Other forms may be added later. Presently the list of interfaces used is the list of running interfaces, not all interfaces. |
setTimeMultiplier (mult) |
The $TIME variable counts time at a speed defined by the mult parameter which is in tenths. So if mult is 10 then $TIME runs normally, 5 would mean half speed and 30 would mean triple speed. |
resetMouse () |
Acknowledges the receipt of the mouse click and clears all the mouse elements. Note that resetMouse should be called in the sale loop as the click was detected – do not insert any wait actions before calling resetMouse otherwise some other click might be acknowledged! |
QkeyColour (keyName, colour) |
Sets the background colour of the named Qkey. |
random (maxValue) random (minValue, maxValue) |
Return a number between minValue (defaults to 0) and maxValue-1 |
traceWhen (matchString, maxWhens) |
Trace the conditions applying to the when statements whose labels match the regular expression matchString. The number of when statements being traced is limited to the number specified (defaults to 10). |
ctcSaveChanges () |
Force the ctc info to be saved when Tcc exits |
Variable |
Use |
commandCount |
Incremented each time a command is entered from the keyboard (and the ENTER key pressed). |
mouseX, mouseY, mouseZ |
The coordinates of the last CTC cell that the mouse was actually clicked in. |
nestZ |
If the cell clicked was nested into another cell, this is the Z of the cell effectively clicked (not the one actually clicked) |
mouseMod |
The key modifiers (which define which button was pressed and which modifier keys (such as shift, alt, control) were held down) when the mouse was last clicked in a CTC cell. |
mouseXYZ, mouseXY |
A compound of the X, Y and Z co-ordinates. This is the same as [mouseX,mouseY,nestZ] except that such a construct is of course presently illegal as it contains variables. |
mouseCtc |
The CtcWindow object where the mouse was actually clicked (uses mouseZ) |
mouseRepeat |
Indicates how long the mouse button has been held down. |
newCtc |
Pointer to a newly created ctcWindow variable when a browser connects and creates a new CTC window. This pointer does not necessarily need to be saved by the script as it is available every time that user clicks. |
numRunning |
The number of when statements that executed on the previous loop. This can be useful for managing response times by only allowing something to execute when not much else is happening. |
realTime |
Not yet implemented |
Tcc supports remote CTC windows connected over http, using perhaps a browser on a mobile phone, tablet or computer. Many such windows can be in use at the same time by a similar number of users, as well as the core CTC windows on the computer Tcc is running on. This causes two problems:
More than one click could be received at the same time.
The script cannot know in advance how many ctc window variables to declare.
As the script can only detect one click at a time, clicks are queued. If several clicks arrive simultaneously they are presented to the script (by setting the mouse* elements listed above) in turn for one script pass (LOOP) only then the next click is presented. If the script actions a click it should call System.resetMouse ()
The solution to declaring variables is that they do not need declaring. When a new window is opened by a browser connecting to port 8080 on the Tcc computer a new ctcWindow variable is created and a pointer to it is placed in System.newCtc Also each time a user click
Last updated 4 June 2017
© Howard Amos 2008-2017