On Mon, Aug 06, 2001 at 12:05:51AM +0000, Mikhael Goikhman wrote: > On 05 Aug 2001 13:34:02 +0200, Dominik Vogt wrote: > > > > How about this enhancement to conditional commands: > > > > Next (conditions) { false-action } true-action > > > > This would allow an "else" case in all conditional commands > > without the need to store a return code of these commands. For > > example: > > > > AddToFunc ToggleWindow > > + I Next ($0) { Exec $0 } Close > > This may work, but is this the best possible solution? This syntax is not > very readable and having else-command before then-command does not make it > better. As before there is still a limit to one command in both branches, > so you are forced to create small functions without a real need. It also > adds a problem of escaping curly brackets in else-command when needed. > What about parsing of nested conditional commands, braces in braces? :) > It seems that an idea of 2 commands on the same line is not very good. > > Here is my revised proposal that solves all problems described above. > > There are 2 constructs, one is long and one is short, both may be mixed: > > if Next (conditions) { > then-commands, one per line > } > else { > else-commands, one per line > } > > if Next (conditions) then-command > else else-command
[SNIP, see mailing list archive for more details] I've made a shot at the "if-else" syntax. Now, all conditional commands (and only conditional commands) have a return code that can be true (1), false (0) or error (-1). There are three new conditional commands: Cond (returncode) command CondCase (returncode) command These two execute the command only if the last conditional command returned the given return code. Break is not strictly a conditional command but terminates execution of a complex function. It only makes sense to be used in some conditional context. Example: AddToFunc PickWindowRaiseAndDeiconify + I Pick + I Cond (-1) Break + I Raise + I Iconify off Return codes are only defined inside complex functions and are not passed to sub functions or vice versa. There is also a new variable $[cond.rc] that is expanded to the last return code. This is invalid outside complex functions or in conditional commands. The code is not well tested yet but complete. I've no problem to change it again if we can think of something better. Now that the funtion arguments allow to pass a return code it is easy to make changes. If you want to play with it, be sure to read the new parts of the man page (commands and CONDITIONAL COMMANDS section). Bye Dominik ^_^ ^_^ -- Dominik Vogt, [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] -- Visit the official FVWM web page at <URL:http://www.fvwm.org/>. To unsubscribe from the list, send "unsubscribe fvwm-workers" in the body of a message to [EMAIL PROTECTED] To report problems, send mail to [EMAIL PROTECTED]