15.7 If Example

15.7.1 Source file (various/if.cws)

<h1> This is a minimal example about if statement </h1>

<h2> Comparing a variable and a constant string </h2>

<cows>

var = "something";

// The following condition will evaluate to TRUE so the first
// statements block will be executed

if (var == "something") {
  print ("<p> The beef industry has contributed to more American");
  print ("deaths than all the wars of this century, all natural");
  print ("disasters, and all automobile accidents combined. ");
  print ("If beef is your idea of \"real food for real people\",");
  print ("you'd better live real close to a real good hospital.<br>");
  print ("-- Neal D. Barnard, M.D., ");
  print ("President Physicians Committee for Responsible Medicine\n");
} else {
  // We'll never get here
  print ("We'll never display this ...");
}

// The following condition will also evaluate to TRUE so the first
// statements block will be executed

if (var != "something else") {
  print ("<p> The average age (longevity) of a meat eater is 63.");
  print ("I am on the verge of 85 and still work as hard as ever.");
  print ("I have lived quite long enough and am trying to die; but I");
  print ("simply cannot do it. A single beef-steak would finish me;");
  print ("but I cannot bring myself to swallow it. I am oppressed");
  print ("with a dread of living forever.");
  print ("That is the only disadvantage of vegetarianism. <br>");
  print ("-- George Bernard Shaw\n");
} else {
  // We'll never get here
  print ("We'll never display this ...");
}

</cows>

<h2> Comparing two variables </h2>

<cows>

var1 = var2 = "Something";

// The following condition will evaluate to TRUE so the first
// statements block will be executed

if (var1 == var2) {
  print ("<p> Vegetarians have the best diet. They have the lowest");
  print ("rates of coronary disease of any group in the country ...");
  print ("Some people scoff at vegetarians, but they have a fraction");
  print ("of our heart attack rate and they have only 40 percent of");
  print ("our cancer rate.");
  print ("They outlive other men by about six years now. <br>");
  print ("-- Dr.William Castelli,M.D.\n");
} else {
  print ("<p> Nothing's changed my life more. I feel better about");
  print ("myself as a person, being conscious and responsible for");
  print ("my actions and I lost weight and my skin cleared up and");
  print ("I got bright eyes and I just became stronger and healthier");
  print ("and happier. Can't think of anything better in the world");
  print ("to be but be vegan <br>");
  print ("-- Alicia Silverstone\n");
}

var2 = "Something else";

// Now, the same condition above will evaluate to FALSE so the
// else-block will be executed

if (var1 == var2) {
  print ("<p> Vegetarians have the best diet. They have the lowest");
  print ("rates of coronary disease of any group in the country ...");
  print ("Some people scoff at vegetarians, but they have a fraction");
  print ("of our heart attack rate and they have only 40 percent of");
  print ("attack rate and they have only 40 percent of our cancer");
  print ("rate. They outlive other men by about six years now. <br>");
  print ("-- Dr.William Castelli,M.D.\n");
} else {
  print ("<p> Nothing's changed my life more. I feel better about");
  print ("myself as a person, being conscious and responsible for");
  print ("my actions and I lost weight and my skin cleared up and");
  print ("I got bright eyes and I just became stronger and healthier");
  print ("and happier. Can't think of anything better in the world");
  print ("to be but be vegan. <br>");
  print ("-- Alicia Silverstone\n");
}

</cows>

<hr> See G-Cows manual for further details

15.7.2 Resulting HTML file

<h1> This is a minimal example about if statement </h1>

<h2> Comparing a variable and a constant string </h2>

<p> The beef industry has contributed to more American
deaths than all the wars of this century, all natural
disasters, and all automobile accidents combined.
If beef is your idea of "real food for real people",
you'd better live real close to a real good hospital.<br>
-- Neal D. Barnard, M.D.,
President Physicians Committee for Responsible Medicine

<p> The average age (longevity) of a meat eater is 63.
I am on the verge of 85 and still work as hard as ever.
I have lived quite long enough and am trying to die; but I
simply cannot do it. A single beef-steak would finish me;
but I cannot bring myself to swallow it. I am oppressed
with a dread of living forever.
That is the only disadvantage of vegetarianism. <br>
-- George Bernard Shaw



<h2> Comparing two variables </h2>

<p> Vegetarians have the best diet. They have the lowest
rates of coronary disease of any group in the country ...
Some people scoff at vegetarians, but they have a fraction
of our heart attack rate and they have only 40 percent of
our cancer rate.
They outlive other men by about six years now. <br>
-- Dr.William Castelli,M.D.

<p> Nothing's changed my life more. I feel better about
myself as a person, being conscious and responsible for
my actions and I lost weight and my skin cleared up and
I got bright eyes and I just became stronger and healthier
and happier. Can't think of anything better in the world
to be but be vegan. <br>
-- Alicia Silverstone



<hr> See G-Cows manual for further details

15.7.3 Resulting HTML file viewed with the Lynx text-browser


                 This is a minimal example about if statement

Comparing a variable and a constant string

   The beef industry has contributed to more American deaths than all the
   wars of this century, all natural disasters, and all automobile
   accidents combined. If beef is your idea of "real food for real
   people", you'd better live real close to a real good hospital.
   -- Neal D. Barnard, M.D., President Physicians Committee for
   Responsible Medicine

   The average age (longevity) of a meat eater is 63. I am on the verge
   of 85 and still work as hard as ever. I have lived quite long enough
   and am trying to die; but I simply cannot do it. A single beef-steak
   would finish me; but I cannot bring myself to swallow it. I am
   oppressed with a dread of living forever. That is the only
   disadvantage of vegetarianism.
   -- George Bernard Shaw

Comparing two variables

   Vegetarians have the best diet. They have the lowest rates of coronary
   disease of any group in the country ... Some people scoff at
   vegetarians, but they have a fraction of our heart attack rate and
   they have only 40 percent of our cancer rate. They outlive other men
   by about six years now.
   -- Dr.William Castelli,M.D.

   Nothing's changed my life more. I feel better about myself as a
   person, being conscious and responsible for my actions and I lost
   weight and my skin cleared up and I got bright eyes and I just became
   stronger and healthier and happier. Can't think of anything better in
   the world to be but be vegan.
   -- Alicia Silverstone
     _________________________________________________________________

   See G-Cows manual for further details

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