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 Problem -- Duplicating Value??

Status
Not open for further replies.

hacole

Programmer
Jan 19, 2001
16
US
Hello, all. I'm working with an application where the user can add a new account, premise, and service point. Once they complete this, they have the option to go back to the beginning and do another, or go to a report page. Throughout the app there are five fields that I'm building arrays with. These are the fields that appear in the report page table. One of them is acting up and I cannot figure out why it's behaving differently than the others. It seems that it's possibly holding two values instead of one?....

Entry File:
Code:
<CFPARAM name=&quot;session.S_TEMP_SERVICE_IND&quot; default=&quot;1&quot;>
...

<!--- Create History arrays and cycle --->
<CFSET SESSION.H_REPEAT=1>
...
<CFSET SESSION.H_TEMP_SERVICE_IND=ArrayNew(1)>
<CFSET SESSION.H_TEMP_SERVICE_IND[SESSION.H_REPEAT]=&quot;!&quot;>

Set the session var to the form var and set array value:
Code:
<CFSET SESSION.S_TEMP_SERVICE_IND=FORM.S_TEMP_SERVICE_IND>
...
<CFSET SESSION.H_TEMP_SERVICE_IND[SESSION.H_REPEAT]= SESSION.S_TEMP_SERVICE_IND>

Here's where I'm building the table:
Code:
<CFLOOP CONDITION=&quot;L_LINE LESS THAN #SESSION.H_REPEAT#&quot;> 
    	<CFSET L_LINE=L_LINE + 1> 
...
<CFSET L_TEMP_SERVICE_IND=SESSION.H_TEMP_SERVICE_IND[L_LINE]> 
...
<CFIF L_TEMP_SERVICE_IND EQ &quot;!&quot;>
   <CFSET L_TEMP_SERVICE_IND=&quot; &quot;>
</CFIF> 
...
<td width=&quot;12%&quot; align=&quot;middle&quot;><font size=&quot;2&quot;> <CFOUTPUT>#L_TEMP_SERVICE_IND#</CFOUTPUT></font></td> 
</tr>
</CFLOOP>

Here's the error I get:
An error occurred while evaluating the expression:
L_TEMP_SERVICE_IND=SESSION.H_TEMP_SERVICE_IND[L_LINE]

The element at position 2 in dimension 1 of object &quot;SESSION.H_TEMP_SERVICE_IND&quot; cannot be found. The object has elements in positions 1 through 1. Please, modify the index expression.


Here's the output when I hard code the array position to 1:
Code:
(<CFSET L_TEMP_SERVICE_IND=SESSION.H_TEMP_SERVICE_IND[1]>)
7376091053 500 N 3RD AVE 9658777414 9879549455 Y
Y
Any help or ideas would be greatly appreciated!!!! I'm at a loss right now!!!

Thanks,
Holly
 
You may find that one of the elements in your array/list, contains a character that it thinks is a delimeter (usually a comma).

This would have the effect of making it think it has an extra element in the array.

Display all the elements that your putting into the array, and you should discover weather this is true or not.

This has happened to me before.

Good luck with it,

Puc
 
Thanks for the advice. I ended up getting it to work by inserting an empty value as the last value in every array.

This is the file before I go to the report. If I'm on the fifth element of all my arrays, it would create a blank element for the fifth+1.
Code:
<CFSET SESSION.H_REPEAT=SESSION.H_REPEAT+1>
<CFSET SESSION.H_ACCOUNT_ID[SESSION.H_REPEAT]=&quot;!&quot;>
<CFSET SESSION.H_STD_FORM_ADDR[SESSION.H_REPEAT]=&quot;!&quot;>
<CFSET SESSION.H_PREMISE_ID[SESSION.H_REPEAT]=&quot;!&quot;>
<CFSET SESSION.H_SP_ID[SESSION.H_REPEAT]=&quot;!&quot;>
<CFSET SESSION.H_TEMP_SERVICE_IND[SESSION.H_REPEAT]=&quot;!&quot;>

You can see above in my first posting how I worked the report after this.

Thanks,
Holly
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top