Skip to main content
Solved

Referencing intrinsic function without FUNCTION keyword

  • March 27, 2026
  • 7 replies
  • 44 views

Frank Swarbrick
Forum|alt.badge.img+1

According to the documentation, if “FUNCTION ALL INTRINSIC” is specified in the Repository paragraph, the “FUNCTION” keyword is not required to refer to any intrinsic function.  Take the following program.

 

      $set sourceformat"free"

program-id. p.

environment division.

configuration section.

repository.

    function all intrinsic.

data division.

working-storage section.

01  x               pic x(10).

procedure division.

    display function length(x)

    display length(x)

    goback.

end program p.


The first line of the procedure division (with function keyword) compiles fine.  The second like (no function keyword) gives the following error:

    display length(x)
*  13-S************                                                          **
**    User-name required

Is there a certain option required to activate this feature?

Using Rocket (R) COBOL Version 11.0 (C).

Best answer by Chris Glazier

I have tested with V11 GA, PU1, PU2 and PU3 and they all work fine for me.

Are you sure it isn’t another line of code causing the issue?

Try this by itself:

$set remove(random)
identification division.
program-id. p.
environment division.
configuration section.
repository.
function all intrinsic.
data division.
working-storage section.
01 r pic 9(9)v9(9).
procedure division.

compute r = random(integer(numval(current-date(1:16))))
goback.

 

7 replies

Chris Glazier
Forum|alt.badge.img+3

Hi Frank,

The word LENGTH is a reserved word because it is a special register.

It can be used as:

      display length of x

In order to use it as an intrinsic function without the FUNCTION keyword you would need to turn it off as a reserved word. You can do this with the following directive:

$set remove(length)

You will then be able to use it without the FUNCTION keyword but you won’t be able to use it as a special register.

 


Frank Swarbrick
Forum|alt.badge.img+1
  • Author
  • Participating Frequently
  • March 30, 2026

Ah, shoot, I should have tried something other than length.  Thanks.
I will note that Enterprise COBOL supports both in the same program.  See the following example.  It compiles fine with Enterprise COBOL V6.4 (and maybe earlier).

 

 identification division.                                

 program-id. lengtest.                                   

 environment division.                                   

 configuration section.                                  

 repository.                                             

     function all intrinsic.                             

 data division.                                          

 working-storage section.                                

 01  my-field                    pic x(80).              

 01  x                           pic 9(4).               

 procedure division.                                     

     compute x = length of my-field                      

     display x                                           

     compute x = function length(my-field)               

     display x                                           

     compute x = length(my-field)                        

     display x                                           

     goback.                                             

 end program lengtest. 

Frank


Frank Swarbrick
Forum|alt.badge.img+1
  • Author
  • Participating Frequently
  • March 30, 2026

@Chris Glazier: I just took a program with “FUNCTION ALL INTRINSIC” and removed the FUNCTION keyword in front of them, and this worked with one exception: RANDOM.  Even if I have a $set remove(random) I still get an error:

Rocket (R) COBOL
Version 11.0 (C) 1984-2025 Rocket Software, Inc. or its affiliates.
     compute r = random(integer(numval(current-date(1:16))))
*  14-S***********************************************                 (   0)**
**    Invalid operand
* Checking complete - errors found

It works if I add back ‘function’ only in front of ‘random’.


Chris Glazier
Forum|alt.badge.img+3

I do not experience the error if I use your statement without FUNCTION and $set remove”random” is set.

It compiles without error.

What Visual COBOL V11 patch update level do you have installed?

I am using PU3.

 


Frank Swarbrick
Forum|alt.badge.img+1
  • Author
  • Participating Frequently
  • March 30, 2026

I am using Personal Edition.  In a listing it says “Rocket (R) COBOL                 V11.0  revision 000”.


Chris Glazier
Forum|alt.badge.img+3
  • Moderator
  • Answer
  • March 31, 2026

I have tested with V11 GA, PU1, PU2 and PU3 and they all work fine for me.

Are you sure it isn’t another line of code causing the issue?

Try this by itself:

$set remove(random)
identification division.
program-id. p.
environment division.
configuration section.
repository.
function all intrinsic.
data division.
working-storage section.
01 r pic 9(9)v9(9).
procedure division.

compute r = random(integer(numval(current-date(1:16))))
goback.

 


Frank Swarbrick
Forum|alt.badge.img+1
  • Author
  • Participating Frequently
  • March 31, 2026

Thanks ​@Chris Glazier.  That worked.  The reason mine didn’t work is because instead of stating “function all intrinsic” I had “function random intrinsic”.  I guess since RANDOM was no longer a reserved word it didn’t work as I believe it should have.

Now I’ll just say this.  I believe that for intrinsic functions whose names are also reserved words (LENGTH, RANDOM, SIGN and SUM), they should be allowed to be implicitly (function all intrinsic) or explicitly (function length, random, sign, sum) declared in the repository and used as an “unqualified” function identifier (no “FUNCTION” keyword required).

The simple act of removing these words from the reserved word list has the unintended consequence of making it such that otherwise valid declarations are no longer valid.  For example, in a file definition, “ACCESS IS RANDOM” would no longer work.  And in data definition, “SIGN IS SEPARATE” would no longer work (if you removed SIGN).

If you can tell me how you created that “text image box” in your last message, I will give you an example program that compiles with Enterprise COBOL 6.4 but does not with Visual COBOL because of these issues.