Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array error "A subscript must be between 1 and the size of the array"

Status
Not open for further replies.

pdankert

Programmer
Nov 4, 2003
19
US
Crystal 8.5
Oracle 9i
I am need to create a unique string for each unique shipping pattern. For example shipping to Miami then Daytona then Atlanta will create MiamiDaytonaAtlanta and the order matters.

/////////DETAIL SECTION\\\\\\\\\whileprintingrecords;
global stringvar holdshipnum;
global numbervar citylength;
global stringvar citycompare;

// get the length of the city name
citylength := length ({SHIPHEAD.SHIPCITY});

// get # of characters from the right of holdshipnum that is equal to the citylength from above
citycompare := Right(holdshipnum, citylength);


// If last city shipped to is the same as the current city shipping to, do nothing.
// Else append a new city to holdshipnum string. This is because a load could have multiple stops in the same city.
if citycompare like {SHIPHEAD.SHIPCITY}
then holdshipnum := holdshipnum
else
holdshipnum := holdshipnum + trim({SHIPHEAD.SHIPCITY})


////////////GROUP FOOTER SECTION\\\\\\\\\\\\\global stringvar holdnum;
global stringvar array shipnumarray;
global numbervar loadcount;


loadcount := loadcount + 1;
shipnumarray[loadcount] := holdnum

Need this array to hold the unique string that was created in the detail section for the load for comparison later, with each increment of the loadcount variable.

However I am getting the following error:
"A subscript must be between 1 and the size of the array" on the line "global stringvar holdnum"

Any help is appreciated.
 
Try something like:

global stringvar holdnum;
global stringvar array shipnumarray;
global numbervar loadcount:=loadcount+1;
redim preserve shipnumarray[loadcount];
shipnumarray[loadcount] := holdnum

-k
 
Ok, that got rid of the error, but I'm not sure what it did for me. What does the following line do?

redim preserve shipnumarray[loadcount];
 

global stringvar array shipnumarray;

all this does is create a variable to hold the array what you also need to do is set how many values the rarray contains

redim shipnumarray[5]

this will clear any values in the current array and allow the array to hold up to 5 values.

redim preserve shipnumarray[5]

this will leave values that are currently held in the array and allow the array to hold up to 5 values.

so in your report SV is using the loadcount variable to increnment the size of the array each time a new value requires to be added.

HTH


Gary Parker
MIS Data Analyst
Manchester, England
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top