How to pass whole array to function?

Hi,
I try to pass an whole array to a function but it wont work, how to pass an whole array to the function?

FUNCTION fun_name RETURNS LOGICAL (INPUT m_var AS CHARACTER EXTENT 10 ):
IF m_var[5] = "hi" THEN
RETURN YES.
RETURN NO.
END.

DEFINE VARIABLE m AS CHARACTER EXTENT 10 INIT ["l","o","p","h","hi","","","","",""] .

IF fun_name(m) THEN
DISP "correct".
 
Another reason to go to version 10.
This:
Code:
FUNCTION fun_name RETURNS LOGICAL (INPUT m_var AS CHARACTER EXTENT 10 ):
    RETURN m_var[5] = "hi".
END.
compiles fine in version 10.

In version 9 and earlier you have to put the extent values in some delimited list or in a extent field of a temp-table:

Code:
DEFINE VARIABLE itmp AS INTEGER    NO-UNDO.
DEFINE TEMP-TABLE tttest NO-UNDO
    FIELD ittest AS INTEGER EXTENT 10.
 
 
FUNCTION tt RETURNS INTEGER (INPUT TABLE ttTest):
    FOR FIRST tttest:
            RETURN tttest.ittest[4].
    END.
END.
CREATE ttTest.
DO itMp = 1 TO 10:
    ASSIGN ttTest.ittest[itMp] = iTmp.
END.
 
MESSAGE tt(INPUT TABLE ttTest)
    VIEW-AS ALERT-BOX INFO BUTTONS OK.

HTH,

Casper.
 
Back
Top