The latest
SpreadSheetPlugin has two new variables
$SET() and
$GET(). This can be used to define named variables in a topic for later use. Here are the docs:
"$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; formulas are evaluated before the variable assignment. 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. See also $GET(). 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 |
"$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. See also $SET(). Example: %CALC{"$GET( my_total )"}% returns the value of the my_total variable |
This feature was mainly inspired by the limitation of the Plugin where values in one table could not be carried over to tables located further below. For example:
Grand total: 16
This can also be used to set a text once and reuse it over and over again. Example:
%CALC{"$SET(foo, this is a long long text I want to repeat)"}%
- this is a long long text I want to repeat
- this is a long long text I want to repeat
- this is a long long text I want to repeat
- this is a long long text I want to repeat
- this is a long long text I want to repeat
- this is a long long text I want to repeat
This is a silly example. A library of named variables could be INCLUDEd from another topic. Wondering for what kind of web applications (e.g.
TWikiApplication) this can be used. Ideas?
--
PeterThoeny - 26 Oct 2003
What may be also useful is a
GET using a
$pattern construct to fetch text in the current topic via a regexp. But this is just off the top of my head, no actual example yet
--
ColasNahaboo - 27 Oct 2003