Passing an array as a parameter for a function in pick

171 views Asked by At

Is it possible to pass an array as a parameter for a function in d3 pick? I have tried doing that and it seems to generate an error message:

B14 Bad Stack Descriptor

The error message appears if you try to pass an array as a parameter for a function. This leads me to two questions.

1) Is it is even possible to pass an array as a parameter in d3 pick?

2) If it is not possible to pass an array directly, is there some kind of workaround that will allow one to achieve the same result?

2

There are 2 answers

0
TonyG On BEST ANSWER

The terminology in the question is a bit ambiguous but try this:

DIM ARRAY(5)
ARRAY(1) = "FOO"
CALL MYSUB( ARRAY )
CRT ARRAY(1) ; * should be BAR
END

And in the called item:

SUBROUTINE MYSUB( MYARRAY )
DIM MYARRAY()
MYARRAY(1) = "BAR"
RETURN

Another solution to this is to pass it indirectly through Common: COMMON ARRAY(5) ARRAY(1) = "FOO" CALL MYSUB CRT ARRAY(1) ; * should be BAR END

And in the called item:

SUBROUTINE MYSUB
COMMON MYARRAY(5) ; * need to agree
MYARRAY(1) = "BAR"
RETURN

To avoid the need to have each program know how many elements are required, put that code in an Include item:

Include item APP.COMMON:

COMMON ARRAY(5)
* nothing else here unless you have other things going on

Mainline code:

INCLUDE APP.COMMON
ARRAY(1) = "FOO"
CALL MYSUB
CRT ARRAY(1) ; * should be BAR
END

And in the called item:

SUBROUTINE MYSUB
INCLUDE APP.COMMON
ARRAY(1) = "BAR" ; * need to use same variable declared in the include item
RETURN
1
Frank Jackson On

Yes you can...

Create a program "MainProgram"

Program MainProgram
  MyArray = ""
  MyArray<1> = "ParameterValue2"
  MyArray<2> = "ParameterValue2"
  call MySubroutine(MyArray)
Stop

Create the Subroutine "MySubroutine"

Subroutine MySubroutine(PassedParam)
  for x = 1 to dcount(PassedParam,@AM)
    print PassedParam<x>
  next x
return

The Subroutine needs to be compiled and cataloged.