Simplicty and flexibility!


Command::

while


Parameters


Returns/Result


Examples


Reference

while

Type

Procedural Command

Purpose

Like the if command, the while command executes a series of actions based on whether a specified condition is true. Unlike the if command, the while command creates a processing loop in which actions are executed repeatedly as long as the specified condition remains true.

When processing reaches a while command, DataEase evaluates the condition that follows the keyword while. If the specified condition is true, DataEase executes all the actions that follow the keyword do until it reaches the corresponding end command.

DataEase then reevalutes the original condition. If the condition is still true, DataEase executes the do action series again. If the condition is false, processing passes to the first action following the end command for the while statement.

Syntax

 while CONDITION do

  ACTION 1 .

  [ACTION 2 .

  .

  .

  ACTION N .]

 end

 

Usage

Frequently, a while command specifies an initial condition that is modified during each pass through the loop (for example, a counter). Any action that modifies the value to be reevaluated must be included in the loop (i.e., it must precede the end command that terminates the loop.)

Example

define temp "CRUISE TICKET NUM" Number .

assign temp CRUISE TICKET NUM := 0 .

 

while temp CRUISE TICKET NUM < 1000 do

temp CRUISE TICKET NUM := temp CRUISE TICKET NUM + 1 .

list records

jointext ( " Boarding Pass No.: " ,

temp CRUISE TICKET NUM) .

end

 

This script tells DataEase: (1) Create (define) a temporary variable called CRUISE TICKET NUM, (2) give (assign) an initial value of 0 to the CRUISE TICKET NUM variable, (3) print a series of labels joining the words Boarding Pass No.: to the number currently stored in the CRUISE TICKET NUM variable, (4) while printing the labels, increment the variable by one each time a new label is printed, and (5) when the value of the variable reaches 1000, stop printing labels.

The while command tells DataEase to reevaluate the value of the variable each time it prints a label. As long as that value is less than 1000, DataEase prints another label. When the value of the variable reaches 1000, DataEase stops performing the action following the do keyword.

See Also


On the forum about while

Problem with GetGlobal / SetGlobal functions while checking procedure .

See below &nbsp;an example :....................................... .................................. ................................ ...........................

Product: Dataease [{8}]FIVE. Written by Luca 31/07/13 at 13:21:39

Re:Problem with GetGlobal / SetGlobal functions while checking procedure .

Hmmm… This is a little headache. SetGlobal(), GetGlobal() is an internal function now not a CDF. And it is defined with “names” rather than numbers to make it more useful. SetGlobal(“MyVar”,MyValue) GetGloba...

Product: Dataease [{8}]FIVE. Written by DataEase 31/07/13 at 13:23:50

Re:Re:Problem with GetGlobal / SetGlobal functions while checking procedure .

It's not a good idea to change how existing functions, etc, work, especially with such a commonly used function as this one.Could you not have given the internal version of this function a different name? e.g. GetVariable, or GetVar.Ther...

Product: Dataease [{8}]FIVE. Written by Adrian Jones 02/08/13 at 14:04:19

Re:Re:Re:Problem with GetGlobal / SetGlobal functions while checking procedure .

Very good point Adrian and the time to correct it is now and the new name is GetVar()/SetVar().Luckily this is the only one, was worse when hole functionality was replaced like the Old Memo with the New memo or Lookup fields with Multi...

Product: Dataease [{8}]FIVE. Written by DataEase 02/08/13 at 14:34:42

Re:Re:Re:Problem with GetGlobal / SetGlobal functions while checking procedure .

You can of course still use numbers and loop through them if that is what you want as DataEase automatically converts numbers to text when you use a variable, so in that use case there will be no difference....

Product: Dataease [{8}]FIVE. Written by DataEase 05/08/13 at 13:40:19

Re:Problem with GetGlobal / SetGlobal functions while checking procedure .

SetGlobal()/GetGlobal() are now renamed to SetVar() and GetVar().You can now use the old CDF and the new functions in parallel.If you have used the the new internal format for SetGlobal()/GetGlobal() you will have to rename them in your...

Product: Dataease [{8}]FIVE. Written by DataEase 05/08/13 at 13:41:53

