Hi Paul,

Here is the copy of a mail I exchanged with Chipp off-list that might interest you (and all):

Le 25 janv. 06 à 13:29, Eric Chatonet a écrit :

Found the following in Bugzilla with an interesting comment from Mark:

Bugzilla 2694 by [EMAIL PROTECTED] (Scott Slaugh)

<snip>

    ------- Additional Comment
      #1 From
      Mark Waddingham
      2005-03-17 05:10 -------

This isn't a bug, but just a classic parsing ambiguity (it's called the
'dangling else' problem)

If-Then-Else constructs in Revolution come in several flavours:

  1) if <cond> then <conseq> else <alt>

  2) if <cond> then <conseq>
     else <alt>

  3) if <cond> then <conseq>
     else
       <alt>
     end if

  4) if <cond> then
       <conseq>
     else <alt>

  5) if <cond> then
       <conseq> else <alt>

  6) if <cond> then
       <conseq>
      else
        <alt>
      end if

  7) if <cond> then
       <conseq>
     end if

  8) if <cond> then <conseq>

If you take a look at your code, then the last command before the else is what you want to be of form (8), however Revolution notices the next token is an 'else' followed by a newline so assumes it to be of form (6) - thus it expects
an extra 'end if'.

Basically, you have an 'else' dangling after an 'if' that could belong to either
the outer 'if' or the inner 'if'. As is standard practice in all other
languages, Revolution binds the else to the innermost 'if' statment.

You can get around this, however, by putting a new line after the final if
statement:
  if ... then
    if .... then ...

  else
  end if


Le 25 janv. 06 à 15:54, [EMAIL PROTECTED] a écrit :

Chipp,
I have the same experience with nested conditionals. I have found the following format (with the "then" below the "if") helps.

if tResult is "Error"
then
 answer "Go Ahead anyway" with "Cancel" or "OK"
 if it is "Cancel" then exit to top
end if

There is sometimes still a problem, especially if the nested conditional contains an "else" - so I always close these with an "end if":

if tResult is "Error"
then
 answer "Go Ahead anyway" with "Cancel" or "OK"
 if it is "Cancel"
 then
     exit to top
 else
     doElseStuff
 end if
end if

It takes more space but I find it is easier to read - and it always compiles.
Paul Looney

Best Regards from Paris,
Eric Chatonet
------------------------------------------------------------------------ ----------------------
http://www.sosmartsoftware.com/    [EMAIL PROTECTED]/


_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to