STACK TOP DATA

Hi

I am working on a case where I am planning to STACK TOP a pda and then use INPUT to get the data which I want to do it dynamically/generic .i.e. PDA can have any number of variable, INPUT should be able to get the data based on the number of PDA variable which I don’t want to specify(see below) because it will be a generic module which can handle any Kind of PDA and able to provide me the corresponding data from the variable.

STACK TOP DATA PARM-INPUT

INPUT (SG=OFF) OUTDATA (1)
OUTDATA (2)
OUTDATA (3)
OUTDATA (4)
OUTDATA (5)

I don’t want to specify the above and want if this can be built automatically, tried with using *DATA and then use a loop but that doesn’t work as it only picks 1 data.

Please let know if further details is required

Use *DATA to find out what’s on the stack and iterate over it.

Hi Wolfgang

I tried that but it does hold all the value if we loop in, it only holds 1st value.

IX := *DATA
EXPAND ARRAY OUTDATA TO (1:IX)
FOR IY = 1 TO IX
INPUT (SG=OFF) OUTDATA (IY) (AL=100)
END-FOR

I have tried the above…Do you mean something else?

STACK TOP DATA #OUT3
STACK TOP DATA #OUT2
STACK TOP DATA #OUT1
STACK TOP DATA '3'
*
INPUT #N
FOR #I 1 #N
  INPUT #OUTDATA (#I)
END-FOR

Guys,
I`m sorry for my ignorance :-), but I expected something like
STACK TOP DATA #OUT3
STACK TOP DATA #OUT2
STACK TOP DATA #OUT1
** STACK TOP DATA ‘3’ /* why? :slight_smile:
*
#N := DATA / *DATA should have been set to 3 NOW!
FOR #I 1 #N
INPUT #OUTDATA (#I)
END-FOR

Could you explain, please, what is wrong with MY version?
Many thanks in advance.

*DATA contains the number of elements in the top entry of the stack. It does NOT contain the number of entries on the stack.

As for my example, each STACK statement provides a single element, so *DATA will equal 1 for each iteration of INPUT.

Sarabjeet needs a variable number of data elements, but INPUT requires a fixed number, so I suggested passing that number at the top of the stack followed by one data element per stack entry.

Thank you very much, Ralph!
Well, according to the HELP, it is not that difficult to get confused by the following explanation (as I did)
Apparently, Sarabjeet interpreted it in the same way :slight_smile:

*DATA
This system variable contains the number of data elements in the Natural stack which are available to the next INPUT statement as input data

Hi Ralph/Nikolay

Thanks for your suggestion and discussion, but I am confused a bit now.

I have a PDA which I want to Stack top and it may contain any number of variables, *data will give me the count of the number of variables.

Not Sure If I understand the solution Ralph gave, Please let me know If I understand it incorrectly…

To retrieve data from the STACK, the INPUT statement must specify a variable for each element in the STACK entry. You cannot stack “any number of variables” because an INPUT statement is limited to 250 characters by 250 lines. No element can be more than 249 characters - there is no line-wrapping of elements.

You can define your map with the maximum number of variables, such as #VAR (A249/250) or #VAR (A124/500), and then stack all elements in a single entry. Then use a single INPUT to retrieve all the data and fill extra #VAR entries with nulls.

Or define the map with a single entry #VAR (A250) and input one data element at a time, as in my previous example, to allow for a variable number of data elements (with no maximum).

Thanks Guys, We found out a way to solve our problem of building a generic module to access the PDA data dynamically without using STACK TOP where it was restricting us to get a generic solution for all kind of PDA’s.