Hi!

    I've made a patch which implements a simple "if-else" syntax.

    A new "Otherwise" command is introduced (wouldn't clash with possible
future syntax enhancements, right?), which executes supplied command only if
previous command was unsuccessful.  So the syntax is:

AddToFunc "Do-this-or-that"
+ "I" Next (SomeProggie) Close
+ "I" Otherwise SomeProggie

(this implements Dominik's example of "if some window exists, kill it,
otherwise start it").

    Each command may return a True/False value, which defaults to "True".
This logic is implemented in execute_complex_function(), which sets the
"current return value" to True before calling a command.  There's no change
in command calling conventions, since "return value of this command" and
"return value of previous command" are global variables (sic!).  Changed are
only conditional commands, which set return value to False when
unsuccessful.  I also investigated if it would be possible to place these
two vars into exec_func_args_type, but those structs aren't passed between
*execute*function().

    Since return values are stored in global vars,
execute_complex_function() saves previous state and restores it on exit.
Unfortunately, it contained a number of returns, which had to be replaced
with "goto END_OF_FUNCTION" (I wish C had Ada/Perl "break from a block"
feature...).

    Of course, calling "Otherwise" outside a complex function is senseless.

    Man page modification isn't included.

       ___________________________________________________________________
       Dmitry Yu. Bolkhovityanov  |  Novosibirsk, RUSSIA
       phone (383-2)-39-49-56     |  The Budker Institute of Nuclear Physics
                                  |  Lab. 5-13
This message contains a file prepared for transmission using the
MIME BASE64 transfer encoding scheme. If you are using Pegasus
Mail or another MIME-compliant system, you should be able to extract
it from within your mailer. If you cannot, please ask your system
administrator for help.

   ---- File information -----------
     File:  OTHERW.DIF
     Date:  7 Aug 2001, 23:04
     Size:  7906 bytes.
     Type:  Binary

Attachment: OTHERW.DIF
Description: Binary data

Reply via email to