Focal Point
[SOLVED] Stack Index is less than or equal to zero in Maintain

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/5611001962

January 31, 2008, 11:10 AM
brjohnson
[SOLVED] Stack Index is less than or equal to zero in Maintain
Hi everyone,

I was wondering if anyone could tell me why this function returns with the error message,
"Stack Index is less than or equal to zero"
The code is

Case AddEF
For all next emergency_funds.EMERGENCY_FUNDS.EFID into GetEmergFundStack ;
Compute EmergFundStack.EFID = GetEmergFundStack(GetEmergFundStack.Foccount).EFID + 1;
Stack clear GetEmergFundStack ;
For all include emergency_funds.EMERGENCY_FUNDS.EFID from EmergFundStack ;
Stack clear EmergFundStack ;
EndCase

This function is supposed to run when a user clicks the submit button. It works when they submit the first
record, but if they enter a new information into the form and hit submit again I receive this error. Any insight would be greatly appreciated.

Thanks

This message has been edited. Last edited by: brjohnson,


Bryan Johnson
WebFOCUS 7.7.03
Maintain
Win 7
Excel, PDF, HTML
January 31, 2008, 12:05 PM
Alan B
At first guess I cannot see why this would happen. My belief is that GetEmergFundStack.FocCount has to be a minimum of 1, but maybe for some reason it is zero. You can check by TYPEing it out.

(Just a thought, are you doing a reposition on emergency_funds.EMERGENCY_FUNDS.EFID, if it works on first but not on second, this could be the cause.)

That would be the only place I see this message being generated from your code slice though.

As a matter of course, I find that EXECing a fex to get the MAX.number (EFID) is quicker and easier than doing a For all next, which has to retrieve all records.


Alan.
WF 7.705/8.007
February 01, 2008, 11:37 AM
Maintain Wizard
Please add:

REPOSTION emergency_funds.EMERGENCY_FUNDS.EFID

To the top of your AddEF case. The first time through this case, there are records. The second time through this case, the database pointer is at the end of the file. When you go to reload, no records are loaded, GetEmergFundStack.Foccount = 0 and that's why you are getting the error.

In the future, if there are no records in the database you can do a check:

if GetEmergFundStack.Foccount = 0 then compute GetEmergFundStack.EFID = 1;

Alan points out that you could EXEC a table to get the maximum EFID, you can also make the segment an SH format. This way, you only have to read the first record instead of all the records.

Mark
February 05, 2008, 11:54 AM
brjohnson
Thanks for the help. It worked when I added REPOSITION to the code, but it was quicker to EXEC a fex to find the maximum EFID. So both of your solutions worked great and I really appreciate both of you chiming in.


Bryan Johnson
WebFOCUS 7.7.03
Maintain
Win 7
Excel, PDF, HTML