Functions are evaluated from left to right, and from inside to outside if nested

A function parameter can be text, a mathematical formula, a cell address, or a range of cell addresses

Multiple parameters form a list; they are separated by a comma, followed by optional space, such as %CALCULATE{$SUM( 3, 5, 7 )}%

Changed:

<<

A parameter representing a string can optionally be enclosed in triple quotes; quotes are required if the string contains commas or parenthesis, such as %CALCULATE{$SUBSTITUTE('''Good, early morning''', morning, day)}%

>>

A parameter representing a string can optionally be enclosed in triple quotes; quotes are required if the string contains commas, parenthesis or newlines, such as %CALCULATE{$SUBSTITUTE('''Good, early morning''', morning, day)}%

ADDLIST( name, list ) -- append a list to a list variable

Specify the variable name (alphanumeric characters and underscores) and the list to add. If the named list does not exist it will be created. Useful in a FormattedSearch to add items to a list. This function returns no output. Use $GETLIST() to retrieve a list variable.

Specify the variable name (alphanumeric characters and underscores). An empty string is returned if the variable does not exist. Use $SET() to set a variable first. Unlike table ranges, variables live for the time of the page view and persist across tables, i.e. you can use it to summarize results across several tables.

Syntax: $GET( name )

Example: %CALCULATE{$GET(my_total)}% returns the value of the my_total variable

GETHASH( name, key ) -- get the value of a previously set hash key

Specify the hash name and key; allowed characters for the hash name are alphanumeric characters, underscores and period. An empty string is returned if the hash key does not exist. Use $SETHASH() or $LIST2HASH() to set a hash. If the key is omitted, a list of all keys of the named hash is returned. If no parameters are specified, a list of all hash names is returned.

HASH2LIST( name, format ) -- convert a hash to a list

Line: 787 to 821

SET( name, value ) -- set a variable for later use

Changed:

<<

Specify the variable name (alphanumeric characters and underscores) and the value. The value may contain a formula; formulae are evaluated before the variable assignment; see $NOEXEC() if you want to prevent that. This function returns no output. Use $GET() to retrieve variables. Unlike table ranges, variables live for the time of the page view and persist across tables, i.e. you can use it to summarize results across several tables and also across included topics

>>

Specify the variable name (alphanumeric characters and underscores) and the value. The value may contain a formula; formulae are evaluated before the variable assignment; see $NOEXEC() if you want to prevent that. This function returns no output. Use $GET() to retrieve variables. Unlike table ranges, variables live for the time of the page view and persist across tables, i.e. you can use it to summarize results across several tables and also across included topics. If the value is omitted, the named variable is deleted.

Syntax: $SET( name, value )

Example: %CALC{$SET(my_total, $SUM($ABOVE()))}% sets the my_total variable to the sum of all table cells located above the current cell and returns an empty string

SETLIST( name, list ) -- save a list for later use

Specify the variable name (alphanumeric characters and underscores) and the list. This function returns no output. Use $GETLIST() to retrieve a list variable. Use $ADDLIST() to add a list to an existing variable. If no list is specified, the named variable is deleted.

SETM( name, formula ) -- modify an existing variable based on a formula

Specify the variable name (alphanumeric characters and underscores) and the formula. The formula must start with an operator to + (add), - (subtract), * (multiply), or / (divide) something to the variable. This function returns no output. Use $GET() to retrieve variables

Proposed Features

Accepted Features

First we search all features and store the status, summary and date in hashes, using the topic name as the key. Then we build a table that shows all proposed features, followed by a table showing all accepted features. Reading the CALCULATE formula from inside out:

Line: 1115 to 1185

Do not handle %CALC{}% variable in included topic while including topic: (default: 1) (See note CALC in Included Topics)

TWiki Spreadsheet Plugin

Changed:

<<

This plugin adds spreadsheet capabilities to TWiki topics. Functions such as %CALC{$INT(7/3)}% are evaluated at page view time. They can be placed in table cells and outside of tables. In other words, this plugin provides general function evaluation capability, not just classic spreadsheet functions. The plugin currently has

>>

