[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Evaluate



>      command.  Does the break command take you back out to the
>      begin-program section or does it let you continue within the local
>      procedure?

The BREAK command breaks out of the inner-most EVALUATE or BEGIN-WHILE loop.
It will never cause you to exit all the way out of a procedure (unless, of
course, there's nothing between the end of the EVALUATE or WHILE loop and
the END-PROCEDURE).

Note that you don't actually NEED the break in the EVALUATE ... WHEN section,
but it's usually a good idea to have it.  If you leave it out, SQR will
spend time evaluating all the other WHEN conditions, and in most cases
EVALUTES are designed so that only one condition ever matches.

Here's an example where more than one condition may match:

  move 3 to #n
  evaluate #n
     when = 3
     when = 1
       show '#n is odd'
     when = 4
     when = 2
       show '#n is even'
     when > 4
       show '#n > 4'
     when > 3
       show '#n > 3'
     when > 2
       show '#n > 2'
     when > 1
       show '#n > 1'
   end-evaluate

will print

   #n is odd
   #n > 2
   #n > 1


                                                        Nathan

----------------------------------------------------------------------------
Nathan Treadway    | Ray Ontko & Co. | Software consulting services
nathant@ontko.com  | Richmond, IN    | http://www.ontko.com/