I hope this code is useful to someone; I was trying to do something and found I did not understand what I was being told about conditional loops, so I built this so I could see how they worked. If it helps you great, if not sorry.
CODE
<!--- This must be some pretty poor code written my rhoisy
Today is Dec 03 2007
If some one wants to make this code better and easier to understand, be my guest, just send me a copy so I can analyse my mistakes. --->
<!--- Create a ColdFusion page with the following content: --->
<cfset chars = "0123456789abcdefghiklmnopqrstuvwxyz">
<cfset SpecialChar = "##$%^&()">
<cfset strLength = 7>
<cfset r = 0>
<!--- <cfset j = 0> --->
<cfset new_passwords = 25>
<cfset passwords = 1>
<cfset no_special_char = 0>
<cfset randout = ArrayNew(1)>
<!--- Setting the Array up for the correct number of new passwords according to #new_passwords# --->
<cfloop from="1" to="#new_passwords#" index="b">
<cfset randout[b] = "">
</cfloop>
<!--- Look and see what is in the Array --->
<!--- Double loop - First loop divides the random strings; while the
second loop divides them into 6 letters and numbers --->
<!--- <cfloop from="1" to="#new_passwords#" index="j" > --->
<cfloop condition="#new_passwords# GE #passwords#" >
<!--- Set no special character to 0 so I can see if one gets set. --->
<cfset no_special_char = 0>
<!--- Inside loop make up the individual passwords --->
<cfloop from="1" to="#strLength#" index="i">
<!--- Set up randon number and random Special Character for the first pass --->
<cfset rnum = ceiling(rand() * len(chars))>
<cfset rspecial = ceiling(rand() * len(SpecialChar))>
<cfif rnum EQ 0 >
<cfset rnum = 1>
</cfif>
<!--- Looking for a randon match to a randon number/MOD of a randon number or just a randon number, How dumb can I get? --->
<cfif rnum is #i# >
<cfset randout[#passwords#] = randout[#passwords#] & mid(SpecialChar, rspecial, 1)>
<cfset #no_special_char# = #no_special_char# + 1>
<!--- This number could have MODs attached and we need to consider them as well --->
<cfelseif rnum Mod 7 is #i# >
<cfset randout[#passwords#] = randout[#passwords#] & mid(SpecialChar, rspecial, 1)>
<cfset #no_special_char# = #no_special_char# + 1>
<cfelse>
<cfset randout[#passwords#] = randout[#passwords#] & mid(chars, rnum, 1)>
</cfif>
<!--- I'm leaving these cf dumps as they helped me find the solution when I had not clue how this code worked.
This is the state of randout during the first loop <cfdump var="#randout[passwords]#"> <P>
This is the password count: <cfdump var="#passwords#"> <P>
<!--- This is false Special Char:<cfdump var="#i#"> <P> --->
This is the state of the no special Character after rounout <cfdump var="#no_special_char#"> <P>
This is the loop I count: <cfdump var="#i#"> <P> --->
<!--- End of inside loop for seven character password --->
</cfloop>
<!--- once again this is juse information on how to use the different version of cf dump. --->
<!--- This is the no special char outside of loop i <cfdump var="#no_special_char#"> --->
<!--- This is the passwords count ourside of loop i <cfdump var="#passwords#">
<!--- <cfdump var="#j#" > is the J before the if <P> --->
This is the current randoout; <cfdump var="#randout[passwords]#"> <P>
--->
<cfif no_special_char EQ 0>
<cfset randout[passwords] = "">
<cfelse>
<cfset #passwords# = #passwords# +1>
</cfif>
</cfloop>
<html>
<head>
<title>Random String/Passwords</title>
</head>
<body>
In this piece of code you will see how I created a random string of letters, digits and special characters. This can be used for making random passwords. <P>
Althought, I can't understand why, but I really did it just to see how the loops could be made to do what I wanted them to do. <P>
<B> What made it important to me was the way the conditional loop works. <P> </B>
PS. If your random generator comes up with an "&" followed by a "#" and then a number you get "" and that one is hard to use as a password.
To create a simple randon string: <P>
<!--- This outputs the randon strings --->
<cfoutput>
<!--- <cfloop from="1" to="Randout Length" index="k"> may work, but what is below does work.--->
<cfloop from="1" to="#ArrayLen(randout)#" index="k">
<!--- More debug and as you can see I had a lot of problems <cfdump var="#ArrayLen(randout)#"> <space> --->
<strong> Index: #k# Random output: #randout[k]# </strong><P>
</cfloop>
</cfoutput>
</body>
</html>