!if, !elif, !else, !endif - Conditional statements
The conditional directives allow statements to be executed only if a condition specified in the directive is met, as follows:-
The condition may be any logical condition as evaluated by the variable functions (e.g. &equal(4)) returning TRUE or FALSE. An integer value, non-zero evaluates TRUE, zero evaluates to FALSE. A non-numerical argument, such as a string is always FALSE.
The conditional body may be any MicroEmacs '06 function, macro or directive with the exception of define-macro and !emacro. All directives that alter the execution of the macro are handled correctly within the !if statement (e.g. !goto, !return etc.
The following macro segment creates the portion of a text file automatically. (yes believe me, this will be easier to understand then that last explanation....)
!if &sequal %curplace "timespace vortex" insert-string "First, rematerialize\n" !endif !if &sequal %planet "earth" ;If we have landed on earth... !if &sequal %time "late 20th century" ;and we are then ml-write "Contact U.N.I.T." !elif &sequal %time "pre 20th century" ml-write "start praying for a miracle" !else insert-string "Investigate the situation....\n" insert-string "(SAY 'stay here Sara')\n" !endif !else set-variable %conditions @ml"Atmosphere conditions outside? " !if &sequal %conditions "safe" insert-string &cat "Go outside......" "\n" insert-string "lock the door\n" !else insert-string "Dematerialize..try somewhere else" newline !endif !endif
Copyright (c) 1998-2006 JASSPA
Last Modified: 2004/01/11
Generated On: 2006/10/07