Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

cfloop over array

New Here ,
Aug 24, 2009 Aug 24, 2009

I am looping over an array It works fine if all variables are declared in array, I am trying to skip the entire process even if one variable is not declared I tried using isdefined, I tried to use cftry and cfcatch... nothing working any suggestions......

1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 24, 2009 Aug 24, 2009

trim each element and check to see if the length is greater than 0.

Do this before you even create and populate the array.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 24, 2009 Aug 24, 2009

It gives this kind of error  when I am trying to check the length

Element 7 is undefined in a Java object of type class coldfusion.runtime.Array.

The error occurred in E:\www\test\codes.cfm: line 727
725 :                     <td>#da[1]#</td>
726 :                     <td>
727 :                     <cfset done = #trim(ca)#>
728 :                     <cfif Len(done) is 0>
729 :                     hi
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 24, 2009 Aug 24, 2009

That error is telling you that you are referencing the 7th element of a 6 element array.

I.E. ca[7] does not exist.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 24, 2009 Aug 24, 2009

Is there a way to weather an element in an array is decleared ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 24, 2009 Aug 24, 2009
LATEST

arrayLen(ca) would probably tell you all you want to know, but there are other interesting array related functions listed in the documentation as well.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources