Click Expression Reference

The following is a list of the expressions that are used in the various Click programs.

Note: this list only includes expressions for the default system objects and the Expression Editor dialog; extensions' expressions are not listed here. Some of these expressions may only be available in newer builds of specified programs. Expression names are not case-sensitive. Expressions including a $ return strings, and those without generally return numbers (but there is an exception in this list [and within some other extensions] which returns a string: key( "Player" )). TGF1 may use "level" instead of "frame" in some cases.

Special Object

Expression
Description
Availability
Random( int ) Generates a random integer from 0 to (n - 1). Max n is 65535. TGF MMF TGF2 MMF2
[Name of Global Value] Returns the value of a given Global Value. TGF MMF TGF2 MMF2
Global Value( index ) Returns the value of a given Global Value referred to by index. MMF TGF2 MMF2
[Name of Global String] Returns the text of a given Global String. TGF2 MMF2
Global String( index ) Returns the text of a given Global String referred to by index. TGF2 MMF2
Appdrive$ Returns the drive letter the application is found on. TGF MMF TGF2 MMF2
Appdir$ Returns the path where the application can be found, minus the drive letter. TGF MMF TGF2 MMF2
Apppath$ Shortcut for Appdrive$ + Appdir$. TGF MMF TGF2 MMF2
AppTempPath$ Returns the path of the temporary folder where the application is extracted during runtime. TGF2 MMF2
Appname$ Returns the name of the executable, minus ".exe" or ".ccn". TGF MMF TGF2 MMF2
BinFileTempName$( path ) Returns the name of the last extracted binary file. MMF2
Str$( number ) Converts a number into a string. TGF MMF TGF2 MMF2
FloatToString$( float, total_digits, digits_after_point ) Converts a float into a string, with some formatting options. TGF2 MMF2
Val( string ) Converts a string to a number up until the first non-numeric character in the string (Ex: "12345a67" converts to 12345). However, if the string is a hex or binary string starting with '0x' or '0b', it will be converted to decimal. TGF MMF TGF2 MMF2
Int( float ) Converts a float into a true integer (anything after the decimal point is lost). Rounds toward 0. MMF TGF2 MMF2
Round( float ) Rounds a float up if the decimal is >= .5, or down otherwise—the opposite if negative. The resulting number is still a float. MMF TGF2 MMF2
Hex$( integer ) Converts an integer to a hex string in the form 0xNNNNNNNN. The resulting hex string past the '0x' may be up to 8 characters, but can be less. MMF TGF2 MMF2
Bin$( integer ) Converts an integer to a binary string in the form 0bNNNNNNNN. The resulting binary string past the '0b' may be up to 32 characters, but can be less. MMF TGF2 MMF2
abs( number ) Returns the absolute value of a number (removes the negative sign if present). MMF TGF2 MMF2
ceil( float ) Forces a float to round to the nearest number larger than it. The result remains a float. (Ex: 3.2 -> 4.0; -3.2 -> -3.0). Rounds toward positive infinity. MMF TGF2 MMF2
floor( float ) Forces a float to round to the nearest number smaller than it. The result remains a float. (Ex: 4.8 -> 4.0; -4.8 -> -5.0). Rounds toward negative infinity. MMF TGF2 MMF2
sqr( number ) Returns the square root of a number. MMF TGF2 MMF2
log( number ) Returns the base-10 log of a number. MMF TGF2 MMF2
ln( number ) Returns the natural log (base-e) of a number. MMF TGF2 MMF2
exp( number ) Returns e to the power of a number. MMF TGF2 MMF2
min( number1, number2 ) Returns the smaller of the two numbers. MMF TGF2 MMF2
max( number1, number2 ) Returns the larger of the two numbers. MMF TGF2 MMF2
sin( angle ) Returns the sine of the angle (provided in degrees). MMF TGF2 MMF2
cos( angle ) Returns the cosine of the angle (provided in degrees). MMF TGF2 MMF2
tan( angle ) Returns the tangent of the angle (provided in degrees). MMF TGF2 MMF2
asin( angle ) Returns the arcsine of the angle (provided in degrees). MMF TGF2 MMF2
acos( angle ) Returns the arccosine of the angle (provided in degrees). MMF TGF2 MMF2
atan( angle ) Returns the arctangent of the angle (provided in degrees). MMF TGF2 MMF2
atan2( y_delta, x_delta ) Returns the angle between two points (returns in degrees). x_delta is (x2 - x1), (y2 - y1) for y_delta. TGF2 MMF2
not( integer ) Performs and returns a bitwise Not on an integer. (Ex: not(56) = -57) MMF TGF2 MMF2
left$( string, length ) Returns the left portion of string with a given length. MMF TGF2 MMF2
right$( string, length ) Returns the right portion of string with a given length. MMF TGF2 MMF2
mid$( string, start, length ) Returns the middle portion of string starting at a 0-based position and with a given length. MMF TGF2 MMF2
len( string ) Returns an integer representing the length of a string; the empty string "" is 0. MMF TGF2 MMF2
newline$ Causes following text to display on another line. MMF TGF2 MMF2
lower$( string ) Converts all characters in a string to lowercase. MMF TGF2 MMF2
upper$( string ) Converts all characters in a string to UPPERCASE. MMF TGF2 MMF2
find( string, pattern, startnum ) Returns an integer representing the 0-based location of the first character of the first occurrence of pattern in string, starting at location startnum. If pattern is not found, -1 is returned. MMF TGF2 MMF2
reversefind( string, pattern, startnum ) Same as find(), but searches for pattern by starting at the end of string. MMF TGF2 MMF2
ndropped Returns the number of files dropped into application window. MMF TGF2 MMF2
dropped$( integer ) Returns the path of a dropped file, referenced by an integer. MMF TGF2 MMF2
commandline$( string ) Returns the command line used to launch the application. MMF TGF2 MMF2
getcommanditem$( string ) Returns the string from a provided command item switch. If the switch has no associated string, "Empty" is returned; if the switch is not found at all, "" is returned. MMF TGF2 MMF2
getrgb( red, green, blue ) Converts an RGB value to MMF's color format integer. Same as: red + green * 256 + blue * 65536 MMF TGF2 MMF2
getred( string ) Returns the red value from MMF's color format. MMF TGF2 MMF2
getgreen( string ) Returns the green value from MMF's color format. MMF TGF2 MMF2
getblue( string ) Returns the blue value from MMF's color format. MMF TGF2 MMF2
cliptext$ Returns the text currently in the clipboard. MMF TGF2 MMF2
loopindex( loopname ) Returns the current 0-based index of loopname. MMF TGF2 MMF2

