TerarinK Posted March 29, 2009 Posted March 29, 2009 $s_String = _RandomString(10) MsgBox(0, "", $s_String) Func _RandomString($iLen) Local $sStr = "" While Not StringLen($sStr) = $iLen ConsoleWrite( StringLen($sStr) & "=" & $iLen) If StringLen($sStr) Then $sTemp = Chr(Random(48, 122, 1)) If StringRegExp($sTemp, "(?i)[a-z0-9]") Then $sStr &= $sTemp Else $sTemp = Chr(Random(48, 57, 1)) If StringRegExp($sTemp, "(?i)[0-9]") Then $sStr &= $sTemp EndIf ConsoleWrite(@TAB & StringLen($sStr) & "=" & $iLen & @CRLF) WEnd Return $sStr EndFunc ;==>_RandomString For some strange reasons it is only get the first character and exiting out of the func. I mean 1=10 is false those leading to true in my statement am I not right? 0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E
LiveOnTheFly Posted March 29, 2009 Posted March 29, 2009 $s_String = _RandomString(10) MsgBox(0, "", $s_String) Func _RandomString($iLen) Local $sStr = "" While Not StringLen($sStr) = $iLen ConsoleWrite( StringLen($sStr) & "=" & $iLen) If StringLen($sStr) Then $sTemp = Chr(Random(48, 122, 1)) If StringRegExp($sTemp, "(?i)[a-z0-9]") Then $sStr &= $sTemp Else $sTemp = Chr(Random(48, 57, 1)) If StringRegExp($sTemp, "(?i)[0-9]") Then $sStr &= $sTemp EndIf ConsoleWrite(@TAB & StringLen($sStr) & "=" & $iLen & @CRLF) WEnd Return $sStr EndFunc ;==>_RandomStringoÝ÷ ØZ+²²ÚÚ«y«(ÈÊ'(¶Ø^~*ìµÈZ§-z¶§uìb¶)à¢ëh~Ø^~éÜ"g
Moderators SmOke_N Posted March 29, 2009 Moderators Posted March 29, 2009 (edited) While StringLen($sStr) < $iLen or While Not (StringLen($sStr) = $iLen) Your statement says basically "While StringLen() = 0". So the first loop the statement is no longer true. Edit: Actually, it's more like Not 1 = 1, I guess that's like -2 = 1 ... Edited March 29, 2009 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
TerarinK Posted March 29, 2009 Author Posted March 29, 2009 Oh ya thats why, I just said that to someone else the other day, man I feel like a idoit. Thank you Smoke_N. Also I know that I could do it without the NOT but was just curious to know how to do it, forgot to add the () 0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E
Moderators SmOke_N Posted March 29, 2009 Moderators Posted March 29, 2009 Oh ya thats why, I just said that to someone else the other day, man I feel like a idoit. Thank you Smoke_N. Also I know that I could do it without the NOT but was just curious to know how to do it, forgot to add the ()Might shed some insight:Global $i_len = 4, $i_loop While 1 $i_loop += 1 ConsoleWrite( _ "Value of Not " & $i_loop & ", (equivlent of StringLen()) = " & Not $i_loop & @CRLF & _ "Value of $i_len = " & ($i_len > 0) & @CRLF & _ "True or False on equality = " & ((Not $i_loop) = $i_len) & @CRLF & @CRLF) If ((Not $i_loop) = $i_len) Then ExitLoop If $i_loop = 10 Then $i_len = 0 WEnd Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now