OpenEdge short-circuits as this program demonstrates:
def var i1 as int no-undo.
def var i2 as int no-undo.
function f1 returns logical.
i1 = i1 + 1. return yes.
end.
function f2 returns logical.
i2 = i2 + 1. return yes.
end.
if f1() or f2() then message i1 i2 view-as alert-box. /*1 0*/
assign i1 = 0 i2 = 0.
if f1() and f2() then message i1 i2 view-as alert-box. /*1 1*/
def var i1 as int no-undo.
def var i2 as int no-undo.
function f1 returns logical.
i1 = i1 + 1. return yes.
end.
function f2 returns logical.
i2 = i2 + 1. return yes.
end.
if f1() or f2() then message i1 i2 view-as alert-box. /*1 0*/
assign i1 = 0 i2 = 0.
if f1() and f2() then message i1 i2 view-as alert-box. /*1 1*/
----- Original Message -----
From: "jckinneman" <jckinneman@...>
To: <vantage@yahoogroups.com>
Sent: Wednesday, July 03, 2013 8:12 AM
Subject: [Vantage] Re: short-circuit in 4GL ?
I don't know if we can make that assumption since Progress's documentation doesn't appear to explicitly indicate it does short circuiting.
Jim Kinneman
Encompass Solutions, Inc
--- In vantage@yahoogroups.com, "Vic Drecchio" <vic.drecchio@...> wrote:
>
> In your example, using OR operators will definitely short circuit the
> statement.
>
>
>
> Using ORs will cause this. When the first condition is evaluated and if
> [varA = False], then the rest of the expression is not evaluated; it doesn't
> care about varB or varC's values. It's complete because everything else is
> "OR".
>
>
>
> If [varA = True], then it will continue and evaluate varB. If [varB =
> False], then varC is never evaluated because the statement's result has
> already been determined.
>
>
>
> Operators dictate the short circuiting. No short circuiting occurs when
> using ANDs inside the statement or expression.
>
>
>
> Short circuiting somewhat implies that the system is doing something wrong
> and it's not.. That's just the way it should work, right? Or am I missing
> something?
>
>
>
> Good little brain teaser for the last day of the week!
>
>
>
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of
> Bill Jackson
> Sent: Wednesday, July 03, 2013 8:22 AM
> To: vantage@yahoogroups.com
> Subject: [Vantage] short-circuit in 4GL ?
>
>
>
>
>
> Does Progress 4gl have the 'short-circuit' behavior like some other
> languages, in a multiple condition 'If' statement?
>
> ie: If ( (varA = False) OR (varB = False) Or (varC = False)) then do:
>
> //stuff
>
> end.
> Else do:
>
> //other stuff
>
> End.
>
> 'short-circuit' being: As soon as one condition is met. then do //stuff
>
> We're looking to minimize decision making in a BPM directive.
>
> [Non-text portions of this message have been removed]
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
------------------------------------
Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must have already linked your email address to a yahoo id to enable access. )
(1) To access the Files Section of our Yahoo!Group for Report Builder and Crystal Reports and other 'goodies', please goto: http://groups.yahoo.com/group/vantage/files/.
(2) To search through old msg's goto: http://groups.yahoo.com/group/vantage/messages
(3) To view links to Vendors that provide Vantage services goto: http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3345 / Virus Database: 3204/6460 - Release Date: 07/03/13
[Non-text portions of this message have been removed]