Highlighted
Absent Member.
Absent Member.
229 views

[archive] Strings in the giving|returning phrase

[Migrated content. Thread originally posted on 14 February 2008]

Hi,

I make a large use of subroutine with entry points in my programming technique, tryng to follow - in some way - the paradigm of encapsulation of the OO programming, so instead of :

move item-code to stock-key
read stock-file
move stock-quantity to my-quantity

i write:

call "xyz_get_item_stock" using item-code giving my-quantity
where "xxx_get_item_stock" is an entry point of the "xyz" subprogram, who encapsulates the properties of the stock-file "entity".

now, if you have to get a "string" property insetad of a numeric one, you can't use the "giving" phrase: you are forced to pass your property via the "using" list:

call "xyz_get_stringproperty" using item-code my-string-property
where item-code is the "in" parameter, my-string-property is the "out".

I think that allowing ANY primitive type in the returning phrase could help to put more emphasys on who is IN and who is OUT, making your code easier to read, and - so to speak - self documenting, so I ask for this enhancement:

call "xyz_get_stringproperty" using item-code GIVING my-string-property

thanks,
0 Likes
3 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Strings in the giving|returning phrase

Well, you could use dynamic memory and return the pointer.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Strings in the giving|returning phrase

i know, but implementing the standard "returning" phrase would be easier to read...
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Strings in the giving|returning phrase

If you allocate the memory and store text at an address in a multi purpose program. That program can return the pointer.
E.g.
77 Apionter usage pointer.
LINKAGE SECTION
77 mybuf pic x[1024].
...
PROCEDURE DIVISION
...
CALL MyFuncManipulatingStrings USING
BY REFERENCE mybuf
RETURNING Apointer.
Set ADDRESS OF mybuf TO Apointer.
...
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.