A (possibly incomplete :-) list of actions that may be used in scripts.

This list contains a mixture of basic actions such as 'Draw Image', object methods such as 'ctc.ctcSetTitle ()' and some object instance variables such as 'qtu.adcCur'.

Where a period exists in a name like these last two examples it means that the method or instance variable is part of an object of the type given before the period.

Where parentheses and possibly a list of parameters is appended to the name it means that the item is a method (like a subroutine call).

For example qtu.adcCur indicates that the item is an instance variable called adcCur and is part of a qtu object. Each qtu object (as declared in a QtuThrottles: section) has its own set of instance variables.

Also ctc.ctcSetTitle (string) indicates a method called ctcSetTitle which takes a single string parameter and is part of a ctc object (as declared in a CtcWindows: section).

Note that items are sorted alphbetically, but that ignores any object type and period in the name.

A

qtu.adcCur: Current measurement reading in QTU throttle.

qtu.adcFb: Feedback voltage reading in QTU throttle

text.add (string, ...): Add a string to a CtcText variable.

ctc.addAspect (cellId, filename): Add another aspect to an existing image.

priorityVariable.addPri (reference, priority): Add a claim to use of a resource. The claim is identified by reference and its preferential status by priority. The highest priority wins. See also removePri, pri, n.

train.addCtcCells (cell, ...): Add CTC cells to the path the train will take on the CTC window. cells can be [x,y,z] variables or constants, or meta names. Cells should be added in order where possible.

train.addQtu (qtuPtr, { realQtu,} { CTC segment list, }{ entry length, } length): Add another section to the planned route of this train. Length specified the electrical length including adjustments for turnout settings.

train.addQtuLength (qtuPtr, length): Add extra length to specified section. May be required if onward route decisions affect electrical section length.

ctc.addSlider (cellId, cols, rows, min, max, var): Add a slider control. Either rows or cols must be 1. var is a variable (not constant or equation) and the variable changes if the control is adjusted.

train.addSpeedLimit (qtuPtr, distance, speed): This specifies the distance along section qtuPtr where the speed limit changes. Speed 0 means no limit. Note that train speed may slowly change once it reaches the specified position - the system is NOT PREDICTIVE, so position the changes to allow the train to slow well before the bend!

qtu.addSpeedLimit (): Preload a speed limit location into QTU throttle

string.append (...): Append to a string variable

string.appendChar (number): Append t single character o a string variable

string.appendHex (value, length, base): Append a hex number to a string variable

B

System.beep (): Sound the system defined beep.

cab.brake: Throttle brake control in SmartCab, QtuCab or Train variable

C

train.cal: The calibration coefficient of the train. This is the value of integral over a distance of 100 of your length units.

ctc.ctcBack (): Move this window to behind others.

ctc.ctcFront (): Move this window to be in front of other windows.

System.ctcMeta (): Fetch the meta name of the last

ctc.ctcMetaData (cellId): Fetch the meta data associated with the specified cell.

ctc.ctcMetaName (cellId): Fetch the meta name of the specified cell. CTC cell clicked in.

ctc.ctcSetMeta (cellId, name, value): Assign or change meta data associated with a cell.

System.ctcTag (string): Fetch the meta data value stored against the cell given the meta name specified. If no parameters given then return the meta data stored for the cell last clicked in, or zero if none available.

text.change (seq, string, ...): Modify a line of text in a CtcText variable.

string.clear (): Empty a string variable

TagReader.clear (): Empty the stock and loco lists in a tag reader object.

ctc.colourBlock (cellId, colour, from, to): Sets the colour of the block containing the specified cell. 'from' and 'to' can specify a portion of the block to colour. Track blocks are defined using the 'B' tool in the Tracks pallette. Replaces $Colour Block

