` Printed Icetips Article

Icetips Article



Par2: Returning mulitple values from a function
1999-02-05 -- Robert Fred Meyer
 
As mentioned by the other two, passing by address is the best way to get
multiple values returned.  But if you really want multiple values returned
without passing by address then there is a way.  Make a project for the
following program and run it.
---------------------------------------------------------------------------
  program

  map
    MultiReturn(ulong xV1, ulong xV2, ulong xV3),string
  end ! map

MultiReturns    group
V1                ulong
V2                ulong
V3                ulong
                end ! group

  code
  MultiReturns = MultiReturn(3,5,7)

  message('V1: ' & MultiReturns.V1 & |
         '|V2: ' & MultiReturns.V2 & |
         '|V3: ' & MultiReturns.V3 )


MultiReturn     procedure(ulong xV1, ulong xV2, ulong xV3)
MR              group(MultiReturns)
                end ! group
  code
  MR.V1 = xV1 * xV1
  MR.V2 = xV2 * xV2
  MR.V3 = xV3 * xV3
  return(MR)
---------------------------------------------------------------------------

Jean-Marc comments:

Put simply, you just declare a function to return a string and you return a
group.
You then reads the values from the group.



Printed April 28, 2024, 11:02 am
This article has been viewed/printed 35109 times.