WHILE ... END WHILE

Syntax

WHILE Logical_Expression
    
[ statements ]
    [ EXIT WHILE ]
END WHILE

WHILE Logical_Expression
    
[ statements ]
    [ EXIT WHILE ]
WEND

Argument

Description

Logical_Expression

An expression that evaluates to .T. (TRUE) or .F. (FALSE).

Description

WHILE ... END WHILE is a control structure that repeats the statements it contains while the Logical Expression evaluates to TRUE. Execution resumes at the line following the end while statement when the Logical Expression is FALSE or when the EXIT while statement is encountered.

Example

This script searches for a customer whose last name is 'Smith'.

dim lFound as l

lFound = .f.

tbl = table.current()

search_name = "Smith"

tbl.fetch_first()

while .not. tbl.fetch_eof()

    if (trim(tbl.last_name) = search_name) then

        lFound = .t.

        exit while

    end if

    tbl.fetch_next()

end while

if lFound

    ui_msg_box("Search", search_name + " has been found.")

else

    ui_msg_box("Search", "Not Found.")

end if

See Also

Language Reference, Reserved Words

Supported By

Alpha Five Version 5 and Above