This plugin adds spreadsheet capabilities to TWiki topics. Functions such as %CALCULATE{$INT(7/3)}% are evaluated at page view time. They can be placed in table cells and outside of tables. In other words, this plugin provides general function evaluation capability, not just classic spreadsheet functions. The plugin currently has

TWiki Spreadsheet Plugin

TWiki Spreadsheet Plugin

TWiki Spreadsheet Plugin

Changed:

<<

This plugin adds spreadsheet capabilities to TWiki topics. Formulae like %CALC{"$INT(7/3)"}% are evaluated at page view time. They can be placed in table cells and outside of tables. In other words, this plugin provides general formula evaluation capability, not just classic spreadsheet functions.

>>

This plugin adds spreadsheet capabilities to TWiki topics. Functions such as %CALC{$INT(7/3)}% are evaluated at page view time. They can be placed in table cells and outside of tables. In other words, this plugin provides general function evaluation capability, not just classic spreadsheet functions. The plugin currently has

Built-in Functions

>>

Use CALC or CALCULATE

Changed:

<<

Conventions for Syntax:

>>

Use %CALC{...}%in table cells: The CALC variable handles all functions, but it gets handled with delay compared to other TWikiVariables: It gets executed after internal variables and plugin variables that use the register tag handler. You may get unexpected results if you nest CALC inside other variables (such as %INCLUDE{%CALC{...}%}%) because it does not get evaluated inside-out & left-to-right like ordinary TWiki variables.

Use %CALCULATE{...}%outside tables: The CALCULATE variable is handled inside-out & left-to-right like ordinary TWiki variables, but it does not support functions that refer to table cells, such as $LEFT() or $T().

Built-in Spreadsheet Plugin Functions

The plugin currently has 756 functions. Convention for parameters:

Required parameters are indicated in ( bold )

Optional parameters are indicated in ( bold italic )

ABOVE( ) -- address range of cells above the current cell

Syntax: $ABOVE( )

Changed:

<<

Example: %CALC{"$SUM($ABOVE())"}% returns the sum of cells above the current cell

>>

Example: %CALC{$SUM($ABOVE())}% returns the sum of cells above the current cell

FIND( string, text, start ) -- find one string within another string

Finds one text string, within another text, and returns the number of the starting position of string, from the first character of text. This search is case sensitive and is not a regular expression search; use $SEARCH() for regular expression searching. Starting position is 1; a 0 is returned if nothing is matched.

GET( name ) -- get the value of a previously set variable

Specify the variable name (alphanumeric characters and underscores). An empty string is returned if the variable does not exist. Use $SET() to set a variable first. Unlike table ranges, variables live for the time of the page view and persist across tables, i.e. you can use it to summarize results across several tables.

Syntax: $GET( name )

Changed:

<<

Example: %CALC{"$GET(my_total)"}% returns the value of the my_total variable

>>

Example: %CALC{$GET(my_total)}% returns the value of the my_total variable

IF( condition, value if true, value if 0 ) -- return a value based on a condition

The condition can be a number (where 0 means condition not met), or two numbers with a comparison operator < (less than), <= (less than or equal), == (equal), != (not equal), >= (greater than or equal), > (greater than).

Syntax: $IF( condition, value if true, value if 0 )

Changed:

<<

Example: %CALC{"$IF($T(R1:C5) > 1000, Over Budget, OK)"}% returns Over Budget if value in R1:C5 is over 1000, OK if not

Example: %CALC{"$IF($EXACT($T(R1:C2),), empty, $T(R1:C2))"}% returns the content of R1:C2 or empty if empty

LISTJOIN( separator, list ) -- convert a list into a string

By default, list items are separated by a comma and a space. Use this function to indicate a specific separator string, which may include $comma for comma, $n for newline, $sp for space, and $empty to join a list without a separator.

ROUND( formula, digits ) -- round a number

Evaluates a simple formula and rounds the result up or down to the number of digits if digits is positive; to the nearest integer if digits is missing; or to the left of the decimal point if digits is negative

SEARCH( string, text, start ) -- search a string within a text

Finds one text string, within another text, and returns the number of the starting position of string, from the first character of text. This search is a RegularExpression search; use $FIND() for non-regular expression searching. Starting position is 1; a 0 is returned if nothing is matched

