Page 1 of 1

CHOOSE CASE TRUE for a series of validations

PostPosted: 19 Feb 2013, 22:14
by Ursego
Use one compact CHOOSE CASE TRUE block to "pack" a series of Boolean expressions and/or Boolean functions.

So, instead of

Code: Select all
if not IsValid(ads) then
   ls_err_msg = "Passed datastore is not valid"
end if

if ls_err_msg = "" and IsNull(al_row) then
   ls_err_msg = "Passed row must not be null"
end if

if ls_err_msg = "" and al_row < 1 then
   ls_err_msg = "Passed row must be greater than 0"
end if

write

Code: Select all
choose case true
case not IsValid(ads)
   ls_err_msg = "Passed datastore is not valid"
case IsNull(al_row)
   ls_err_msg = "Passed row must not be null"
case al_row < 1
   ls_err_msg = "Passed row must be greater than 0"
end choose