How to pass NUMERIC in CHAR parm in a procedure without using BIF ? - IBM AS400

This is a discussion on How to pass NUMERIC in CHAR parm in a procedure without using BIF ? - IBM AS400 ; Hi, I would like to build a proc with 10 char parm (9 NoPass) and call it passing parms without minding about the real nature of the passed value (Char or Num). MyProc Pi Parm01 25A Const Parm02 25A Cons ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: How to pass NUMERIC in CHAR parm in a procedure without using BIF ?

  1. How to pass NUMERIC in CHAR parm in a procedure without using BIF ?

    Hi,

    I would like to build a proc with 10 char parm (9 NoPass) and call it
    passing parms without minding about the real nature of the passed
    value (Char or Num).

    MyProc Pi
    Parm01 25A Const
    Parm02 25A Cons Option(*NoPass)
    ...


    /FREE
    ....
    MyResult = MyProc(AnyVar: AnyOtherProc(P1: P2));

    In the example above, AnyVar could be any variable (numeric or char)
    and the result passed back by AnyOtherProc would depend on the proc I
    use to get a value. I do not want the user of this proc to know or
    consider the data type he tries to pass. So he does not need to write
    extra code or use any BIF.

    The called proc will receive and process each parm as char to build a
    long text string passed back to the caller.

    I do not think OPDESC can do the JOB... Any Suggestion is welcome.

    Thanks a lot.

    J-Laurent.


  2. Re: How to pass NUMERIC in CHAR parm in a procedure without usingBIF ?

    jean-laurent.maestre@axon-id.com wrote:
    >
    > I would like to build a proc with 10 char parm (9 NoPass) and call it
    > passing parms without minding about the real nature of the passed
    > value (Char or Num).
    >


    Sorry, that is not currently supported by RPG.

  3. Re: How to pass NUMERIC in CHAR parm in a procedure without usingBIF ?

    Barbara Morris wrote:
    > jean-laurent.maestre@axon-id.com wrote:
    >>
    >> I would like to build a proc with 10 char parm (9 NoPass) and call it
    >> passing parms without minding about the real nature of the passed
    >> value (Char or Num).
    >>

    >
    > Sorry, that is not currently supported by RPG.


    Barbara:

    Any reason it can't just be a pointer by value? (Other than all the
    logical problems that can cause...)

    --
    Tom Liotta
    http://zap.to/tl400

  4. Re: How to pass NUMERIC in CHAR parm in a procedure without using BIF ?

    Hi Tom -

    On Sat, 31 Mar 2007 01:36:47 -0700, Tom Liotta
    wrote:

    >Any reason it can't just be a pointer by value? (Other than all the
    >logical problems that can cause...)


    That will work just fine. I've used that for passing parameters of a
    type which wasn't supported by prototyping at that release, or where
    it could be about anything and other parameters would contain the
    needed information about that parameter.

    It does give you additional opportunities to shoot yourself in the
    foot, but no more so than good ol' unprototyped CALLs.

    --
    Ken
    http://www.kensims.net/
    Opinions expressed are my own and do not necessarily represent the views
    of my employer or anyone in their right mind.

  5. Re: How to pass NUMERIC in CHAR parm in a procedure without usingBIF ?

    Ken Sims wrote:

    > On Sat, 31 Mar 2007 01:36:47 -0700, Tom Liotta
    > wrote:
    >
    >> Any reason it can't just be a pointer by value? (Other than all the
    >> logical problems that can cause...)

    >
    > That will work just fine. I've used that for passing parameters of a
    > type which wasn't supported by prototyping at that release, or where
    > it could be about anything and other parameters would contain the
    > needed information about that parameter.
    >
    > It does give you additional opportunities to shoot yourself in the
    > foot, but no more so than good ol' unprototyped CALLs.


    Hi, Ken.

    I use it when it seems reasonable, but sparingly. Hard to pass up the
    chance to get Barbara to slip a useful tidbit in though. I know it's a
    tough kind of thing to recommend. Yet, if a language doesn't directly
    support a thing, good advice on proper handling by the developer is a
    way to go.

    A comment that gives foundation for discussion starts it off. The rest
    of us can fill out the thread. Hopefully, if we go wrong, minor
    corrections can keep it on track.

    As for unprototyped CALLs, that seems an excellent way to talk about it.
    The pointers behind a basic PARM list aren't much different from
    prototyped pointers-by-value.

    --
    Tom Liotta
    http://zap.to/tl400

  6. Re: How to pass NUMERIC in CHAR parm in a procedure without usingBIF ?

    Tom Liotta wrote:
    >
    > Any reason it can't just be a pointer by value? (Other than all the
    > logical problems that can cause...)
    >


    Tom, you're right, that's one way to handle it. But I think
    Jean-Laurent wanted to make it _easier_ to call his procedure

    Passing a pointer to the parameter would require also passing
    information about the parameter type and length, which would make
    calling the procedure far more unpleasant than just coding %CHAR when
    passing the parameter.

+ Reply to Thread