Using a copycode inside of a copycode and transporting operands down the chain?

Anyone did find out, how to call inside a copycode with variables another copycode with using the same variables of the first copycode as parameters for the second copycode?

Lets give an example:
CB_A of type copycode


&1& := &1& * 10
INCLUDE CB_B '&1&'

CB_B of type copycode


&1& := &1& + 1

PGM of type program


DEFINE DATA LOCAL
1 MYVALUE (N5)
END-DEFINE

MYVALUE := 5
INCLUDE CB_A 'MYVALUE'
END

I will then get the following error message in the PGM at the INCLUDE:

  • E_0890: Invalid source parameter construction. (source “CB_A” ln.6 col.14: “‘&1&’” - &n& notation in insert value ‘&1&’ not allowed)

And in the Console I have:
[17:07:51.512] Stowing program ‘TEST/PGM’…failed
[17:07:51.512] error: NAT0890 Invalid source parameter construction.

So what to write there, that Natural complies and is handing downwards operands to other copycodes?

Or is there no solution to this, and it is not possible to handle operands inside of copycode chains, except coding them as text constants directly in the source?

It makes for ugly code, but you could use an intermediate variable.

CB_B (unchanged)

&1& := &1& + 1

CB_A

#MYVALUE-TMP := &1& * 10
INCLUDE CB_B '#MYVALUE-TMP'
&1& := #MYVALUE-TMP

PGM

DEFINE DATA LOCAL
1 #MYVALUE (N5)      INIT <5>
1 #MYVALUE-TMP (N5)
END-DEFINE
WRITE 'before' #MYVALUE
INCLUDE CB_A '#MYVALUE'
WRITE ' after' #MYVALUE
END

Result:

Page     1                                                   08092017  09:12:57
 
before      5
 after     51

Only a guess (albeit an educated one):

In your program PGM

INCLUDE CB_A ‘MYVALUE’

MYVALUE must be the name of a variable that the compiler can find in an LDA or DEFINE DATA.

Now consider what the compiler tries to do with:

In the copycode CB_A

INCLUDE CB_B '&1&'  

the compiler would be looking for a variable with the name &1&. There is no such variable, hence the compiler error messages.

As Ralph noted, you can code around this with an extra variable.

You can also combine the two copycodes into one with two substitute variable &1& and &2&. Or, simply do the second computation in PGM.