Array Indexing

When i try to preview a report i get this error msg “The indexing 0 in the array is outside the permited range” And am returned back to the stating point.

The Qs is what might be wrong with my arrays, and how can i solve this? please assist

Thank you in advance.

Arrays in NAV are indexed starting from 1.

But have not defined any array with the value zero. What could bring about this?

Or May be i sent you the the report file and related tables you have a look on it.

Please.

Thank you in advance

Export the object as text and post it here.

Gen. Business Posting Group - OnAfterGetRecord()

GenBusiPostingGroupTotals[Jx] := 0;
GenBusiPostingGroupAmount[Jx] := 0;

valueEntry.RESET;
valueEntry.SETCURRENTKEY(“Item Ledger Entry Type”,“Gen. Bus. Posting Group”,“Inventory Posting Group”,“Posting Date”);
valueEntry.SETFILTER(valueEntry.“Item Ledger Entry Type”,‘Sale’);
valueEntry.SETRANGE(valueEntry.“Gen. Bus. Posting Group”,“Gen. Business Posting Group”.Code);
valueEntry.SETRANGE(valueEntry.“Posting Date”,SalesDateFilter,SalesDateFilter1);

Jx := 1;
valueEntry.SETRANGE(valueEntry.“Inventory Posting Group”,‘InventoryPostingGrpCode’);
IF valueEntry.FIND(’-’) THEN
REPEAT
GenBusiPostingGroupAmount[Jx] += valueEntry.“Sales Amount (Actual)”;
UNTIL valueEntry.NEXT = 0;
GenBusiPostingGroupTotals[Jx] += GenBusiPostingGroupAmount[Jx];

In these line

GenBusiPostingGroupTotals[Jx] := 0;
GenBusiPostingGroupAmount[Jx] := 0;

What value has Jx ?

Jx is an array that i set on the global variable. Datatype is integer. So the value of Jx on the above will depend on the no of loops done.

If its the first loop then Value of Jx should be 1, second loop is 2 and so on.

In fact the major problem is how to DEBUGin Nav. Otherwise i could have traced the error but see i cant trace it.

You may turn debug on by selecting Tools → Debugging → Active. When you run the report and the report stops, the debug window will open and show the “offending” line.

I would bet the line showed will be:

GenBusiPostingGroupTotals[Jx] := 0;

If you look at your code, you can see that you are first using the variable Jx as an array index, then assigning a value to it.

After setting the debuger on, how do you step into and over the stamements?

Thanks

For example in VB 6 you step into with key F8, Vb.net F10 and F9. So what about Navision.

Please help.

You may set in advance breakpoints into an object (provided you know which object is going to be executed and where might be the problem) by opening it in object designer and using the F9 key on the line you want the debugger stop at. You’ll need to remove the breakpoint after the debug manually, using the F9 key again.
Or you may start the debug with the option “Breakpoint at triggers” on, then, once the debug has started you may choose where set breakpoints (again using F9 key) and turn the option off.

While debug is running: F5 goes to the next breakpoint, F8 goes to next step into whatever function and whatever object, CTRL+F8 goes to the next step in the object and function you are in.

Anyway, in the case on hand you don’t need anything of the above, since with the debug active, the error message will cause the report to stop and the debugger window to open on the line which has caused the error. All the user defined variables (as jx is) will be visible, fields in record will not, but, again, you don’t need them in the case at hand.

Thanxs alot Guys. Have sorted out the issue of Array Indexing and have also known how to use the debuger. Since am new in Navision i shall continue posting more challenges.

Thanx alot once more

Regards

You are most welcome. Please, mark your question as answered and evaluate it. [:)]