Sound Object

Expression
Description
Availability
samplemainvolume Returns the value of the main volume setting. TGF2 MMF2
samplevolume( sample ) Returns the volume of the specified sample. TGF2 MMF2
channelvolume( channel ) Returns the volume of the specified channel (1 to 32). TGF2 MMF2
samplemainpan Returns the current value of the main panning (left/right balance) setting. TGF2 MMF2
samplepan( sample ) Returns the pan of the specified sample. TGF2 MMF2
channelpan( channel ) Returns the pan of the specified channel. TGF2 MMF2
sampleposition( sample ) Returns the time position of the specified sample in milliseconds. TGF2 MMF2
channelposition( channel ) Returns the time position of the specified sample in milliseconds. TGF2 MMF2
sampleduration( sample ) Returns the total time of the specified sample, in milliseconds. TGF2 MMF2
channelduration( channel ) Returns the total time of the specified channel, in milliseconds. TGF2 MMF2
samplefreq( sample ) Returns the sample rate in hertz of the specified sample, or 0 if there is no sample playing. TGF2 MMF2
channelfreq( channel ) Returns the sample rate in hertz of the specified channel, or 0 if the channel is not active. TGF2 MMF2

Storyboard Controls Object

Expression
Description
Availability
frame Returns the current frame number. TGF MMF TGF2 MMF2
players Returns the number of active players (using default movements). TGF MMF TGF2 MMF2
frame width Returns the width of the frame in pixels. TGF MMF TGF2 MMF2
frame height Returns the height of the frame in pixels. TGF MMF TGF2 MMF2
virtualwidth Returns the frame's virtual width. TGF2 MMF2
virtualheight Returns the frame's virtual height. TGF2 MMF2
x left frame Returns the leftmost visible X coordinate of the frame (based on the scrolling position). TGF MMF TGF2 MMF2
x right frame Returns the rightmost visible X coordinate of the frame. TGF MMF TGF2 MMF2
y top frame Returns the topmost visible Y coordinate of the frame. TGF MMF TGF2 MMF2
y bottom frame Returns the bottommost visible Y coordinate of the frame. TGF MMF TGF2 MMF2
framebkdcolor Returns the background color of the frame, in MMF's color format. TGF2 MMF2
collisionmask( x, y ) Checks a point at x, y (on layer 1) to see what type of background collision it is; Returns 0 for nothing, 1 for obstacle, and 2 for ladder. MMF TGF2 MMF2
framerate Returns the current framerate (FPS). TGF2 MMF2