SET( name, value ) -- set a variable for later use

Specify the variable name (alphanumeric characters and underscores) and the value. The value may contain a formula; formulae are evaluated before the variable assignment; see $NOEXEC() if you want to prevent that. This function returns no output. Use $GET() to retrieve variables. Unlike table ranges, variables live for the time of the page view and persist across tables, i.e. you can use it to summarize results across several tables and also across included topics

Syntax: $SET( name, value )

Changed:

<<

Example: %CALC{"$SET(my_total, $SUM($ABOVE()))"}% sets the my_total variable to the sum of all table cells located above the current cell and returns an empty string

>>

Example: %CALC{$SET(my_total, $SUM($ABOVE()))}% sets the my_total variable to the sum of all table cells located above the current cell and returns an empty string

SETM( name, formula ) -- update an existing variable based on a formula

Specify the variable name (alphanumeric characters and underscores) and the formula. The formula must start with an operator to + (add), - (subtract), * (multiply), or / (divide) something to the variable. This function returns no output. Use $GET() to retrieve variables

Syntax: $SETM( name, formula )

Changed:

<<

Example: %CALC{"$SETM(total, + $SUM($LEFT()))"}% adds the sum of all table cells on the left to the total variable, and returns an empty string

>>

Example: %CALC{$SETM(total, + $SUM($LEFT()))}% adds the sum of all table cells on the left to the total variable, and returns an empty string

SPLIT( separator, text ) -- split a string into a list

Split text into a list using separator as a delimiter. The separator may be a regular expression and may include $comma for comma, $sp for space and $empty to split at each character. Default separator is one or more spaces ($sp$sp*).

SQRT( num ) -- square root of a number

Syntax: $SQRT( num )

Changed:

<<

Example: %CALC{"$SQRT(16)"}% returns 4

>>

Example: %CALC{$SQRT(16)}% returns 4

SUBSTITUTE( text, old, new, instance, option ) -- substitute text

Substitutes new text for old text in a text string. instance specifies which occurance of old you want to replace. If you specify instance, only that instance is replaced. Otherwise, every occurance is changed to the new text. A literal search is performed by default; a RegularExpression search if the option is set to r

SUMDAYS( list ) -- sum the days in a list or range of cells

The total number of days in a list or range of cells containing numbers of hours, days or weeks. The default unit is days; units are indicated by a h, hours, d, days, w, weeks suffix. One week is assumed to have 5 working days, one day 8 hours

T( address ) -- content of a cell

TRANSLATE( text, from, to ) -- translate text from one set of characters to another

The translation is done from a set to a set, one character by one. The text may contain commas; all three parameters are required. In the from and to parameters you can add token $comma for comma, $sp for space, and $n for newline

The unit is seconds if not specified; unit can be specified as in $TIMEADD().

Notes: An approximation is used for month and year calculations. Use $ROUND() to round day unit to account for daylight savings time change. Use $FORMAT(), $FORMATTIMEDIFF() or $INT() to format real numbers

TRANSLATE( text, from, to ) -- translate text from one set of characters to another

The translation is done from a set to a set, one character by one. The text may contain commas; all three parameters are required. In the from and to parameters you can add token $comma for comma, $sp for space, and $n for newline

WHILE( condition, do ) -- do something while a condition is true

The condition can be a number (where 0 means condition not met), or two numbers with a comparison operator < (less than), <= (less than or equal), == (equal), != (not equal), >= (greater than or equal), > (greater than).

The condition and do are evaluated in each cycle; a $counter starting at 1 can be used in condition and do.

FAQ

You need to escape the CALC so that it executes once per search hit. This can be done by escaping the % signs of %CALC{...}% with $percnt. For example, to execute $IF($EXACT($formfield(Tested), Yes), %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/choice-yes.gif, %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/choice-no.gif) in the format="" parameter, write this:

>>

You need to escape the CALC so that it executes once per search hit. This can be done by escaping the % signs of %CALC{...}% with $percnt. For example, to execute $IF($EXACT($formfield(Tested), Yes), %ICONURL{choice-yes}%, %ICONURL{choice-no}%) in the format="" parameter, write this: