Jump to content
Sign in to follow this  

Question about using function...

Recommended Posts



i want use password generating function like this:

MsgBox(0,"Generated Password is:", genPassword(8))

Func genPassword($length)
    $array = StringSplit("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789","")

    $newPassword = ""
    For $X = 1 to $length
        $newPassword &= $array[Random (1, $array[0], 1)]

    return $newPassword


for getting and using generated random password, inside autoit script. But I donĀ“t know how can i write function output to variable for future use.

Can anyone help me with this beginner stupid question ? I can only write result to Message box, just as it is above.

Tank you

Radovan J.

Share this post

Link to post
Share on other sites

Not sure if this is what you mean.

Global $sGenPass

$sGenPass = _GeneratePassword(8)
MsgBox(0, "Generated Password is:", $sGenPass)
ConsoleWrite("Generated Password is:" & $sGenPass & @CRLF)

Func _GeneratePassword($iLength)
    Local $aArray = StringSplit("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", "")

    $sPassword = ""
    For $X = 1 To $iLength
        $sPassword &= $aArray[Random(1, $aArray[0], 1)]

    Return $sPassword
EndFunc   ;==>genPassword

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.