Technical References - [text]

Text variables are fundamental building blocks of the WebDNA language. They are simple to understand and easy to weave into your code.

numero = 77
interpreted = N
texte = [text]variablename=value[/text] Retrieve by using [variablename] anywhere afterwards. One valuable way of using a text variable is to set the value of something repetitive, so you don't have to do it over and over on the page. This way, there is only one place to edit. Example:
[text]maincolor=#660000[/text][text]secondcolor=#eebb21[/text][text]thirdcolor=#f0e2b8[/text]
Then, in the style sheet area following, you can use these variables for colors, and when you tweak color schemes, you only have to change them in one place.
<style type="text/css"><!--.mainhead { font-weight: bold;    font-size: 25px ; color:[maincolor] }.subhead  { color: [secondcolor]; font-weight: bold; font-size: 13px }.menubar  { color:[thirdcolor];   background-color: [maincolor]; }....plus the dozens more styles with colors involved.--></style>
Note that you could also use [text multi=t] to set the string of colors in one shot. But I find them more readable when stacked as in the above example.

the name of a text variable is limited to 49 characters.

Text variables can be numbers, and they can be used in math equations. A number is still a number, as long as it isn't tainted with non-numerical characters (i.e. 24a would not work as a number).
Parameters Description
multi (optional) "T" or "F". Allows you to assign more than one text variable in a single context. [text multi=T]var1=Joe&var2=Fred[/text] simultaneously assigns the two variables. (There is no need to use multi=f for single variables.)
show(optional) "T" or "F". Default behavior is to hide the value when assigning to a text variable (the opposite of a math variable). If you want the value to be shown at the same time it is assigned to a variable, you may set Show=T. But if you set multi=T at the same time, then no values will be displayed. (There is no reason to ever use show=f, as this is default behavior.)
secure(optional) "T" or "F". Default is "T". Setting secure=F makes the text variable overrideable by incoming form variables. This is not recommended, and the default behavior is secure. Sometimes you might want a form on the preceding page to override an embedded variable, and in this case, you'd use secure=f for the embedded text contect. However, this also makes it possible for a visitor to type in the name=value pair in the URL, which would override the embedded one. So use this with caution, only if no harm could result.

WebDNA expects anything after the = to be part of the set variable. If the value also contains an =, this will not mess anything up, and in fact, it is not uncommon to set a variable consisting of a string such as db=somedb.db&eqsomefielddatarq=value&somefieldsort=1, to be used in a search context later. Something like this would of course not work in a [text multi=t] situation.

If you forget to put the closing [/text] tag, then the entire rest of the page will not display, being assumed to be part of the variable. Historical behavior: Originally, a text variable had to be retrieved by using this format: [text]variablename[/text]. It will still work this way. If you inadvertantly code something without an = sign, nothing bad will happen; the seemingly unknown variable will simply resolve to blank. This behavior can be used to your advantage if you sometimes set a variable, and sometimes do not (on the same page) depending on the condition. When retrieving, if the variable is unknown, you would get the variable name surrounded by square brackets, but merely a blank if using the old syntax.

All you ever wanted to know about Variable Types

