Page 1 of 1

short circuit evaluation

PostPosted: Fri Nov 30, 2007 10:56 pm
by Tzadik Vanderhoof
I noticed (quite by accident) that the Cobol I'm using has "short-circuit logic evaluation". For example, you can do:
IF IDX <= MAX-IDX AND MYTBL(IDX) > 34

without worrying about making a reference outside the bounds of the table. If IDX is greater than MAX-IDX, the code will not even execute the part after the AND. I knew C and Java had this feature but it quite useful to know that COBOL also has it.

The way I discovered this was that I had the 2 sides of the AND reversed, so it was ABENDING due an out-of-table reference, even though I was checking for that... I was just checking it in the wrong order. Switching the order solved it.

Does anyone know if that is part of the standard, or is it just an added feature of certain versions?

Re: short circuit evaluation

PostPosted: Sat Dec 01, 2007 1:12 am
by dick scherrer
Hello,

Look at the documentation for SSRANGE.