Skip to main content

[archive] Strings in the giving|returning phrase

  • February 15, 2008
  • 4 replies
  • 0 views

[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,

4 replies

[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,
Well, you could use dynamic memory and return the pointer.

[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,
Well, you could use dynamic memory and return the pointer.

[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,
i know, but implementing the standard "returning" phrase would be easier to read...

[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,
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.
...