Functions

Back to Lansa, and functions. This stumped me at first but now I think I have got it.

Function Options(*DIRECT *NOMESSAGES) Rcv_List(#LIST)

#LIST is passed to the function which can then manipulate it. However, parameters are sent via the exchange stack:

Exchange Fields(#FIELD1 #FIELD2 #FIELD3 #FIELD4)
Call Process(*DIRECT) Function(FUNCNAME) Pass_Lst(#LIST)

The important point is that the fields and the list has to have exactly the same definition both places, which applies to all that is passed and exchanged. And since it is a list, that includes all the fields in the list, type, counter and not least number of entrys. So this would work:

Function:

Function Options(*DIRECT *NOMESSAGES) Rcv_List(#LIST)
Define Field(#FIELD1) Type(*CHAR) Length(10)
Define Field(#FIELD2) Type(*CHAR) Length(10)
Define Field(#FIELD3) Type(*DEC) Length(2)
Define Field(#FIELD4) Type(*DEC) Length(2)
Define Field(#COL1) Type(*DEC) Length(5) Decimals(0) Edit_Code(Z)
Define Field(#COL2) Type(*CHAR) Length(20)
Define Field(#COL3) Reffld(#COL2)
Def_List Name(#LIST) Fields(#COL1 #COL2 #COL3) Counter(#LISTCOUNT) Type(*WORKING) Entrys(102)
...
Return

Caller:

Define Field(#FIELD1) Type(*CHAR) Length(10)
Define Field(#FIELD2) Type(*CHAR) Length(10)
Define Field(#FIELD3) Type(*DEC) Length(2)
Define Field(#FIELD4) Type(*DEC) Length(2)
Define Field(#COL1) Type(*DEC) Length(5) Decimals(0) Edit_Code(Z)
Define Field(#COL2) Type(*CHAR) Length(20)
Define Field(#COL3) Reffld(#COL2)
Def_List Name(#LIST) Fields(#COL1 #COL2 #COL3) Counter(#LISTCOUNT) Type(*WORKING) Entrys(102)
Exchange Fields(#FIELD1 #FIELD2 #FIELD3 #FIELD4)
Call Process(*DIRECT) Function(FUNCNAME) Pass_Lst(#LIST)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s