Friday, July 2, 2021
Tip of the Day: Variable Handling in IF and WHILE Conditions
Product.......: R:BASE X.5 and R:BASE X.5 Enterprise (Version 10.5)
Build.........: 10.5.3.20624 or higher
Sections......: Commands
Keywords......: Condition, Variable, IF, WHILE
Unlike other R:BASE commands, whose purpose may be to manipulate data,
control structure commands are used to control the execution of a
program. The R:BASE programming language has two control structures
which provide conditional execution of commands.
. IF...ENDIF
determine whether or not to execute a sequence of commands
. WHILE...ENDWHILE
repeats commands until a condition is no longer true
A condition is specified within the IF and WHILE command syntax to
tell R:BASE to retrieve only the rows of data or perform an operation
that meets specific criteria. The condition can include a variable, a
combination of one or more expressions, and/or operations that would
evaluate to either true or false. And, the variable handling for the
command's condition will result in whether or not the expected
results are retrieved.
IF...ENDIF
-------------------
An expression can be substituted for the first variable in each of
the conditions. The second variable in the comparison must be dotted
so that the value of the variable is used, not the variable name.
IF vQtyOrd > .vLastQty THEN
IF vQtyOrd <> 0 THEN
IF vChng > 0 AND vBackOrd IS NOT NULL THEN
-- action are performed
ELSE
-- action are performed
ENDIF
ENDIF
ENDIF
Because an IF command is a one time comparison, using the variable
name or the dotted variable name generally result in the same thing.
The comparison is intended to be with the value of the underlying
variable.
https://www.rbase.com/support/rsyntax/rbgx5/if___endif.html
WHILE...ENDWHILE
-------------------
A variable can be substituted for the first variable iteration in
WHILE condition formats (e.g. VarName IS NULL), and for either item
when using an operator comparison, as in the above example.
WHILE veFileNum <= veFileCnt THEN
SET VAR veFileNum = (.veFileNum + 1)
-- action are performed
ENDWHILE
The condition should not use dotted variables, unless the current
value of that variable is to be evaluated. When comparing two items
with an operator, the condition may be enclosed in parentheses,
where R:BASE will evaluate the expression each time through the loop.
Now, if the IF command is inside a WHILE loop, the commands inside
the loop are first read without converting dotted variables to their
values. As the commands are actually processed, the current values
of the variables can be used.
https://www.rbase.com/support/rsyntax/rbgx5/while___endwhile.html
Very Best R:egards,
Razzak.
https://www.rbase.com
http://www.facebook.com/rbase/
--
For group guidelines, visit
http://www.rbase.com/support/usersgroup_guidelines.php
---
You received this message because you are subscribed to the Google Groups "RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rbase-l/0MfFlM-1laeUZ0qtu-00OlgF%40mrelay.perfora.net.