This really shows I should spend some more time reading the manual! Thanks.
Original Message:
Sent: Wed April 05, 2023 05:36 AM
From: Frank Swarbrick
Subject: Calling using intrinsic functions as parameters
You can already omit the FUNCTION keyword (in COBOL 6.3 and later, at least; not sure about earlier) by using a REPOSITORY paragraph:
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
REPOSITORY.
FUNCTION ALL INTRINSIC.
By doing this you no longer need the word FUNCTION elsewhere.
The information contained in this electronic communication and any document attached hereto or transmitted herewith is confidential and intended for the exclusive use of the individual or entity named above. If the reader of this message is not the intended recipient or the employee or agent responsible for delivering it to the intended recipient, you are hereby notified that any examination, use, dissemination, distribution or copying of this communication or any part thereof is strictly prohibited. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy this communication. Thank you.
Original Message:
Sent: 4/5/2023 3:11:00 AM
From: Per Trangbæk
Subject: RE: Calling using intrinsic functions as parameters
You may be right, I'm unsure how the internal works. The manual (6.3) just state it is a string returned, not if it is a dynamic. If you are right, it should be even easier for the compiler people to fix :)
You omitting the keyword FUNCTION show how annoying it is and is yet another good enhancement request.
By the way, I measured a few metodes to find the length of a string, minus leading spaces. Under some circumstances your method was the fastes.
------------------------------
Per Trangbæk
Original Message:
Sent: Wed April 05, 2023 02:33 AM
From: Frank Swarbrick
Subject: Calling using intrinsic functions as parameters
By the way, TRIM does seem to have a (dynamic) length. The following works (FUNCTION keyword omitted):
COMPUTE FIELD-LEN = LENGTH(TRIM(EDIT-SQLCODE LEADING))
------------------------------
Frank Swarbrick
Original Message:
Sent: Wed April 05, 2023 01:00 AM
From: Per Trangbæk
Subject: Calling using intrinsic functions as parameters
Hi Frank
I think it is a stretch to call it a FUNCTION, if it can not be placed everywhere where the return type can be placed.
You have my vote!
------------------------------
Per Trangbæk
Original Message:
Sent: Mon April 03, 2023 12:54 AM
From: Frank Swarbrick
Subject: Calling using intrinsic functions as parameters
None of the following work, and I think they should all be made to work (regardless of the COBOL standard, which I've not checked in this case).
CALL 'mysubr1' USING BY CONTENT FUNCTION LENGTH(my-field)
(You CAN use the LENGTH OF
special register in this context)
CALL 'mysubr2' USING BY CONTENT FUNCTION TRIM(my-field) FUNCTION LENGTH(FUNCTION TRIM(my-field))
Additionally, you should also be able to do a CALL RETURNING in to an ADDRESS OF special register.
CALL 'subr-returning-pointer' RETURNING ADDRESS OF my-based-field
And, while I don't have Enterprise COBOL v6.4 yet, also allow the result of a function to go in to ADDRESS OF. Maybe that one is already allowed.
SET ADDRESS OF my-based-field TO FUNCTION func-returning-pointer()
Passing function results BY VALUE should also be similarly allowed.
Would you vote yes for an official request of the above?
------------------------------
Frank Swarbrick
------------------------------