Chapter 15 Conditional Expressions

Table of Contents
15.1 Use of Conditional Expressions
15.2 Ifdef
15.3 Ifdef Example
15.4 Ifndef
15.5 Ifndef Example
15.6 If
15.7 If Example
15.8 Nested Conditionals
15.9 Nested Conditionals Example

A Conditional Expression is essentially a directive telling Cows whether or not to execute a block of statements. Other forms of Conditional Expressions allow to choose among multiple blocks of statements.

15.1 Use of Conditional Expressions

Cows' conditional expressions seem useless since conditions are only tested during the creation of your web pages. In other words, you are testing a condition but you already know the result!

The idea is to allow a single file to be used in various contexts; if you have a programming background, just think they work like C preprocessor conditionals. Depending on a variable's value, or if it is defined or not, a block of statements will be executed or not, or a block will be executed instead of another one.

In other words, the same file will change its behavior according to the situation: you only have to define certain variables before including a file. You can also define a variable with the -D command line option when running Cows.

This manual can be downloaded from http://www.g-cows.org/.