SetGetPlugin

Set and get variables

Introduction

Use %SET{}% to store arbitrary text in a named variable, and reuse it with %GET{}% later on within the topic or an included topics. These variables live only during topic rendering time, e.g. they do not persist between topic views. This is an alternative to:

  • TWiki preferences settings: Can be defined on a site level (TWikiPreferences), web level (WebPreferences) and topic level. Preferences settings persist until changed.
  • SpreadSheetPlugin variables: Variables can be set with %CALC{$SET(some_name, anything)}% and retrieved with $GET(). These variables persist during page rendering time. A limitation of %CALC{} is that it does not follow the standard TWiki variable evaluation order (nesting inside out, left to right).

%SET{}% and %GET{}% can be nested inside other TWiki variables and get handled as expected, e.g. inside out, and left to right.

Syntax Rules

SET{"name" value="..."} -- set a variable

  • Set a named variable, can be retrieved later with %GET{}%.
  • Syntax: %SET{"name" value="..."}%
  • Example: %SET{"lunch" value="Sushi"}%
  • Related: GET, SpreadSheetPlugin#FuncSET

GET{"name"} -- get a variable

  • Get the value of a named variable, previously set with %SET{}%.
  • Syntax: %GET{"name"}%
  • Example: %GET{"lunch"}% returns Sushi if this has been previously set: %SET{"lunch" value="Sushi"}%
  • Related: SET, SpreadSheetPlugin#FuncGET

Plugin Settings

Plugin settings are stored as preferences variables. To reference a plugin setting write %<plugin>_<setting>%, i.e. %NEWPLUGIN_SHORTDESCRIPTION%

  • One line description, is shown in the TextFormattingRules topic:
    • Set SHORTDESCRIPTION = Set and get variables

  • Debug plugin: (See output in data/debug.txt)
    • Set DEBUG = 0

Plugin Installation Instructions

Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the TWiki server.

  • Download the ZIP file from the Plugin Home (see below)
  • Unzip SetGetPlugin.zip in your twiki installation directory. Content:
    File: Description:
    data/TWiki/SetGetPlugin.txt Plugin topic
    lib/TWiki/Plugins/SetGetPlugin.pm Plugin Perl module
    lib/TWiki/Plugins/SetGetPlugin/Core.pm Core Perl module
  • Configure the Plugin:
    • Run the configure script to enable the plugin
  • Test if the installation was successful:
    • The next bullet should show: Result: Yes, it works!
    • Result: Yes, it works!

Plugin Info

Plugin Author: TWiki:Main/PeterThoeny
Copyright: © 2010, TWiki:Main/PeterThoeny
License: GPL (GNU General Public License)
Plugin Version: 2010-10-17 (V1.0)
Change History:  
2010-10-17: Initial version
TWiki Dependency: $TWiki::Plugins::VERSION 1.1
CPAN Dependencies: none
Other Dependencies: none
Perl Version: 5.005
Benchmarks: GoodStyle 100%, FormattedSearch 99%, SetGetPlugin 99%
Plugin Home: http://TWiki.org/cgi-bin/view/Plugins/SetGetPlugin
Feedback: http://TWiki.org/cgi-bin/view/Plugins/SetGetPluginDev
Appraisal: http://TWiki.org/cgi-bin/view/Plugins/SetGetPluginAppraisal

Related Topics: VarSET, VarGET, TWikiPlugins, DeveloperDocumentationCategory, AdminDocumentationCategory, TWikiPreferences


Current Tags:
create new tag
, view all tags
Topic revision: r2 - 2010-11-21 - 23:24:19 - TWikiAdminUser
 

Computational Fluid Dynamics and Turbulence Mechanics
@ the University of Manchester
This site is powered by the TWiki collaboration platformCopyright & by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.SetGetPlugin