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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making sure an array has been populated: 2

Status
Not open for further replies.

cturland

Programmer
Sep 25, 2000
66
0
0
GB
Hi all,

I've populated a session array with 659 objects. The problem is that sometimes I try and access the array to quickly before it has finished populating - which obviously returns an error. Is there anyway that I can check that the 659 element of the array is there, I know I can check to see if the array is defined by the isdefined function but it does not seem to work when trying to check if one element is there.

Any ideas?
 
I'm not very familiar with arrays, but maybe you can check it by using: ArrayLen(array), this returns the length of the array, with a simple check you see if the length is the same?

Or using CFLOCK might also be a sollution. If I'm correct, it will first execute the code inside (populating the array) before you can continue with 'querying' that array.

With kind regards
Bram
 
I suggest using the two function IsDefined() and ArrayLen().

<CFIF IsDefined(&quot;aMyArray&quot;) AND ArrayLen(aMyArray) EQ 659>
Execute this code
</CFIF>
- tleish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top