So, do you access all variable values using the syntax [XXX]? You may want to reconsider it.. or at least consider further this usage. This is because variables that have the same name, can have different values in WebDNA.. just as in C++ and other languages. So does WebDNA have a preference on what type it displays as default? Yes. below is the code that you can paste into your own blank template and save to a WebDNA server to test it yourself!
<!--HAS_WEBDNA_TAGS--><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"        "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="content-type" content="text/html; charset=iso-8859-1"><title>Variables</title><meta name="generator" content="BBEdit 7.0.1"></head><body><b>Can a variable be named the same and have different values?</b><hr>Here is a variable named <b>"myVar"</b> that is of the types"math" and "text". (see at bottom for "form")<br><br><b>The Code:</b><br><pre>[input][raw]<b>The Results</b><br>[text]myVar=text[/text][math show=F]myVar=1[/math]Which variable type takes precedence?<br>Answer: [myVar]<br><br>Methods to be sure to display specific types of variables:<br>TextVar = [listvariables type=text&name=myVar][value][/listvariables]<br>MathVar = [listvariables type=math&name=myVar][value][/listvariables]<br>[hideif [url][formvariables name=myVar][value][/formvariables][/url]=]FormVar = [formvariables name=myVar][value][/formvariables]<br>[/hideif]<br>TextVar = [myVar]<br>MathVar = [math]myVar[/math]<br><br>What about Form Variables?<br>Formvariables work in the same way. Try appending to this URL"?myVar=FormVar" and see what you get.[/raw][/input]</pre><hr> <b>The Results</b><br>[text]myVar=text[/text][math show=F]myVar=1[/math]Which variable type takes precedence?<br>Answer: [myVar]<br><br>Methods to be sure to display specific types of variables:<br>TextVar = [listvariables type=text&name=myVar][value][/listvariables]<br>MathVar = [listvariables type=math&name=myVar][value][/listvariables]<br>[hideif [url][formvariables name=myVar][value][/formvariables][/url]=]FormVar = [formvariables name=myVar][value][/formvariables]<br>[/hideif]<br>TextVar = [myVar]<br>MathVar = [math]myVar[/math]<br><br>What about Form Variables?<br>Formvariables work in the same way. Try appending to this URL"?myVar=FormVar" and see what you get.<hr></body></html>
The Results Which variable type takes precedence? Answer: text Methods to be sure to display specific types of variables: TextVar = text MathVar = 1 TextVar = text MathVar = 1 What about Form Variables? Formvariables work in the same way. Try appending to this URL "?myVar=FormVar" and see what you get.

There are a few 'reserved' scope names: "global" - refers to the 'normal/secure' template variable space. "local" - When used inside of a function or scope context, refers to the variable space associated with the current function or scope. "insecure" - Refers to the 'insecure' template variable space (this space also includes HTML form variables).

[text]variablename=value[/text]

Retrieve by using [variablename] anywhere afterwards.

One valuable way of using a text variable is to set the value of something repetitive, so you don't have to do it over and over on the page. This way, there is only one place to edit.

Example:

[text]maincolor=#660000[/text]
[text]secondcolor=#eebb21[/text]
[text]thirdcolor=#f0e2b8[/text]


Then, in the style sheet area following, you can use these variables for colors, and when you tweak color schemes, you only have to change them in one place.

<style type="text/css"><!--
.mainhead { font-weight: bold; font-size: 25px ; color:[maincolor] }
.subhead { color: [secondcolor]; font-weight: bold; font-size: 13px }
.menubar { color:[thirdcolor]; background-color: [maincolor]; }
....plus the dozens more styles with colors involved.
--></style>


Note that you could also use [text multi=t] to set the string of colors in one shot. But I find them more readable when stacked as in the above example.

the name of a text variable is limited to 49 characters.



Text variables can be numbers, and they can be used in math equations. A number is still a number, as long as it isn't tainted with non-numerical characters (i.e. 24a would not work as a number).

Parameters Description
multi (optional) "T" or "F". Allows you to assign more than one text variable in a single context. [text multi=T]var1=Joe&var2=Fred[/text] simultaneously assigns the two variables. (There is no need to use multi=f for single variables.)
show(optional) "T" or "F". Default behavior is to hide the value when assigning to a text variable (the opposite of a math variable). If you want the value to be shown at the same time it is assigned to a variable, you may set Show=T. But if you set multi=T at the same time, then no values will be displayed. (There is no reason to ever use show=f, as this is default behavior.)
secure(optional) "T" or "F". Default is "T". Setting secure=F makes the text variable overrideable by incoming form variables. This is not recommended, and the default behavior is secure. Sometimes you might want a form on the preceding page to override an embedded variable, and in this case, you'd use secure=f for the embedded text contect. However, this also makes it possible for a visitor to type in the name=value pair in the URL, which would override the embedded one. So use this with caution, only if no harm could result.


WebDNA expects anything after the = to be part of the set variable. If the value also contains an =, this will not mess anything up, and in fact, it is not uncommon to set a variable consisting of a string such as db=somedb.db&eqsomefielddatarq=value&somefieldsort=1, to be used in a search context later. Something like this would of course not work in a [text multi=t] situation.



If you forget to put the closing [/text] tag, then the entire rest of the page will not display, being assumed to be part of the variable.

Historical behavior: Originally, a text variable had to be retrieved by using this format: [text]variablename[/text]. It will still work this way. If you inadvertantly code something without an = sign, nothing bad will happen; the seemingly unknown variable will simply resolve to blank. This behavior can be used to your advantage if you sometimes set a variable, and sometimes do not (on the same page) depending on the condition. When retrieving, if the variable is unknown, you would get the variable name surrounded by square brackets, but merely a blank if using the old syntax.

All you ever wanted to know about Variable Types



So, do you access all variable values using the syntax [XXX]? You may want to reconsider it.. or at least consider further this usage. This is because variables that have the same name, can have different values in WebDNA.. just as in C++ and other languages.

So does WebDNA have a preference on what type it displays as default? Yes. below is the code that you can paste into your own blank template and save to a WebDNA server to test it yourself!

<!--HAS_WEBDNA_TAGS-->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title>Variables</title>
<meta name="generator" content="BBEdit 7.0.1">
</head>
<body>
<b>Can a variable be named the same and have different values?</b><hr>

Here is a variable named <b>"myVar"</b> that is of the types
"math" and "text". (see at bottom for "form")<br><br>

<b>The Code:</b><br>
<pre>[input][raw]
<b>The Results</b><br>
[text]myVar=text[/text]
[math show=F]myVar=1[/math]

Which variable type takes precedence?<br>
Answer: [myVar]<br><br>

Methods to be sure to display specific types of variables:<br>
TextVar = [listvariables type=text&name=myVar][value][/listvariables]<br>
MathVar = [listvariables type=math&name=myVar][value][/listvariables]<br>
[hideif [url][formvariables name=myVar][value][/formvariables][/url]=]
FormVar = [formvariables name=myVar][value][/formvariables]<br>
[/hideif]
<br>

TextVar = [myVar]<br>
MathVar = [math]myVar[/math]<br><br>

What about Form Variables?<br>
Formvariables work in the same way. Try appending to this URL
"?myVar=FormVar" and see what you get.
[/raw][/input]</pre>

<hr>

<b>The Results</b><br>
[text]myVar=text[/text]
[math show=F]myVar=1[/math]

Which variable type takes precedence?<br>
Answer: [myVar]<br><br>

Methods to be sure to display specific types of variables:<br>
TextVar = [listvariables type=text&name=myVar][value][/listvariables]<br>
MathVar = [listvariables type=math&name=myVar][value][/listvariables]<br>
[hideif [url][formvariables name=myVar][value][/formvariables][/url]=]
FormVar = [formvariables name=myVar][value][/formvariables]<br>
[/hideif]
<br>

TextVar = [myVar]<br>
MathVar = [math]myVar[/math]<br><br>

What about Form Variables?<br>
Formvariables work in the same way. Try appending to this URL
"?myVar=FormVar" and see what you get.
<hr>

</body>
</html>


The Results

Which variable type takes precedence?
Answer: text

Methods to be sure to display specific types of variables:
TextVar = text
MathVar = 1

TextVar = text
MathVar = 1

What about Form Variables?
Formvariables work in the same way. Try appending to this URL
"?myVar=FormVar" and see what you get.

There are a few 'reserved' scope names:

"global" - refers to the 'normal/secure' template variable space.
"local" - When used inside of a function or scope context, refers to the variable space associated with the current function or scope.
"insecure" - Refers to the 'insecure' template variable space (this space also includes HTML form variables).

Terry Wilson

DOWNLOAD WEBDNA NOW!

Top Articles:

Tips and Tricks

A list of user-submitted tips ...

AWS Raw WebDNA LAMP-Plus WebServer

Amazon Web Services (AWS) README for Machine Image ID...

F.A.Q

A compilation of some user's questions...

WebDNA Modules

A list of the currently available modules...

[biotype]

BioType is a behavioral biometrics WebDNA function based on ADGS research and development (from version 8...

Download WebDNA Applications

WebDNA applications...

Related Readings:

[findstring]

[FindString Source=...

[shell]

[shell] is a way to use the command line with your webserver...

[include]

Include the contents of the specified file...

[lowercase]

Changes all upper case letters to lower case...

[showif]

[showif Comparison]Show This HTML[/showif]...

[listmimeheaders]

Lists all the MIME header names and values sent from the remote browser...