Tags:
create new tag
view all tags
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:

Table 1 Value
foo 3
bar 2
sub-total: 5

Table 2 Value
moo 7
wouf 4
sub-total: 11

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

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2004-05-20 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.