ctc.colourMessage (cellId, [colour][, bg]): Define text colour and/or background colour for a text message. The colour is defined using $RGB_aabbggrr where bb gg and rr are the amount of blue, green and red respectively. aa is the 'alpha channel' and defaults to FF if not specified, it is a measure of opaqueness, 0 being transparent. $RBG_0 is black, $RGB_FFFFFF is white. Several colours are predefined including clear, black, brown, red, orange, yellow, green, blue, purple, gray and white.

ctc.colourTrack (cellId, colour): Set the color of the single track segment. Compare with colourBlock. Replaces $Colour Track

System.command (): Retrieve the last entered keyboard command as a string.

ctc.ctcSetTitle (string): sets the title of the TC window.

qtu.cur: Current detect flag in QTU variable

train.currentQtu: Contains a pointer to the QtuThrottle currently feeding this train. This assumes that addQtu is invoked as the route ahead of the train is booked and removeQtu as the train moves.

qtu.curSpeed: Current speed setting after inertia in QTU throttle

D

DccCab.dccLcd (cab, line, string): Display the message string on line (2,3,4) of the specified hand-held cab.

cab.dir: Throttle direction control in SmartCab or QtuCab

ctc.drawImage (cellId, filename, width, height): Draw an image in a ctc cell. Replaces $Draw image

ctc.drawMessage (cellId, message, ...): Draw a text message at the ctc cell specified. Replaces $Draw Message.

ctc.drawShape (cellId, "cmd1", "cmd2", …): Draw a compound shape in the cell.

ctc.drawSprite (cellId, filename, width, height): Draw a sprite in a ctc cell.

System.dumpLog (): Dumps the whole of the log window to tcc.log

E

ctc.eraseImage (param): Erase the previously drawn image. Param can be either a cellId or an image number returned by drawImage.

ctc.eraseMessage (cellId): Erase the previously drawm text message.

F

qtu.fbEnableable: Feedback enable control in QTU variable

qtu.fbSpeed: Current speed setting after inertia and feedback in QTU throttle

ctc.flipImage (cellId, flipX, flipY): Flip, or reflect an existing image in either or both axes.

ctc.flipImageND (cellId, flipX, flipY): Flip, or reflect an existing image in either or both axes. Does not cause an immediate redraw of the window.

ctc.flipSprite (spriteNumber, flipX, flipY): Flip, or reflect an existing image in either or both axes.

ctc.flipSpriteND (spriteNumber, flipX, flipY): Flip, or reflect an existing sprite in either or both axes. Does not cause an immediate redraw of the window.

forward: Throttle direction constant in SmartCab, QtuCab or Train variable

G