Re:Re:Re:Problem with GetGlobal / SetGlobal functions while checking procedure .

Adrian Jones wrote: "There is also an advantage to having the number, as it means you can view the currently used values with a getGlobal ( number ), or with my Looper table of integers with getGlobal ( LoopNo ). Of course, if the...

Product: Dataease [{8}]FIVE. Written by DataEase 01/10/13 at 09:16:45

While current status not = 1 do. Will not open input form

I am trying to open a form & post information from that form to other forms using the following, however DE8 will not open the form. If i remove the "while current....&nbsp;do .&nbsp;" the form "Deposit Close_Retrurn" will not open!while curren...

Product: Dataease [{8}]FIVE. Written by Graham Brown 02/02/14 at 10:50:34

Re:While current status not = 1 do. Will not open input form

We just tested this in 8.1.1.1450 (shouldn't be any difference to any previous versions of DE8) and it worked fine. Obviously we didn't test your app as we don't have it, but a input using in general: <span style="color: r...

Product: Dataease [{8}]FIVE. Written by DataEase Tech Sup 03/02/14 at 08:57:00

Re:Re:While current status not = 1 do. Will not open input form

I have looked at the database in question and have found the following:-Problem 1: The table of the form that was the subject of the input using statement was duplicated - I deleted the duplicate in the manner suggested in a recent Forum postin...

Product: Dataease [{8}]FIVE. Written by Peter Birney, PB Associates 03/02/14 at 11:31:26

Re:Re:Re:While current status not = 1 do. Will not open input form

This simple DQL does not display any messages.&nbsp; When run in Design View the flashing cursor disappears.define "pob" Number .pob := 0 .while pob &lt; 5 do .message pob window .pob := pob + 1 .end .message "The...

Product: Dataease [{8}]FIVE. Written by Peter Birney, PB Associates 04/02/14 at 07:59:18

Re:Re:Re:Re:While current status not = 1 do. Will not open input form

Hi! We have just tested this while loop in 6.53 7.2 and 8.1 and it works fine.There must be something "environmental" here that impacts this. Is this in a fresh app or is it in the app that had problems with the while loop earlier?&nbsp;<b...

Product: Dataease [{8}]FIVE. Written by DataEase Tech Sup 04/02/14 at 10:04:40

Re:Re:Re:Re:Re:While current status not = 1 do. Will not open input form

Hi - It works fine in a new app - I will ask Graham if he will let you have a copy of his database (It may still have the duplicate Table Name).Can you advise us where to send it?...

Product: Dataease [{8}]FIVE. Written by Peter Birney, PB Associates 04/02/14 at 10:21:41

Re:Re:Re:Re:Re:Re:While current status not = 1 do. Will not open input form

[@EOF@]...

Product: Dataease [{8}]FIVE. Written by Graham Brown 05/02/14 at 14:58:33

Form is open while shutting down

This is something like&nbsp;curiosity, even though I always advise clients to close the app properly.What will happen to a DE8 database, if a user shuts down the workstation without properly closing the DE8 app.And a form was open at the ti...

Product: Dataease [{8}]FIVE. Written by Jeyarajah Arulrajah 07/12/14 at 17:19:00

Re:Form is open while shutting down

There is a big distance between what people should do and what they actually do.This is a little like not using a Mobile on a plane. If it was really true that a plane would fall out of the air if someone forgot to switch off their phone or re...

Product: Dataease [{8}]FIVE. Written by DataEase 09/12/14 at 11:46:29

count of not updated in a while loop

Hi there,I have this simple algorithm to implement:1. Check how many working days there are between date x and date x - y days (y = 3);NOTE: I have a special table listing all days till 2050: the day has...

Product: Dataease [{8}]FIVE. Written by George Washington 16/10/15 at 07:08:04

Re:count of not updated in a while loop

Downalod Sample! This is one of the 20 least well known "bugs" in DataEase, but it is KNOWN ;-) There has been much debate on this as...

Product: Dataease [{8}]FIVE. Written by DataEase 16/10/15 at 12:07:02

Re:Re:count of not updated in a while loop

Thanks that works!...

Product: Dataease [{8}]FIVE. Written by George Washington 16/10/15 at 14:36:15

On the blog about while


dg3_HelpView