When the solution matters

Tips...

Registration Documentation Knowledgebase Seminars / Training Partner Programs 4D Partner Central

IfAndInclude

The next step is to create the WebFolder. This is the folder where the "index.shtml" file will be saved. You should create the WebFolder in the same directory in which your "IfAndInclude" 4D structure file was saved. Once you have created the folder, you should launch your favorite text editor, create a new document, and type the following into it:

<html>
<head>
<title>4D Web Tags</title>
</head>
<body>
<!--4DIF (random%2=0)-->
This is even!
<!--4DELSE-->
This is odd!
<!--4DENDIF-->
</body>
</html>

screenshot

Save the text file as "index.shtml" inside the WebFolder. Your text editor should look something like the one in the picture above.

This is a very simple example that illustrates the use of the 4DIF tag. 4DIF has a couple of other tags associated with it: 4DELSE and 4DENDIF. The 4DIF tag is used to evaluate an expression. The expression can be any valid 4th Dimension expression that evaluates to either True or False.

The example expression is (random%2=0). Random is a 4th Dimension function that gives a random number as a result. The % symbol is the "modulo" operator - it finds the "remainder"after one number is divided by another. So this expression will return True if a random number is divisible by two - in other words, if the random number is even or not.

Now launch your web browser and type "127.0.0.1" into the address bar. If everything is properly configured, you should see either "This is even!" or "This is odd!" displayed on the web page. Hit the reload button a few times. You should see the even and odd messages displayed at random.

Previous Step  1 2 3  Next Step


International | Company | Contact 4D | Site Map | Privacy Policy | © 4D, Inc. 1995-2008 | Change font size: [A] [A] [A] | Print this page | 4D RSS Feeds