CHOOSE CASE TRUE for a series of validations

Share this topic:



Link to this posting

Postby Ursego » 19 Feb 2013, 22:14

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
User avatar
Ursego
Site Admin
 
Posts: 112
Joined: 19 Feb 2013, 20:33

Return to Elegant Code

Who is online

Users browsing this forum: No registered users and 1 guest


CHOOSE CASE TRUE for a series of validations

Share this topic:


If you think that this site is not too bad, please LIKE it in Facebook. Thanks!





free counters

eXTReMe Tracker