while
Username:  
Password:
  > Home
> User Guide
v Reference
    > Introduction
    > CROFT
    > BEE Variables
    > BEE Syntax
    v BEE Commands
       > Variable Operations
       > Conditional
       v Loop
          o foreach
          o for
          o while
          o continue
          o break
       > Module Calling
       > Remote Calling
       > Authentication
       > Data Access
       > Socket
       > Special Functions
    > Database Operation
    > Content Management
    > Objects and Classes
    > Interface with others
    o Glossary
> Portal Object
> Development Guide


Shortcuts
sys Class
debug Class
Intrinsic Conversions
>> Reference >> BEE Commands >> Loop >> while <=  =>      <  1  >  
while – loop while a condition remains true

BEE Script:   while [maxiter=num] (condition) statement;

or          while [maxiter=num] (condition)

                  { statement; ... }

 

BEE Tag:     <beewhile "condition" [maxiter=num]>

                  tag

                  ...

            </beewhile>

 

Note: The condition is surrounded by a small bracket and therefore is taken literally.  While you can (and sometimes need to) quote individual values in the condition, please do not quota the whole condition with double or single quote.  Otherwise, the whole condition will be taken as a string (and will most likely to be evaluated to true unless it is blank or 0).

The "while" loop iterates for as long as the condition evaluates to true.

Please note that variables in condition are evaluated as macros and therefore one should bear in mind the logical expression syntax.  In particular, you need to quote strings as required.  Please see the "if" command for examples.

Example:

var i = 0;

while ({i} < 5)

{

      display 'i=<br>\n';

      var i = "(expr){i} + 1";

}

// Sample display:

//    i=0

//    i=1

//    i=2

//    i=3

//    i=4

 

 

Parameters

maxiter is the maximum number of iterations the loop will execute.  It is default to 1000.  Zero means infinity.

 

The following BEE Variables will be made available within a "while" loop:

result%while:istrue

Set to 1 if the condition evaluates to true, or 0 otherwise

result%while:condition

Set to the condition after variable evaluation

result%while:iteration

The iteration count.  It contains 1 in the first iteration and 2 for the second etc.

 

An interesting remark on the "while" command: The condition is declared once but evaluated multiple times, each in every iteration.  Internally the condition is passed in through an implicit "absolute" attribute, which means no pre-evaluation will be done until the execution starts.

 

Previous Page       Next Page

Accsoft Computer Technology Pty Ltd     ABN: 98 065 617 549
PO Box 892, Epping NSW 1710         Level 1, Epping Office Park, 242 Beecroft Rd, Epping NSW 2121, Australia
Tel: Sydney - (02)98691668     National - 1300-881668         Fax: (02)98691866
© Copyright 2003 Accsoft Computer Technology Pty Ltd