Sign in to follow this  
Followers 0
TerarinK

Wierd thing happening

5 posts in this topic

$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

Share this post


Link to post
Share on other sites



$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

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 ... :D

Edited 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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0