blob: 148b996de8543f6f71f77ba1413ab42844d4479e [file] [log] [blame]
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>var</title><link rel="stylesheet" type="text/css" href="rivet.css"><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"><link rel="home" href="index.html" title="Apache Rivet 3.0"><link rel="up" href="commands.html" title="Rivet Tcl Commands and Variables"><link rel="prev" href="url_script.html" title="url_script"><link rel="next" href="wrap.html" title="wrap"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">var</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="url_script.html"><img src="images/prev.png" alt="Prev"></a> </td><th width="60%" align="center">Rivet Tcl Commands and Variables</th><td width="20%" align="right"> <a accesskey="n" href="wrap.html"><img src="images/next.png" alt="Next"></a></td></tr></table></div><div class="refentry"><div class="refentry.separator"><hr></div><a name="var"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>var, var_qs, var_post — get the value of a form variable.</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis" style="width:80%"><div style="border: 1px solid #282; margin:1ex ; padding:.4ex; padding-left: 0.8ex; word-spacing:1ex "><span style="font-weight:bold ; font-family:monospace">::rivet::var</span> (<span style="font-family:monospace; font-weight: bold;">get</span> | <span style="font-family:monospace; font-weight: bold;">list</span> | <span style="font-family:monospace; font-weight: bold;">exists</span> | <span style="font-family:monospace; font-weight: bold;">number</span> | <span style="font-family:monospace; font-weight: bold;">all</span>)</div></div><div class="cmdsynopsis" style="width:80%"><div style="border: 1px solid #282; margin:1ex ; padding:.4ex; padding-left: 0.8ex; word-spacing:1ex "><span style="font-weight:bold ; font-family:monospace">::rivet::var_qs</span> (<span style="font-family:monospace; font-weight: bold;">get</span> | <span style="font-family:monospace; font-weight: bold;">list</span> | <span style="font-family:monospace; font-weight: bold;">exists</span> | <span style="font-family:monospace; font-weight: bold;">number</span> | <span style="font-family:monospace; font-weight: bold;">all</span>)</div></div><div class="cmdsynopsis" style="width:80%"><div style="border: 1px solid #282; margin:1ex ; padding:.4ex; padding-left: 0.8ex; word-spacing:1ex "><span style="font-weight:bold ; font-family:monospace">::rivet::var_post</span> (<span style="font-family:monospace; font-weight: bold;">get</span> | <span style="font-family:monospace; font-weight: bold;">list</span> | <span style="font-family:monospace; font-weight: bold;">exists</span> | <span style="font-family:monospace; font-weight: bold;">number</span> | <span style="font-family:monospace; font-weight: bold;">all</span>)</div></div></div><div class="refsect1"><a name="idm1800"></a><h2>Description</h2><p style="width:90%">
The <span style="font-family:monospace"><span class="command"><strong>var</strong></span></span> command retrieves information
about GET or POST variables sent to the script via client
request. It treats both GET and POST variables the same,
regardless of their origin. Note that there are two
additional forms of <span style="font-family:monospace"><span class="command"><strong>::rivet::var</strong></span></span>:
<span style="font-family:monospace"><span class="command"><strong>rivet::var_qs</strong></span></span> and
<span style="font-family:monospace"><span class="command"><strong>::rivet::var_post</strong></span></span>.
These two restrict the retrieval of information to
parameters arriving via the querystring
(?foo=bar&amp;bee=bop) or POSTing, respectively.
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
<div class="cmdsynopsis" style="width:80%"><div style="border: 1px solid #282; margin:1ex ; padding:.4ex; padding-left: 0.8ex; word-spacing:1ex "><span style="font-weight:bold ; font-family:monospace">::rivet::var</span> <span style="font-family:monospace; font-weight: bold;">get</span> ?<span style="font-family:monospace; font-weight: bold;"><em class="replaceable"><code>varname</code></em></span>? ?<span style="font-family:monospace; font-weight: bold;"><em class="replaceable"><code>?<span class="optional">default</span>?</code></em></span>?</div></div>
</span></dt><dd><div style="padding:4 ; margin-top:3 ; margin-bottom:3 ; width:75%"><div style="margin-bottom:1.5ex ; padding .5ex">
Returns the value of variable
<em class="replaceable"><code>varname</code></em>
as a string (even if there are multiple values). If
the variable doesn't exist as a GET or POST
variable, the
<em class="replaceable"><code>?<span class="optional">default</span>?</code></em>
value is returned, otherwise "" - an empty string -
is returned.
</div></div></dd><dt><span class="term">
<div class="cmdsynopsis" style="width:80%"><div style="border: 1px solid #282; margin:1ex ; padding:.4ex; padding-left: 0.8ex; word-spacing:1ex "><span style="font-weight:bold ; font-family:monospace">::rivet::var</span> <span style="font-family:monospace; font-weight: bold;">list</span> ?<span style="font-family:monospace; font-weight: bold;"><em class="replaceable"><code>varname</code></em></span>?</div></div>
</span></dt><dd><div style="padding:4 ; margin-top:3 ; margin-bottom:3 ; width:75%"><div style="margin-bottom:1.5ex ; padding .5ex">
Returns the value of variable
<em class="replaceable"><code>varname</code></em> as a list,
one list element per reference. Radiobuttons or multiple
selection listboxes are suited widgets which may
return list data.
</div><div style="margin-bottom:1.5ex ; padding .5ex">
If the result list is passed as a default value to the form package, one
could also set index "__varname" to get it interpreted as a list.
</div><pre class="programlisting">set response(countries) [::rivet::var list countries]
set response(__countries) ""
form form_request -defaults response
form_request select countries -multiple 1 -values {USA Canada Mexico}
form_request end</pre></div></dd><dt><span class="term">
<div class="cmdsynopsis" style="width:80%"><div style="border: 1px solid #282; margin:1ex ; padding:.4ex; padding-left: 0.8ex; word-spacing:1ex "><span style="font-weight:bold ; font-family:monospace">::rivet::var</span> <span style="font-family:monospace; font-weight: bold;">exists</span> ?<span style="font-family:monospace; font-weight: bold;"><em class="replaceable"><code>varname</code></em></span>?</div></div>
</span></dt><dd><div style="padding:4 ; margin-top:3 ; margin-bottom:3 ; width:75%"><div style="margin-bottom:1.5ex ; padding .5ex">
Returns 1 if
<em class="replaceable"><code>varname</code></em>
exists, 0 if it doesn't.
</div></div></dd><dt><span class="term">
<div class="cmdsynopsis" style="width:80%"><div style="border: 1px solid #282; margin:1ex ; padding:.4ex; padding-left: 0.8ex; word-spacing:1ex "><span style="font-weight:bold ; font-family:monospace">::rivet::var</span> <span style="font-family:monospace; font-weight: bold;">number</span> </div></div>
</span></dt><dd><div style="padding:4 ; margin-top:3 ; margin-bottom:3 ; width:75%"><div style="margin-bottom:1.5ex ; padding .5ex">
Returns the number of variables.
</div></div></dd><dt><span class="term">
<div class="cmdsynopsis" style="width:80%"><div style="border: 1px solid #282; margin:1ex ; padding:.4ex; padding-left: 0.8ex; word-spacing:1ex "><span style="font-weight:bold ; font-family:monospace">::rivet::var</span> <span style="font-family:monospace; font-weight: bold;">all</span> </div></div>
</span></dt><dd><div style="padding:4 ; margin-top:3 ; margin-bottom:3 ; width:75%"><div style="margin-bottom:1.5ex ; padding .5ex">
Return a list of variable names and values.
</div></div></dd></dl></div><p style="width:90%">See <a class="xref" href="examples.html#variable_access" title="Example 3. Variable Access">Example 3, “Variable Access”</a>.</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="url_script.html"><img src="images/prev.png" alt="Prev"></a> </td><td width="20%" align="center"><a accesskey="u" href="commands.html"><img src="images/up.png" alt="Up"></a></td><td width="40%" align="right"> <a accesskey="n" href="wrap.html"><img src="images/next.png" alt="Next"></a></td></tr><tr><td width="40%" align="left" valign="top">url_script </td><td width="20%" align="center"><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a></td><td width="40%" align="right" valign="top"> wrap</td></tr></table></div></body></html>