1

Okay this might get a tad complex or not.

Have a file with a multivalues in attribute 4

I want to write another dictionary item that loops through the multivalue list, calls a subroutine and returns calculated values for each item in attribute 4.

somthing like

<4> a]b]c]d]e

New attribute

@RECORD<4>;SUBR("SUB.CALC.AMT", @1)

Result

<4> AMT a 5.00 b 15.00 c 13.50 d 3.25

Not quite sure how to pass in the values from RECORD<4>, had a vague notion of a @CNT system variable, but that's not working, which might mean it was from SB+ or one of the other 4GLs.

ScaryMinds
  • 335
  • 3
  • 11

1 Answers1

0

You might be over thinking this.

You should just be able to reference it without out doing the ";" and @1 thing (I am not familiar with that convention). Using an I-Descriptor this should do the trick, though I have traditionally used the actual dictionary names instead of the @RECORD thing.

 SUBR("SUB.CALC.AMT", @RECORD<4>) 

This should work provided your subroutine is compiled, cataloged and returns your desired value with the same value/subvalue structure as @RECORD<4> in the first parameter of the Subroutine.

SUBROUTINE SUB.CALC.AMT(RETURN.VALUE,JUICY.BITS)
JBC = DCOUNT(JUICY.BITS<1>,@VM)
FOR X=1 TO JBC
   RETURN.VALUE<1,X> = JUICY.BITS<1,X>:" or something else"
NEXT X
RETURN
END

Good luck.

Van Amburg
  • 1,207
  • 9
  • 15
  • Thanks Van, exactly right, not sure why I got caught on the place holder logic. Basically needed to derive a model (RECORD<4>) cost which included a subvalued extra cost depending on country, ergo the subroutine call. – ScaryMinds Nov 05 '18 at 23:36