sander
sander

Reputation: 1654

Calling a procedure from another file

I'm trying to call a procedure which is is another file. What I've got so far results in an error:

test.p

DEFINE VARIABLE tmp AS CHARACTER.
      RUN sumWords.p(INPUT "Hello", INPUT "World", OUTPUT tmp).
DISPLAY tmp.

sumWords.p

 PROCEDURE sumWords:
        DEFINE INPUT PARAMETER i_firstWord AS CHARACTER.
        DEFINE INPUT PARAMETER i_secondWord AS CHARACTER.
        DEFINE OUTPUT PARAMETER o_returnWord AS INTEGER. 

        o_returnWord = i_firstWord + i_secondWord.
    END PROCEDURE.

test.p passed parameters to sumWords.p, which didn't expect any. (1005)

Upvotes: 3

Views: 1540

Answers (1)

Mike Fechner
Mike Fechner

Reputation: 7192

You have created an internal procedure "sumWords" in "sumWords.p". sumWords.p does indeed not expect parameters.

Either change sumWords.p and remove the lines PROCEDURE sumWords: and END PROCEDURE.

That way the sumWords.p expects the parameters.

Or change the caller:

DEFINE VARIABLE hSumWords AS HANDLE NO-UNDO.

RUN sumWords.p PERSISTENT SET hSumWords. 

RUN sumWords IN hSumWords (INPUT "Hello", INPUT "World", OUTPUT tmp).

DELETE OBJECT hSumWords.

Upvotes: 7

Related Questions