Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

Boolean functions

$
0
0

Hi,

I would like to know whether it is possible to write a COBOL function that returns a true or false value so that one can write:


    if myfunc() then <true-branch> else <false-branch> end-if.

I can write functions that return values "t" or "f" (or 1/0, or "TRUE"/"FALSE", or whatever) and then write:

    if myfunc() = "t" then <true-branch> else <false-branch> end-if.


That "= ""t""" seems like something I should not have to do.


I read somewhere abouit using PIC 1, where B"1" is true and B"0" is false. I wrote a function using that but the callers do not compile.

To expand that:

    function-id. myfunc prototype.

    linkage section.

    01  l-result pic 1.

    procedure division returning l-result.

    end function myfunc.

    ...

    if myfunc() then

    ...

I see a compiler error on the ')' of the function call saying "Error    1    COBCH0001 : Undefined error. Inform Technical Support   ..."

Any insights gratefully received.

Leigh.

       function-id. numeric-1 prototype.
       linkage section.
       01      l-data      pic x any length.
      *01      l-result    pic x.
       01      l-result    pic 1(16).
       procedure division using l-data returning l-result.
       end function numeric-1.


Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>