Lasso Soft Inc. > Home

  • Tutorials

Using Logic

One of the key things you need to learn to do when making a web page dynamic is introduce "logic". When would you need logic? Below are some examples.

You could use logic when:

  • You want to have something on the page change at a certain time
  • You want to have something on the page change after a certain date
  • You want to display things differently to different people

Let's say, for example, that you wish the text on your page to say "Good Morning" in the morning, and "Good Afternoon" in the afternoon.

<body>Good Morning! I am an HTML document.</body>
and
<body>Good Afternoon! I am an HTML document.</body>

 

The long way around is to open the document at noon and midnight every day and change the text manually. This might get a little frustrating after a while. Alternatively, you can use "conditional logic". Using Lasso, here is a way to achieve this:

[if:(date)>'12:00'&&(date)<'00:00']
<body>Good Morning! I am an HTML document.</body>
[else]
<body>Good Afternoon! I am an HTML document.</body>
[/if]

 

In other words, IF the time is before noon AND the time is after midnight, then show "Good Morning". Otherwise (ELSE), show "Good Afternoon". We would probably want to add a "Good Evening" as well. We would just add some more conditional logic;

[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 the text in our document will read correctly depending on the time that people come to our page. In Lasso, you can also write this differently, through a "script";

I'm going to stick to the "embedded" language, just for simplicity. We'll talk about style later.

As you can see, Lasso is a simple methodology to direct the server to change the content of pages as you fly. It is easy to read, easy to understand, and easy to implement.

There are many additional Methods that can help you, especially where you are getting into multiple levels of complexity. Method definitions and examples are found in the Reference section.

Now that we have logic under control, let's talk about variable information.

Next Tutorial: Using Variable Information

Comments

No comments found
You must be logged in to comment.

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. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft