Global Variables

Variables will allow you to place replacement strings inside of your html and param files. This can be handy when you want to change the look at feel of a variety of pages quickly. Or to have a single place to make changes. As an example you can take a look at the variables theme, variable.var, and variable.prm files.
The first type of variable is a simple replacement. It looks for a value in the variable file and replaces that in the designated variable in the html page. Let's try it. First you have to create a file in the variables directory for this we'll use the file name of items.var:

yourname=John

Save that file.

Now create an html file in the data or htdocs directory called items.htm:

<html>
%_load items.var%
<body>
Hello %yourname%<br>
</body>
</html>

Now save and view that file and you'll see:

Hello John

The next type of variable is called a conditional and this will take a block and allow, or not allow based on the value being set to yes, true or 1. Now add this line to items.var so it reads:

yourname=John
showitems=yes

And add the follwing to items.htm:

<html>
%_load items.var%
<body>
Hello %yourname%<br>
Start Items<br>
%!?showitems%
Item1<br>
Item2<br>
Item3<br>
%!%
End Items
</body>
</html>

Now read that file and you'll see:

Hello John
Start Items
Item1
Item2
Item3
End Items

Now if you change the items.var file to read:

showitems=no

Save it you'll see:

Hello John
Start Items
End Items

Now just to make this complete lets also add this to items.var:

showname=false
yourname=John
showitems=1

Save that and then add this to the items.htm file:

<html>
%_load items.var%
<body>
%!?showname%
Hello %yourname%<br>
%!%
Start Items<br>
%!?showitems%
Item1<br>
Item2<br>
Item3<br>
%!%
End Items
</body>
</html>

Now if you reload you'll see this:

Start Items
Item1
Item2
Item3
End Items

You can load one variable file in many different pages and so it's possible to modify the HTML and the param files by a single file. See what we allow you to change in the scribe default file.