36 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <HTML><HEAD><TITLE>Built-In Commands - if manual page</TITLE></HEAD><BODY>
 | |
| <H3><A NAME="M2">NAME</A></H3>
 | |
| if - Execute scripts conditionally
 | |
| <H3><A NAME="M3">SYNOPSIS</A></H3>
 | |
| <B>if </B><I>expr1 </I>?<B>then</B>? <I>body1 </I><B>elseif </B><I>expr2 </I>?<B>then</B>? <I>body2</I> <B>elseif</B> ... ?<B>else</B>? ?<I>bodyN</I>?<BR>
 | |
| <H3><A NAME="M4">DESCRIPTION</A></H3>
 | |
| The <I>if</I> command evaluates <I>expr1</I> as an expression (in the
 | |
| same way that <B><A HREF="../TkCmd/expr.htm">expr</A></B> evaluates its argument).  The value of the
 | |
| expression must be a boolean
 | |
| (a numeric value, where 0 is false and
 | |
| anything is true, or a string value such as <B>true</B> or <B>yes</B>
 | |
| for true and <B>false</B> or <B>no</B> for false);
 | |
| if it is true then <I>body1</I> is executed by passing it to the
 | |
| Tcl interpreter.
 | |
| Otherwise <I>expr2</I> is evaluated as an expression and if it is true
 | |
| then <B>body2</B> is executed, and so on.
 | |
| If none of the expressions evaluates to true then <I>bodyN</I> is
 | |
| executed.
 | |
| The <B>then</B> and <B>else</B> arguments are optional
 | |
| ``noise words'' to make the command easier to read.
 | |
| There may be any number of <B>elseif</B> clauses, including zero.
 | |
| <I>BodyN</I> may also be omitted as long as <B>else</B> is omitted too.
 | |
| The return value from the command is the result of the body script
 | |
| that was executed, or an empty string
 | |
| if none of the expressions was non-zero and there was no <I>bodyN</I>.
 | |
| 
 | |
| <H3><A NAME="M5">SEE ALSO</A></H3>
 | |
| <B><A HREF="../TkCmd/expr.htm">expr</A></B>, <B><A HREF="../TkCmd/for.htm">for</A></B>, <B><A HREF="../TkCmd/foreach.htm">foreach</A></B>
 | |
| <H3><A NAME="M6">KEYWORDS</A></H3>
 | |
| <A href="../Keywords/B.htm#boolean">boolean</A>, <A href="../Keywords/C.htm#conditional">conditional</A>, <A href="../Keywords/E.htm#else">else</A>, <A href="../Keywords/F.htm#false">false</A>, <A href="../Keywords/I.htm#if">if</A>, <A href="../Keywords/T.htm#true">true</A>
 | |
| <HR><PRE>
 | |
| <A HREF="../copyright.htm">Copyright</A> © 1993 The Regents of the University of California.
 | |
| <A HREF="../copyright.htm">Copyright</A> © 1994-1996 Sun Microsystems, Inc.
 | |
| <A HREF="../copyright.htm">Copyright</A> © 1995-1997 Roger E. Critchlow Jr.</PRE>
 | |
| </BODY></HTML>
 | 
