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

RE: User defined functions

$
0
0

You can define the function within the same source file as the program that calls it.

Here is an example:

      $set preservecase case repository(update ON)
       id division.      
       function-id. myfunction.
       linkage section.
       01 myparam    pic x(5).
       01 myresult   pic x(5).
       procedure division using myparam returning myresult.
           move myparam to myresult
           goback.
       end function myfunction.
       
       id division.
       program-id. mytest.
       environment division.
       repository.
           function MYFUNCTION.
       data division.
       working-storage section.
       01 myparameter   pic x(5) value "12345".
       01 myresult      pic x(5) value spaces.
       procedure division.
           move function myfunction(myparameter) to myresult
           display myresult
           goback.
  
       end program mytest.

Viewing all articles
Browse latest Browse all 4356

Trending Articles



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