Index out of Range Array error when adding dummy variable to array value

Nancy Palmquist nlp at vss3.com
Fri Jun 27 09:07:10 PDT 2008


Marcus wrote:
> Hello everyone,
> 
> Thank you for taking the time to look at this.
> 
> I am a newcomer to the filePro community and still learning, so please keep
> that in mind as you read this.
> The issue I'm having is that when I try to run the operation 'ut = ut +
> saleunit[ii]' I get the following error.
> 
> 
> *** A filePro Error Has Occurred ***
> 
> Array Index Out of Range: dim salu(12) -- Index: 0
> 
> Output Processing
> Line Number: 43
> Process contains a syntax error at position indicated.
> 
> 
> Here are the declareations of the variables and the lines they are declared
> on.
> dim saleunit[12](3, .0) 'line 5
> ut(5, .0)  'line 8
> ii(2, .0)  'line 8
> wt(5, .0)  'line 8
> 
> I have confirmed that the values the variables contain are the following
> just before the operation is run.
> ut = "0"
> ii = "7"
> saleunit["7"] = "1"
> saleunit[ii] = "1"
> ut + saleunit[ii] = "1"
> 
> I am able to use a show statement to print all values to the screen
> including the add operation.
> Trying to run the operation 'wt = ut + saleunit[ii]' gives the same result
> as trying to run 'ut = ut + saleunit[ii]'.
> 
> I have tried locating a similar error online with no success and after
> spending a couple of days trying to figure this out I've run out of ideas.
> 
> I have approached my boss, who has several years experience with filePro,
> with this error.  After looking it over, and not seeing the cause of the
> error, he has advised me to present it to the filePro mailing list.
> 
> We are running filePro version 5.0.14R4 on SCO UNIX 5.07.
> 
> I have included the table below.  The line giving the error is 43.
> 
> Thank you again for taking the time to look at this.  Any advise and/or
> solutions are greatly appreciated.
> 
> I can be reached at mbeach at vegena.net
> 
> -Marcus Beach
> 
> 
>   1  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'This table takes records from the sort select table vWarDenRep
> .
>        Then: 'and processes them for the Warranty denial claims report
> .
>   2  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'test var
> .
>        Then: declare test(1, yesno)
> .
>   3  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'external vars
> .
>        Then: declare extern startdate, enddate
> .
>   4  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'arrays
> .
>        Then:
> .
>   5  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'holds unit sales from INV
> .
>        Then: dim saleunit[12](3, .0):za
> .
>   6  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'holds unit warrenties from INV
> .
>        Then: dim warunit[12](3, .0):zm
> .
>   7  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'engine family var
> .
>        Then: ef(20, *, g)
> .
>   8  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'counting and total vars
> .
>        Then: ii(2, .0); ut(5, .0); wt(5, .0); tu(5, .0, g)
> .
>   9  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'subtotal vars
> .
>        Then: us(4, .0, g); ds(9, .2, g); td(9, .2, g); ua(4, .0, g); pc(3,
> .0, g); tp(3, .0, g)
>  10  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'test vars
> .
>        Then: declare failcd(4, .0, g), partnum(20, allup, g)
> .
>  11  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: failcd ne 12 'if fail code has changed
> .
>        Then: us = "0"; ds = "0"; failcd = 12 'reset subtotal vars
> .
>  12  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: partnum ne 4 'if part number has changed
> .
>        Then: gosub partcng
> .
>  13  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 110 ne "Y" 'if not a duplicate field increment units
> .
>        Then: us = us + "1"; ua = ua +1
> .
>  14  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'add claim cost to subtotal and total and calc %
> .
>        Then: ds = ds + 37; td = td + 37; pc = (us*"100")/tu; tp =
> (ua*"100")/tu.
>  15  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'end of output processing
> .
>        Then: end
> .
>  16  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
> datenum. If: 'This gosub takes a date and returns the integer value of the
> .
>        Then: ' date's month.
> .
>  17  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'gosub passed/return vars
> .
>        Then: declare local pdate(10, mdyy/), dnretval(2, .0)
> .
>  18  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'gosub internal vars
> .
>        Then: declare local bdate(10, mdyy/), edate(10, mdyy/)
> .
>  19  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'initialize vars for loop
> .
>        Then: bdate = boy(pdate); edate = addmonth(bdate); dnretval = "1"
> .
>  20  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
> dnloop . If: 'loops through until month is found
> .
>        Then: 'if pdate not between bdate and edate, increment and loop
> .
>  21  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: not (pdate ge bdate and pdate lt edate)
> .
>        Then: bdate = addmonth(bdate); edate = addmonth(edate); dnretval =
> dnretval + "1"; goto dnloop
>  22  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If:
> .
>        Then: return
> .
>  23  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
> saletot. If: 'this section calculates the number of parts sold for the date
> .
>        Then: 'range given
> .
>  24  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'date holding vars
> .
>        Then: declare startmonth(2, .0), endmonth(2, .0)
> .
>  25  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'lookup to INV by part number
> .
>        Then: lookup invlk = INV  k=4    i=A -npxu
> .
>  26  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: not invlk 'if look up fails, display error and exit
> .
>        Then: input popup test "ERROR: PART NUMBER NOT FOUND. CONTACT
> ADMINISTRATOR"; write invlk; close invlk; exit
>  27  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: ' get unit sales values from INV file
> .
>        Then: saleunit["1"] = invlk(119); saleunit["2"] = invlk(120)
> .
>  28  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: ' get unit sales values from INV file
> .
>        Then: saleunit["3"] = invlk(121); saleunit["4"] = invlk(122)
> .
>  29  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: ' get unit sales values from INV file
> .
>        Then: saleunit["5"] = invlk(123); saleunit["6"] = invlk(124)
> .
>  30  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: ' get unit sales values from INV file
> .
>        Then: saleunit["7"] = invlk(125); saleunit["8"] = invlk(126)
> .
>  31  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: ' get unit sales values from INV file
> .
>        Then: saleunit["9"] = invlk(132); saleunit["10"] = invlk(131)
> .
>  32  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: ' get unit sales values from INV file
> .
>        Then: saleunit["11"] = invlk(128); saleunit["12"] = invlk(129)
> .
>  33  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: ' get unit warranty values from INV file
> .
>        Then: warunit["1"] = invlk(387); warunit["2"] = invlk(388)
> .
>  34  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: ' get unit warranty values from INV file
> .
>        Then: warunit["3"] = invlk(389); warunit["4"] = invlk(390)
> .
>  35  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: ' get unit warranty values from INV file
> .
>        Then: warunit["5"] = invlk(391); warunit["6"] = invlk(392)
> .
>  36  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: ' get unit warranty values from INV file
> .
>        Then: warunit["7"] = invlk(393); warunit["8"] = invlk(394)
> .
>  37  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: ' get unit warranty values from INV file
> .
>        Then: warunit["9"] = invlk(395); warunit["10"] = invlk(396)
> .
>  38  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: ' get unit warranty values from INV file
> .
>        Then: warunit["11"] = invlk(397); warunit["12"] = invlk(398)
> .
>  39  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'init vars
> .
>        Then: ii = startmonth; ut = "0"; wt = "0";
> .