DccCab.function (F#, value): Control the specified function. F# should be a number from 0 to 28. Values or 1 or 0 turn on or off that function. Larger values pulse the function for that number of ms. Pulse lengths should be at least several hundred ms.

db.get (column, row): Within the results returned by a db.query ("SELECT...") return the value of the given cell.

qtu.getAdcUser (): Fetch analogue input voltage reading from QTU

text.getLine (lineNo): Retrieve a line of text by line number from a CtcText variable.

TagReader.getLocoId (n): Return the id of the n-th loco scanned by the reader.

qtu.getScriptData (): Fetch shared memory value from QTU

TagReader.getStockId (n): Return the id of the n-th item of stock scanned by the reader.

TagReader.getStockType (n): Return the type of the n-th item of stock scanned since last cleared. Type zero is reserved to mean loco.

text.getText (seq): Retrieve a line of text from a CtcText variable.

train.getTrNo (&qtu): Get the train number using the specified qtu.

TagReader.getUnknownCode (n): Return the string value of the n-th code scanned that is not stored in the database.

string.getWord (word): Fetch a word from a string

H

db.heading (column): Within the results returned by a db.query ("SELECT...") return the name of the given coluumn.

train.headLength: The (default or measured) length from the front of the train to the frontmost pickup. Measured in your chosen distance units. A loco-in-front train will have a small headLength.

train.headPosition (qtuPtr): Returns the current position of the head (front) of the train, as seen by the specified section. If the train has not yet arrived in that section, the result will be negative. The section must already have been registered using addQtu.

ctc.hideImage (cellIdNum): Hide a previously drawn image.

ctc.hideSprite (cellIdNum): Hide a previously drawn sprite.

I

IF <condition> THEN <actions> { ELSEIF <conditions> THEN <actions> }... { ELSE <actions> } ENDIF This allows some actions to be conditionally executed as part of a statement.

string.indexof (): Find a string in a string variable

string.insert (): Insert into a string variable

qtu.integral: Dead-reckoning integral in in QTU variable

J

K

L

train.length: The length of the train. This defaults to 0, or whatever is set in the tdl file (if applicable). Once a calibrated train passes a position sensor measured length readings are accumulated, the average of which replaces the default value of length.

train.loadDb (): Load calibration data for this train from the "trains" database.

train.loadLocodata (loco number): Lookup calibration data in the database "LOCOS" for the given locoId.

TagReader.locoCount: How many locos have been scanned since this reader was last reset.

train.locoPos: The absolute position of the (calibrated) train in its current section (stored in currentQtu).In your chosen distance units.

System.log (string): Add string to tcc.log

M

qtu.measureTime: Time measurement value in QTU variable

cab.mom: Throttle momentum/inertia control in SmartCab, QtuCab or Train variable

ctc.moveImage (cellIdNum, newcellId): Move an already drawn image to a new location in the same CTC window.

ctc.moveImageND (cellIdNum, newcellId): Move an already drawn image to a new location in the same CTC window. Does not immediately redraw the window.

ctc.moveSprite (spriteNumber, newCellId, xFraction, yFraction): Move an already drawn image to a new location in the same CTC window. Can move sprites fractional cell positions.

ctc.moveSpriteND (spriteNumber, newCellId, xFraction, yFraction): Move an already drawn image to a new location in the same CTC window. Does not immediately redraw the window.

N

priorityVariable.n: The number of claims currently registered.

train.noCurrent: This variable is normally zero. However if current pickup is lost (perhaps by dirty track) then this value reports how many seconds no current has been flowing to the train.

ctc.numCols: Read-only variable containing the number of columns currently displayed in this CTC window.

ctc.numRows: Read-only variable containing the number of rows currently displayed in this CTC window.

O

qtu.overload: Overload flag in QTU variable

P

ctc.panCol: Read-only variable containing the number of columns this CTC window is panned by (contents shifted left).

ctc.panRow: Read-only variable containing the number of rows this CTC window is panned by (contents shifted up).

ctc.panTo (col, row): Pan this CTC window by the specified number of rows and columns from the origin.

string.parse (): Extract a number from a string variable

string.parseHex (): Extract a number from a string variable

System.playSound ("filename"): Load the sound file specified and play it out of the main speakers.

string.pop (word, index): Remove a character from a string variable

pulse: control={value} pulse period will set the control to value for period and then set it to zero again. Value defaults to 1 if omitted. Same as control=value, wait period, control=0. Period is in seconds if a literal, or milliseconds if a variable. pulse o=0.5 is the same as x=500, pulse o=x

priorityVariable.pri: The current highest priority of all claims on this resource. See also addPri, removePri, n.

ctc.popIndex: Read-only variable containing the index of the last popup selection. If in a submenu, this contains the index of the submenu in the main list.

ctc.popSubIndex: Read-only variable containing the index of the last popup selection within a sub-menu.

ctc.popup (col, row, menu item, ...): Display a popup menu in a CTC cell.

ctc.popupCol: The column in which the last popup was drawn.

ctc.popupLoc: The first parameter passed to the last call to popup in this window. Could contain a meta name, an [x,y,z] coordinate value, or a column number.

ctc.popupName (): Returns the name of the last selection from a popup menu.

ctc.popupRow: The row in which the last popup was drawn.

ctc.popupSubName (): Returns the name of the sub menu that the last selection was from.

string.popWord (word): Remove a word from a string variable

Q

db.query ("SQL"): Action the given SQL statement on the attached database. This can include SELECT, UPDATE and CREATE statements.

R

text.remove (): Remove a string from a CtcText variable.

text.removeAll (): Clear a CtcText variable.

priorityVariable.removePri (reference): Remove a claim to use of a resource. The claim (previously made using addPri) identified by reference is removed from the list of claims. See also addPri, pri, n.

train.removeQtu (qtuPtr): Remove a QTU from the list this train is routed over. This should be done after the train has passed the section and before allocating that section for another train.

string.replace (start, end, params): Replace part of a string variable

string.replaceInWord (word, start, end, params): Replace part of a word in a string variable

qtu.resetIntegral: Reset the Dead-reckoning integral in in QTU throttle

return: Return from the current statement. If this action is in a subroutine it causes the subroutine to exit and execution resumes from after the call. If this action is in a normal when statement the statement immediately terminates execution.

reverse: Throttle direction constant in SmartCab, QtuCab or Train variable

ctc.rotateImage (cellIdNum, rotation, x, y): Rotate an existing image about an arbitrary point.

ctc.rotateImageND (cellIdNum, rotation, x, y): Rotate an existing image about an arbitrary point. Does not cause an immediate redraw of the window.

ctc.rotateSprite (spriteNumber, rotation, x, y): Rotate an existing sprite about an arbitrary point.

ctc.rotateSpriteND (spriteNumber, rotation, x, y): Rotate an existing sprite about an arbitrary point. Does not cause an immediate redraw of the window.

db.rowWith (column, value): Within the results returned by a db.query ("SELECT...") search for 'value' in the given column. return the row number of the first match.

S

qtu.sBrake: Script brake setting in QTU throttle

ctc.scaleImage (cellIdNum, scaleX, scaleY, fill): Scale an existing image.

ctc.scaleImageND (cellIdNum, scaleX, scaleY, fill): Scale an existing image. Does not cause an immediate redraw of the window.

ctc.scaleSprite (spriteNumber, scaleX, scaleY, fill): Scale an existing image.

ctc.scaleSpriteND (spriteNumber, scaleX, scaleY, fill): Scale an existing sprite. Does not cause an immediate redraw of the window.

qtu.sDir: Script direction setting in QTU throttle

$Send Packet ifNum {(x,y,z) {[index]}=value: Send an ethernet packet out of packet interface ifNum. Value is normally a string (literal or variable). If x,y,z are included then they are included as 32 bit values in the packet header, or default to -1 if omitted.

train.sensorChanged (qtuPtr, distance, state): the sensor positioned distance along section qtuPtr has changed to state. State should be 1 for train present, 0 otherwise. Calls to this method allow train length determinations based upon the current position of the train.

ctc.setCellSize (width, height): Set the size of each cell in this ctc window.

train.setDefaultCal (cal): Set a global variable that will be used for all uncalibrated trains.

train.setDefaultLengths (head, tail): Set the values that should be used for trains lengths until actual measurements become available. These values are discarded once measured data is available and are not part of the averaging process.

train.setEntryLength (qtuPtr, length): Change entry gap length from value stored in addQtu. entryLength is amount of track before nominal zero position, thus tracks having differing entry paths do not need different stopping distances. Convenience method in case supporting variable number of arguments is difficult.

train.setFirstClassName (name): Define the name of the first class we are using.

ctc.setImageAspect (cellId, aspect): Select which aspect of a multi-aspect image to show.

DccCab.setLocoId (locoId, size): Set the loco number (decoder address) to be controlled by this DccCab object. If locoId>127 or size<>0 then the address is a long address, otherwise it is treated as a short loco address.

text.setMaxLines (n): Set the maximum number of lines that may be stored and displayed in a CtcText variable.

ctc.setMessagePos (cellId, pos): Set the position of a previously drawn message within its cell.

ctc.setMessageSize (cellId, size): Set the size of a previously drawn message.

ctc.setOffset (cellIdNum, x, y): Define the point within the image to be treated as the origin.

ctc.setOffsetND (cellIdNum, x, y): Define the point within the image to be treated as the origin. Does not cause an immediate redraw of the window.

train.setQtuLength (qtuPtr, length): Change entry gap length from value stored in addQtu. Convenience method in case supporting variable number of arguments is difficult.

qtu.setScriptData (): Save shared memory value into QTU

ctc.setSize (cols, rows): Resize this CTC window to the given number of rows and columns.

train.setSpeedCal (cal): Set a global variable that relates scale speed (in perhaps cm per sec) to real speed (in perhaps MPH).

ctc.setTrackAspect (cellId, aspect): Change the representation of the multiway track element specified by cellId to the form specified by aspect. Turnouts use 0 for left, 1 for right and 2 for undefined. DIY multiway track elements can be defined by hand-editing the ctc file or using setTrackLines. replaces $switch

ctc.setTrackLines (cellId, lines, ...): Change the representation of the track element specified by cellId. Each value of lines specifies a set of track segments (bit 0 is top-left, bit 1 is top and so on round the circle). The first value is the default representation and subsequent lines values are aspects 1..7

train.setTrainColour (colour): Set the colour to use to animate the train on the CTC.

string.setWord (word, string): Replace a word in a string

ctc.showImage (cellIdNum): Show a previously hidden image.

ctc.showSprite (cellIdNum): Show a previously hidden sprite.

qtu.sMom: Script momentum setting in QTU throttle

cab.speed: Throttle output setting in SmartCab, QtuCab or Train variable

train.speedLimit: Reflects any speed limit this train is operating under. Zero means no speed limit applies.

qtu.sSpeed: Script speed setting in QTU throttle

System.status (message {, fg {, bg}}): Set the script status (displayed in the status bar at the bottom of the Tcc window). Foreground and background colours and optionally be set.

TagReader.stockCount: How many items of stock have been scanned since this reader was last reset.

qtu.stopAt: Dead-reckoning stop control in QTU throttle

train.stopAtPosition (qtuPtr, length, flags{, entryGap, exitGap}): Causes the train to stop at position length along section qtuPtr. Flags and gaps modify desired stopping position according to length of train and section clearances.

string.strlen (): Return the length of a string variable

SUB (): Calling (and defining) subroutines in your TCL script.

string.substring (): Extract part of a string variable

$switch (x,y,z)=value: Change the representation of the multiway track element at x,y,z to the form specified by value. Turnouts use 0 for left, 1 for right and 2 for undefined. DIY multiway track elements can be defined by hand-editing the ctc file.

T

train.tailLength: The (default or measured) length from the rear of the train to the frontmost pickup. Measured in your chosen distance units. A loco-in-front train will have a large tailLength.

train.tailPosition (qtuPtr): Returns the current position of the tail (rear) of the train, as seen by the specified section. If the train has not yet fully arrived in that section, the result will be negative. The section must already have been registered using addQtu.

train.trackLength: The electrical length of the section (defined in currentQtu) the train currently is powered by.

string.trim (): Remove leading and trailing spaces from a string.

U

TagReader.unknownCount: How many tag codes were not in the database when last scanned.

V

W

WAIT period: Delay the execution of the rest of this statement by the period specified. If the period is a number then it is a floating point number of seconds, such as '2.5'. If the period is a variable then it is measured in milliseconds, so x=2500, wait x, will wait for 2.5 seconds.

WAIT UNTIL <condition> THEN, This action suspends the execution of the statement until the condition is true, and then execution continues.

string.wordStarting (string): Return the word nunber of the first word that starts with the given string.

System.windowFront (number): Move CTC<number> to the front.

X

Y

Z

If there are any omissions from the above list, then please feel free to email me suitable pages to insert here.
Last updated 11 Aug 2018.

© Howard Amos 2008-2018