Timer Object

Expression
Description
Availability
hours Returns the number of hours elapsed since the start of frame or the timer set to 0. TGF MMF TGF2 MMF2
minutes Returns the number of minutes elapsed since the start of frame or the timer set to 0. TGF MMF TGF2 MMF2
seconds Returns the number of seconds elapsed since the start of frame or the timer set to 0. TGF MMF TGF2 MMF2
hundreds Returns the number of hundreths of a second elapsed since start of frame or the timer set to 0. TGF MMF TGF2 MMF2
timer Returns the number of milliseconds elapsed since the start of frame or the timer set to 0. TGF MMF TGF2 MMF2

Create Object

Expression
Description
Availability
total objects Returns the count of all objects on the frame. TGF MMF TGF2 MMF2

Mouse and Keyboard Object

Expression
Description
Availability
xmouse Returns the X position of the mouse. TGF MMF TGF2 MMF2
ymouse Returns the Y position of the mouse. TGF MMF TGF2 MMF2
wheeldelta Returns the magnitude of the last mouse wheel movement; it should be a multiple of 120, but is device dependent. Positive if up, negative if down; must be reset manually. TGF2 MMF2

Player Objects

Expression
Description
Availability
score( "Player X" ) Returns the score of player X (1 through 4). TGF MMF TGF2 MMF2
lives( "Player X" ) Returns the number of lives of player X. TGF MMF TGF2 MMF2
playername$( "Player X" ) Returns player X's name. MMF TGF2 MMF2
input( "Player X" ) Returns player X's input device. MMF TGF2 MMF2
key( "Player X", keynum) Returns a string representing the key assigned to keynum: 0 for up, 1 for down, 2 for left, 3 for right, 4 for fire1, 5 for fire2, 6 for fire3, and 7 for fire4. MMF TGF2 MMF2

Expression Editor

Expression
Description
Availability
+ Performs addition between two numbers, obviously. TGF MMF TGF2 MMF2
- Performs subtraction between two numbers, obviously. TGF MMF TGF2 MMF2
* Performs multiplication between two numbers, obviously. TGF MMF TGF2 MMF2
/ Performs division between two numbers, obviously. NOTE: MMF does integer division unless either the denominator or numerator (or both) are floats, in which case it will do floating point division. TGF1 can't handle floats at all. Division by zero returns 0. TGF MMF TGF2 MMF2
mod Performs modulus division (returns the remainder of integer division) between two integers. TGF MMF TGF2 MMF2
pow Raises the left number to the power of the right number. MMF TGF2 MMF2
and Performs bitwise And on two integers. (Ex: 15 and 24 = 8; 00001111 and 00011000 = 00001000) MMF TGF2 MMF2
or Performs bitwise Or on two integers. (Ex: 15 or 24 = 31; 00001111 or 00011000 = 00011111) MMF TGF2 MMF2
xor Performs bitwise Xor on two integers. (Ex: 15 xor 24 = 23; 00001111 xor 00011000 = 00010111) MMF TGF2 MMF2