You are assigning ii=startmonth   but I do not find where you give startmonth 
the correct value.  You need to trace the value of startmonth and see why is is 
"0".  That is the fault.

Also the condition on line 43 should keep it from failing when ii < "0" or > 
"12"  .  You might want to add spaces around the AND if it is failing with the 
condition in place.  If you added that to control the error, and you are still 
getting the error, I am puzzled.

Nancy

>  40  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: endmonth eq "12" 'set end month to next month for loop
> .
>        Then: endmonth = "1"; test = "Y"
> .
>  41  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: test ne "Y"
> .
>        Then: endmonth = endmonth + "1"
> .
>  42  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'reset test var
> .
>        Then: test = ""
> .
>  43  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
> stloopa. If: (ii ge "1")and(ii le "12") 'add values for month ii to total
> var  .
>        Then: ut = ut + saleunit[ii]
> .
>  44  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: (ii ge "1")and(ii le "12") 'add values for month ii to total
> var  .
>        Then: wt = wt + warunit[ii]
> .
>  45  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'add values for month ii to total var
> .
>        Then: ut = ut + saleunit[ii]
> .
>  46  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: ii eq "12"  'if ii is 12, loop back to 1, set test var
> .
>        Then: ii = "1"; test = "Y"
> .
>  47  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: test ne "Y"  ' if ii was not just reset to 1, increment
> .
>        Then: ii = ii + "1"
> .
>  48  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'reset test var
> .
>        Then: test = ""
> .
>  49  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: ii ne endmonth ' if not past end month
> .
>        Then: goto stloopa  ' loop back
> .
>  50  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: ' get out of INV file
> .
>        Then: write invlk; close invlk
> .
>  51  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'else values for period totaled and return
> .
>        Then: return  ' end saletot
> .
>  52  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
> partcng. If: 'this runs to set values when the part number changes
> .
>        Then:
> .
>  53  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'reset vars
> .
>        Then: partnum = 4; ua = "0"; td = "0"
> .
>  54  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'get int value for starting month
> .
>        Then: pdate = startdate; gosub datenum; startmonth = dnretval
> .
>  55  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'get int value for ending month
> .
>        Then: pdate = enddate; gosub datenum; endmonth = dnretval
> .
>  56  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'get totals from INV
> .
>        Then: gosub saletot; tu = ut - wt
> .
>  57  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'lookup to get engine family
> .
>        Then:
> .
>  58  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If: 'return
> .
>        Then: return
> .
>  59  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If:
> .
>        Then:
> .
>  60  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>        . If:
> .
>        Then:
> .
> 
> 
> 
> 
> 
> E-mail message checked by Spyware Doctor (5.5.1.322)
> Database version: 5.10130e
> http://www.pctools.com/en/spyware-doctor/
> _______________________________________________
> Filepro-list mailing list
> Filepro-list at lists.celestial.com
> http://mailman.celestial.com/mailman/listinfo/filepro-list
> 
> 


-- 
Nancy Palmquist 		MOS & filePro Training Available
Virtual Software Systems	Web Based Training and Consulting	
PHONE: (412) 835-9417		   Web site:  http://www.vss3.com


More information about the Filepro-list mailing list