Hi,
Is it possible to compare to a range of values in COBOL? I'm thinking of something like this:
if account-id between 1 and 7 then
perform debit-internal-account
else
debit-customer-account
end-if
Regards
#COBOL
Hi,
Is it possible to compare to a range of values in COBOL? I'm thinking of something like this:
if account-id between 1 and 7 then
perform debit-internal-account
else
debit-customer-account
end-if
Regards
Hi,
Is it possible to compare to a range of values in COBOL? I'm thinking of something like this:
if account-id between 1 and 7 then
perform debit-internal-account
else
debit-customer-account
end-if
Regards
I figured it out, I used the following syntax
evaluate account-id
when 1 thru 7
perform debit-internal-account
when other
perform debit-customer-account
end-evaluate
ME ANSWERING MY SELF
So Crazy of Me!
Hi,
Is it possible to compare to a range of values in COBOL? I'm thinking of something like this:
if account-id between 1 and 7 then
perform debit-internal-account
else
debit-customer-account
end-if
Regards
Here's another technique, a little closer to your original request:
01 account-id pic 9.
88 account-id-valid values are 1 through 7.
if account-id-valid then
perform debit-internal-account
else
perform debit-customer-account
end-if
If you do it with 88's, then the semantics of the test is only one place in your code, rather than being spread through out the procedure division. Then, when you decided to add 8 to the valid values, you only have to change one place.
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.