House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

Checking arrays for any values

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Richard Steele
09/05/2010 10:26 PM

If any of the elements of an array have a value of 1 for bit datatypes or don't have empty strings for string datatypes, then I need to have my program do one thing, otherwise, if everything is either empty or false, another thing.  I could parse the array and get their values, but I wonder if there is an easier way. Thanks in advance.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Scott Brady
09/06/2010 06:38 AM

You can do listFind(arrayToList(aYourArray),1)  for the bit datatypes.  I'm not sure what the performance of that will be if your array is very large, though. For the string array, you can do NOT listFind(arrayToList(aYourArray,"")) I'm not sure if that logic is exactly correct, but it should get you going down the right path. Scott ----- Excess quoted text cut - see Original Post for more ----- -- ----------------------------------------- Scott Brady http://www.scottbrady.net/

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Peter Boughton
09/06/2010 07:07 AM

In CF9, Adobe have (finally) added the ArrayFind function, which simplifies that code. (Also available in OpenBD v1.3 and above, and in Railo since early days.)

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Richard Steele
09/05/2010 10:26 PM

If any of the elements of an array have a value of 1 for bit datatypes or if all string datatypes are empty, then I need to have my program do one thing, otherwise, if everything is either empty or false, another thing.  I could parse the array and get their values, but I wonder if there is an easier way. Thanks in advance.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Peter Boughton
09/06/2010 05:36 AM

It's not clear what you're trying to do. Can you post examples of each type of value it might contain, and whether that is considered true/false? (It's probably still simplest to step through the array and check each value though.)


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

February 08, 2012

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29