If we look at our last tutorial, we can see that through conditional logic we can achieve changes to the content of our page through simple IF statements, like so;
[if:(date)>'12:00'&&(date)<'00:00']
<body>Good Morning! I am an HTML document.</body>
[else:(date)>'18:00'&&(date)<'00:00']
<body>Good Afternoon! I am an HTML document.</body>
[else]
<body>Good Evening! I am an HTML document.</body>
[/if]
One of the catches with this is that the code do achieve this small is very bulky and very difficult to read and change later. If we decided to change the line "I am an HTML document", we would have to replace the text three times. This would be tedious work. So instead, we can set a "variable" piece of information and assign it to a "cut and paste"-like clipboard for use later. Then we can trigger a change to the content using this clipboard information.
We can create a variable by simply naming it like so;
[Variable: 'Salutation' = 'Hello']
Most people are far to lazy too type out the word "variable" over and over again, so instead they simple write it like so;
[Var: 'Salutation' = 'Hello']
Now we have a special clipboard of memory called "salutation", with the value of "Hello". In our document, we would write the following;
[Var: 'Salutation' = 'Hello']
<body>[Variable: 'Salutation']! I am an HTML document</body>
And the final user would see the following;
<body>Hello! I am an HTML document</body>
As programmers are lazy, and wish to type as little as possible (you'll see a trend here), they would actually use the shorthand method, which looks something like this;
[Var: 'Salutation' = 'Hello']
<body>[$Salutation]! I am an HTML document</body>
This just means that a page-level variable has been created and this shorthand will return it correctly.
Now if we return to our logic, you can see that this will save us quite a bit of typing and make things simpler for us in the future. Here's the original code again;
[if:(date)>'12:00'&&(date)<'00:00']
<body>Good Morning! I am an HTML document.</body>
[else:(date)>'18:00'&&(date)<'00:00']
<body>Good Afternoon! I am an HTML document.</body>
[else]
<body>Good Evening! I am an HTML document.</body>
[/if]
Now let's start by using our conditional logic and variables together. Watch how this works;
[if:(date)>'12:00'&&(date)<'00:00']
[Var: 'Salutation' = 'Good Morning']
[else:(date)>'18:00'&&(date)<'00:00']
[Var: 'Salutation' = 'Good Afternoon']
[else]
[Var: 'Salutation' = 'Good Evening']
[/if]
<body>[$Salutation]! I am an HTML document</body>
This achieves the same result as our previously bulky code, but allows us to manage our content in a much more simplistic manner. We'll be less likely to make mistakes later (with information repeated) and can easily add additional pieces of logic to define what our page might look like to the end user. For example, let's say we wished to change "I am an HTML document" to "I am a web page", this visible text now only appears once. Instead of digging aimlessly through our document, we can use Lasso logic to help us get things done faster.
Now that we understand the logic, let's try grouping it together in a more intelligent manner.
Next Tutorial: Using Groups of Information
Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft