|
Next: Multiplex branch Up: Drawing conditional branch Previous: Drawing conditional branch |
Simple branch
To draw a simple branch, you use if The simplest conditional branch is one that has only if. This example is a program to return an absolute value.
By using else you can write process to be executed when condition is false. The next example calculate a square root, and it will print an imaginary unit i if the number is negative:
Finally, I am going to explain valid and invalid syntax of
if If true part or false part contains only one command, you do not have to enclose it with { } as in the first example. However, these are both illegal:
You can omit both true part and false part. Hence, the following example is OK:
You can insert a newline code before { and after }, and you can put as many spaces as you like. So, the next example is valid.
|
|
Go back to pad2ps - automatic PAD drawer. Go back to Seiichi Yoshida's Home Page. Copyright(C) Seiichi Yoshida (comet@aerith.net). All rights reserved. Sun Nov 10 01:36:04 JST 1996 |