Jump to content

Why I can't call a function more than 1 time?


Recommended Posts

Hello,

I would like to know why this For statement doesn't work as expecte (i.e. 10 MsgBox with the result of the function).

After executing the script, I can see the MsgBox with the debug of the chars string and the 1st MsgBox with the 1st password. But after this, the AutoIt icon stays in the tray area and after clicking on it it changes to a red cross and I must Exit it.

Any idea?

For $j = 0 to 10

    RandomPassword()

    $password =_ArrayToString($passwords," "); Convertir el array en un string
    $password = StringReplace($password," ",""); Eliminar los blancos que pone la función anterior

    MsgBox(0,"Password Aleatorio",$password)

Next

Here is the full script code

;
; Passwords aleatorios
;

#include <d:\run\autoit\include\Array.au3>

AutoItSetOption("TrayIconDebug", 1)
AutoItSetOption("MustDeclareVars", 1)

;~ ********************************************************************************
;~ Variables
;~ ********************************************************************************

Dim $longpassword = 8
Dim $numpasswords = 10
;Dim $passwords[$numpasswords][$longpassword]
Dim $passwords[$longpassword]
Dim $password = ""

Dim Const $minusculas = 0
Dim Const $mayusculas = 1
Dim Const $digitos = 2
Dim Const $simbolos = 3
Dim Const $maxsimbolos = 2

Dim $numminusculas = 26
Dim $nummayusculas = 26
Dim $numdigitos = 10
Dim $numsimbolos = 3

Dim $caracteres[$numminusculas + $nummayusculas + $numdigitos + $numsimbolos]
Dim $strcaracteres

Dim $limites[5]

$limites[$minusculas] = 0
$limites[$mayusculas] = $limites[$minusculas] + $numminusculas
$limites[$digitos] = $limites[$mayusculas] + $nummayusculas
$limites[$simbolos] = $limites[$digitos] + $numdigitos
$limites[4] = $limites[$simbolos] + $numsimbolos

Dim $j

;~ ********************************************************************************
;~ Rellenar caracteres
;~ ********************************************************************************

For $j = $limites[$minusculas] to ($limites[$mayusculas]-1)
    $caracteres[$j] = chr(97 + $j)
Next

For $j = $limites[$mayusculas] to ($limites[$digitos] - 1 )
    $caracteres[$j] = chr(65 + $j - $limites[$mayusculas])
Next        

For $j = $limites[$digitos] to ($limites[$simbolos] - 1)
    $caracteres[$j] = chr(48 + $j - $limites[$digitos])
Next    

For $j = $limites[$simbolos] to ($limites[4] - 1)
    $caracteres[$j] = chr(35 + $j - $limites[$simbolos])
    if $caracteres[$j] = "%" Then $caracteres[$j] = "?"
Next

;~ ********************************************************************************
;~ Debug
;~ ********************************************************************************

$strcaracteres=""
For $j = $limites[$minusculas] to ($limites[4] - 1)
    $strcaracteres = $strcaracteres & $caracteres[$j]       
Next

MsgBox(0,"String Caracteres",$strcaracteres);

;~ ********************************************************************************
;~ Random Password
;~ ********************************************************************************

For $j = 0 to 10

    RandomPassword()

    $password =_ArrayToString($passwords," "); Convertir el array en un string
    $password = StringReplace($password," ",""); Eliminar los blancos que pone la función anterior

    MsgBox(0,"Password Aleatorio",$password)

Next

Exit

;~ ********************************************************************************
;~ Funciones
;~ ********************************************************************************

Func RandomPassword()

Local $pos
Local $numsimbolos = 1
Local $tipo
Dim $j

;
; Hay que generar un password que tenga al menos:
; - 1 minúscula
; - 1 mayúscula
; - 1 número
; - 1 símbolo
;

For $j = $minusculas to $simbolos
    $pos = Random(0, $longpassword - 1, 1)
    if IsString($passwords[$pos]) = 1 then
        do
            $pos = Random(0, $longpassword - 1, 1)
            until IsString($passwords[$pos]) = 0
    endif
        $passwords[$pos] = $caracteres[Random($limites[$j],$limites[$j+1]-1,1)]
Next

For $j = 4 to $longpassword-1
    $pos = Random(0, $longpassword - 1, 1)
    if IsString($passwords[$pos]) = 1 Then
        do
            $pos = Random(0, $longpassword - 1, 1)
        until IsString($passwords[$pos]) = 0
    endif

; No podemos generar más de 2 simbolos

    if $numsimbolos < $maxsimbolos then
        $tipo = Random($minusculas,$simbolos,1)
        if $tipo = 3 then
            $numsimbolos = $numsimbolos + 1
        endif
    else
        $tipo = Random($minusculas,$digitos,1)
    endif
    $passwords[$pos] = $caracteres[Random($limites[$tipo],$limites[$tipo+1]-1,1)]
Next

EndFunc
Link to comment
Share on other sites

  • Moderators

Well... Your stuck in a Do/Until Loop... if you explained what those 2 loops are supposed to accomplish exactly... we could probably help you better... I put a ToolTip there so you can see for yourself:

;
; Passwords aleatorios
;

#include <Array.au3>

AutoItSetOption("TrayIconDebug", 1)
;AutoItSetOption("MustDeclareVars", 1)

;~ ********************************************************************************
;~ Variables
;~ ********************************************************************************

Dim $longpassword = 8
Dim $numpasswords = 10
;Dim $passwords[$numpasswords][$longpassword]
Dim $passwords[$longpassword]
Dim $password = ""

Dim Const $minusculas = 0
Dim Const $mayusculas = 1
Dim Const $digitos = 2
Dim Const $simbolos = 3
Dim Const $maxsimbolos = 2

Dim $numminusculas = 26
Dim $nummayusculas = 26
Dim $numdigitos = 10
Dim $numsimbolos = 3

Dim $caracteres[$numminusculas + $nummayusculas + $numdigitos + $numsimbolos]
Dim $strcaracteres

Dim $limites[5]

$limites[$minusculas] = 0
$limites[$mayusculas] = $limites[$minusculas] + $numminusculas
$limites[$digitos] = $limites[$mayusculas] + $nummayusculas
$limites[$simbolos] = $limites[$digitos] + $numdigitos
$limites[4] = $limites[$simbolos] + $numsimbolos

Dim $j

;~ ********************************************************************************
;~ Rellenar caracteres
;~ ********************************************************************************

For $j = $limites[$minusculas] to ($limites[$mayusculas]-1)
    $caracteres[$j] = chr(97 + $j)
Next

For $j = $limites[$mayusculas] to ($limites[$digitos] - 1 )
    $caracteres[$j] = chr(65 + $j - $limites[$mayusculas])
Next        

For $j = $limites[$digitos] to ($limites[$simbolos] - 1)
    $caracteres[$j] = chr(48 + $j - $limites[$digitos])
Next    

For $j = $limites[$simbolos] to ($limites[4] - 1)
    $caracteres[$j] = chr(35 + $j - $limites[$simbolos])
    if $caracteres[$j] = "%" Then $caracteres[$j] = "?"
Next

;~ ********************************************************************************
;~ Debug
;~ ********************************************************************************

$strcaracteres=""
For $j = $limites[$minusculas] to ($limites[4] - 1)
    $strcaracteres = $strcaracteres & $caracteres[$j]       
Next

MsgBox(0,"String Caracteres",$strcaracteres);

;~ ********************************************************************************
;~ Random Password
;~ ********************************************************************************

For $j = 0 to 10
    RandomPassword()

    $password =_ArrayToString($passwords," "); Convertir el array en un string
    $password = StringReplace($password," ",""); Eliminar los blancos que pone la función anterior

    MsgBox(0,"Password Aleatorio",$password)

Next

Exit

;~ ********************************************************************************
;~ Funciones
;~ ********************************************************************************

Func RandomPassword()

Local $pos
Local $numsimbolos = 1
Local $tipo
Dim $j

;
; Hay que generar un password que tenga al menos:
; - 1 minúscula
; - 1 mayúscula
; - 1 número
; - 1 símbolo
;

For $j = $minusculas to $simbolos
    $pos = Random(0, $longpassword - 1, 1)
    if IsString($passwords[$pos]) = 1 then
        do
            $pos = Random(0, $longpassword - 1, 1)
            ToolTip('Debugging RandomPassword Loop One - $pos = ' & $pos, @DesktopWidth / 2, @DesktopHeight / 2)
        until IsString($passwords[$pos]) = 0
    endif
    $passwords[$pos] = $caracteres[Random($limites[$j],$limites[$j+1]-1,1)]
Next

For $j = 4 to $longpassword-1
    $pos = Random(0, $longpassword - 1, 1)
    if IsString($passwords[$pos]) = 1 Then
        do
            $pos = Random(0, $longpassword - 1, 1)
            ToolTip('Debugging RandomPassword Loop Two - $pos = ' & $pos, @DesktopWidth / 2, @DesktopHeight / 2)
        until IsString($passwords[$pos]) = 0
    endif

; No podemos generar más de 2 simbolos

    if $numsimbolos < $maxsimbolos then
        $tipo = Random($minusculas,$simbolos,1)
        if $tipo = 3 then
            $numsimbolos = $numsimbolos + 1
        endif
    else
        $tipo = Random($minusculas,$digitos,1)
    endif
    $passwords[$pos] = $caracteres[Random($limites[$tipo],$limites[$tipo+1]-1,1)]
Next

EndFunc

What I mean by explain, is go through EACH line of that RandomPassword() and explain what you "Think it's doing", what your trying "To make it do", and what "Type of result" your expecting... Also, if you could explain why your using IsString() that would be great too.

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.

Link to comment
Share on other sites

Hello,

Thank you for the ToolTip. Using it I've seen that after the 1st MsgBox the script stays in the loop.

I'll try to explain the script. This script is used to generate a Random Password of 8 chars. This password must have:

- almost 1 lowercase letter

- almost 1 uppercase letter

- almost 1 number

- almost 1 symbol (2 symbols at a maximum)

I have an Array of 8 positions:

Dim $longpassword = 8
Dim $passwords[$longpassword]

The I construct an Array of chars as the source for the chars in the password:

Dim $numminusculas = 26
Dim $nummayusculas = 26
Dim $numdigitos = 10
Dim $numsimbolos = 3
Dim $caracteres[$numminusculas + $nummayusculas + $numdigitos + $numsimbolos]

Dim $limites[5]

$limites[$minusculas] = 0
$limites[$mayusculas] = $limites[$minusculas] + $numminusculas
$limites[$digitos] = $limites[$mayusculas] + $nummayusculas
$limites[$simbolos] = $limites[$digitos] + $numdigitos
$limites[4] = $limites[$simbolos] + $numsimbolos

Dim $j

;~ ********************************************************************************
;~ Rellenar caracteres
;~ ********************************************************************************

For $j = $limites[$minusculas] to ($limites[$mayusculas]-1)
    $caracteres[$j] = chr(97 + $j)
Next

For $j = $limites[$mayusculas] to ($limites[$digitos] - 1 )
    $caracteres[$j] = chr(65 + $j - $limites[$mayusculas])
Next        

For $j = $limites[$digitos] to ($limites[$simbolos] - 1)
    $caracteres[$j] = chr(48 + $j - $limites[$digitos])
Next    

For $j = $limites[$simbolos] to ($limites[4] - 1)
    $caracteres[$j] = chr(35 + $j - $limites[$simbolos])
    if $caracteres[$j] = "%" Then $caracteres[$j] = "?"
Next

The limites variable has the starting positions of every type of chars (lower, upper, numbers and symbols) in the array of chars.

Then, the function for generating the Random Password starts by choosing a lower letter, an upper letter, a number and a symbol and putting these chars in a random position in the final password. In this manner I can assure that the password has my requirements but it doesn't start always with the same pattern. This is the first loop:

For $j = $minusculas to $simbolos
    $pos = Random(0, $longpassword - 1, 1)
    if IsString($passwords[$pos]) = 1 then
        do
            $pos = Random(0, $longpassword - 1, 1)
            until IsString($passwords[$pos]) = 0
    endif
        $passwords[$pos] = $caracteres[Random($limites[$j],$limites[$j+1]-1,1)]
Next

In this loop -and in the second- I search an "empty" position in the final password by looking if there is a char (i.e. IsString). This work great when generating the first password. When generating the second password this do...until doesn't finish (I suppose that is related to the fact that $passwords has the content of the first password generated.

The second loop fills the 4 remaining positions in the final password. The only restriction is that when I have used 2 symbols in the password I can't add more. The script doesn't executes this second loop when generating the second password because it is stalled in the first loop.

So the question is how to re-initialize or erase the variable after each execution of the function? (if the variable has the same content than initialy I suppose the code will work).

Any help would be very appreciated.

Thank you.

Link to comment
Share on other sites

  • Moderators

Well, I'll admit, I'm still a bit confused... Try this out and see if it's what your trying to accomplish... I'm half asleep, so I'm not sure if I under stand your request, but this will only allow 2 characters of each of the 4 sets of characters you've chosen

MsgBox(0, 'Testing Password', 'Your Password is: ' & _GeneratePassword())

Func _GeneratePassword($s_SpecialCharacters = "#,$,?", $s_Dilemeter = ',')
    Local $s_Character = StringSplit($s_SpecialCharacters, $s_Dilemeter)
    Local $i_Random[3]
    Local $s_Password = ''
    Local $i_Count[5]
    Do
        $i_Random[1] = Random(1, 4, 1)
        If $i_Random[1] == 1 And $i_Count[1] < 2 Then
            $i_Count[1] = $i_Count[1] + 1
            $i_Random[2] = Random(1, 26, 1)
            $s_Password = $s_Password & Chr($i_Random[2] + 96)
        EndIf
        If $i_Random[1] == 2  And $i_Count[2] < 2 Then
            $i_Count[2] = $i_Count[2] + 1
            $i_Random[2] = Random(1, 26, 1)
            $s_Password = $s_Password & Chr($i_Random[2] + 64)
        EndIf
        If $i_Random[1] == 3  And $i_Count[3] < 2 Then 
            $i_Count[3] = $i_Count[3] + 1
            $i_Random[2] = Random(0, 9, 1)
            $s_Password = $s_Password & $i_Random[2]
        EndIf
        If $i_Random[1] == 4  And $i_Count[4] < 2 Then 
            $i_Count[4] = $i_Count[4] + 1
            $i_Random[2] = Random(1, 3, 1)
            $s_Password = $s_Password & $s_Character[$i_Random[2]]
        EndIf
    Until StringLen($s_Password) == 8
    Return $s_Password
EndFunc
This should always be something a bit unique...

I was about to delete this file... So I thought I would update the UDF a bit, has parameters for password, how many characters you want for each type.

While 1
    If MsgBox(4, 'Testing Password', 'Your Password is: ' & _GeneratePassword() & @CRLF & 'Would you like to generate another?') = 7 Then Exit
WEnd

Func _GeneratePassword($s_SpecialCharacters = "#,$,?", $s_Dilemeter = ',', $i_PasswordLen = 8, $n_Lower_az = 2, $n_Upper_AZ = 2, $n_Numb09 = 2, $n_SpecialChar = 2)
    If $n_Lower_az + $n_Upper_AZ + $n_Numb09 + $n_SpecialChar <> $i_PasswordLen Then
        SetError(0)
        Return (0)
    EndIf
    Local $s_Character = StringSplit($s_SpecialCharacters, $s_Dilemeter)
    Local $i_StringLenSC = StringLen(StringReplace($s_SpecialCharacters, $s_Dilemeter, ''))
    Local $i_Random[3]
    Local $s_Password = ''
    Local $i_Count[5]
    Do
        $i_Random[1] = Random(1, 4, 1)
        If $i_Random[1] == 1 And $i_Count[1] < $n_Lower_az Then
            $i_Count[1] = $i_Count[1] + 1
            $i_Random[2] = Random(1, 26, 1)
            $s_Password = $s_Password & Chr($i_Random[2] + 96)
        ElseIf $i_Random[1] == 2  And $i_Count[2] < $n_Upper_AZ Then
            $i_Count[2] = $i_Count[2] + 1
            $i_Random[2] = Random(1, 26, 1)
            $s_Password = $s_Password & Chr($i_Random[2] + 64)
        ElseIf $i_Random[1] == 3  And $i_Count[3] < $n_Numb09 Then 
            $i_Count[3] = $i_Count[3] + 1
            $i_Random[2] = Random(0, 9, 1)
            $s_Password = $s_Password & $i_Random[2]
        ElseIf $i_Random[1] == 4  And $i_Count[4] < $n_SpecialChar Then
            $i_Count[4] = $i_Count[4] + 1
            $i_Random[2] = Random(1, $i_StringLenSC, 1)
            $s_Password = $s_Password & $s_Character[$i_Random[2]]
        EndIf
    Until StringLen($s_Password) == $i_PasswordLen
    Return $s_Password
EndFunc
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.

Link to comment
Share on other sites

Hello,

Thank you for the ToolTip. Using it I've seen that after the 1st MsgBox the script stays in the loop.

I'll try to explain the script. This script is used to generate a Random Password of 8 chars. This password must have:

- almost 1 lowercase letter

- almost 1 uppercase letter

- almost 1 number

- almost 1 symbol (2 symbols at a maximum)

I have an Array of 8 positions:

Dim $longpassword = 8
Dim $passwords[$longpassword]

The I construct an Array of chars as the source for the chars in the password:

Dim $numminusculas = 26
Dim $nummayusculas = 26
Dim $numdigitos = 10
Dim $numsimbolos = 3
Dim $caracteres[$numminusculas + $nummayusculas + $numdigitos + $numsimbolos]

Dim $limites[5]

$limites[$minusculas] = 0
$limites[$mayusculas] = $limites[$minusculas] + $numminusculas
$limites[$digitos] = $limites[$mayusculas] + $nummayusculas
$limites[$simbolos] = $limites[$digitos] + $numdigitos
$limites[4] = $limites[$simbolos] + $numsimbolos

Dim $j

;~ ********************************************************************************
;~ Rellenar caracteres
;~ ********************************************************************************

For $j = $limites[$minusculas] to ($limites[$mayusculas]-1)
    $caracteres[$j] = chr(97 + $j)
Next

For $j = $limites[$mayusculas] to ($limites[$digitos] - 1 )
    $caracteres[$j] = chr(65 + $j - $limites[$mayusculas])
Next        

For $j = $limites[$digitos] to ($limites[$simbolos] - 1)
    $caracteres[$j] = chr(48 + $j - $limites[$digitos])
Next    

For $j = $limites[$simbolos] to ($limites[4] - 1)
    $caracteres[$j] = chr(35 + $j - $limites[$simbolos])
    if $caracteres[$j] = "%" Then $caracteres[$j] = "?"
Next

The limites variable has the starting positions of every type of chars (lower, upper, numbers and symbols) in the array of chars.

Then, the function for generating the Random Password starts by choosing a lower letter, an upper letter, a number and a symbol and putting these chars in a random position in the final password. In this manner I can assure that the password has my requirements but it doesn't start always with the same pattern. This is the first loop:

For $j = $minusculas to $simbolos
    $pos = Random(0, $longpassword - 1, 1)
    if IsString($passwords[$pos]) = 1 then
        do
            $pos = Random(0, $longpassword - 1, 1)
            until IsString($passwords[$pos]) = 0
    endif
        $passwords[$pos] = $caracteres[Random($limites[$j],$limites[$j+1]-1,1)]
Next

In this loop -and in the second- I search an "empty" position in the final password by looking if there is a char (i.e. IsString). This work great when generating the first password. When generating the second password this do...until doesn't finish (I suppose that is related to the fact that $passwords has the content of the first password generated.

The second loop fills the 4 remaining positions in the final password. The only restriction is that when I have used 2 symbols in the password I can't add more. The script doesn't executes this second loop when generating the second password because it is stalled in the first loop.

So the question is how to re-initialize or erase the variable after each execution of the function? (if the variable has the same content than initialy I suppose the code will work).

Any help would be very appreciated.

Thank you.

there have been a couple of random password generators already created (i think i may have made one in response to a similar post) if you search the forums. you may find a better way to do what you want....
Link to comment
Share on other sites

  • Moderators

yeah i thought i had done one...

found it

Oh ... OF COURSE you wrote one, could have saved me 20 minutes!

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.

Link to comment
Share on other sites

Thank to all for your answers.

Yes, all your solutions work but this didn't answer my question:

In my code I'm in a do...until loop because in the second pass the array isn't empty.

So the question is: if I have an array of chars, how can I empty this array? Or reinitialize it to the same status that it have when defined.

Thank you.

Link to comment
Share on other sites

  • Moderators

Thank to all for your answers.

Yes, all your solutions work but this didn't answer my question:

In my code I'm in a do...until loop because in the second pass the array isn't empty.

So the question is: if I have an array of chars, how can I empty this array? Or reinitialize it to the same status that it have when defined.

Thank you.

$ArrayOfChars = 'SomeKindOfArray'

Now to empty it:

$ArrayOfChars = ''

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.

Link to comment
Share on other sites

Hi again,

It doesn't work! My variable is declared like this:

Dim $passwords[$longpassword]
Dim $caracteres[$numminusculas + $nummayusculas + $numdigitos + $numsimbolos]

I updated it like this:

$passwords[$pos] = $caracteres[Random($limites[$j],$limites[$j+1]-1,1)]

How can I empty $passwords[$pos]?

Link to comment
Share on other sites

Hi again,

It doesn't work! My variable is declared like this:

Dim $passwords[$longpassword]
Dim $caracteres[$numminusculas + $nummayusculas + $numdigitos + $numsimbolos]

I updated it like this:

$passwords[$pos] = $caracteres[Random($limites[$j],$limites[$j+1]-1,1)]

How can I empty $passwords[$pos]?

$passwords[$pos] = ""
Link to comment
Share on other sites

Nop,

If I write this simple code:

Dim $numpasswords = 10
Dim $passwords[$numpasswords]

; Status 1

$passwords[1]=chr(97)
$passwords[2]=chr(96)
$passwords[3]=chr(96)

; Status 2

$passwords[$numpasswords]=""

In the latest line I get this error:

$passwords[$numpasswords]=""

^ERROR

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.

If I want a Status 2 to have the same variable state than in Status 1 how can I empty, initialize the $passwords variable?

Link to comment
Share on other sites

Nop,

If I write this simple code:

Dim $numpasswords = 10
Dim $passwords[$numpasswords]

; Status 1

$passwords[1]=chr(97)
$passwords[2]=chr(96)
$passwords[3]=chr(96)

; Status 2

$passwords[$numpasswords]=""

In the latest line I get this error:

$passwords[$numpasswords]=""

^ERROR

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.

If I want a Status 2 to have the same variable state than in Status 1 how can I empty, initialize the $passwords variable?

you're trying to clear the eleventh element of a 9 element array... Edited by cameronsdad
Link to comment
Share on other sites

  • Moderators

Nop,

If I write this simple code:

Dim $numpasswords = 10
Dim $passwords[$numpasswords]

; Status 1

$passwords[1]=chr(97)
$passwords[2]=chr(96)
$passwords[3]=chr(96)

; Status 2

$passwords[$numpasswords]=""

In the latest line I get this error:

$passwords[$numpasswords]=""

^ERROR

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.

If I want a Status 2 to have the same variable state than in Status 1 how can I empty, initialize the $passwords variable?

Dim $numpasswords = 10
Dim $passwords[$numpasswords]

; Status 1

$passwords[1]=chr(97)
$passwords[2]=chr(96)
$passwords[3]=chr(96)

; Status 2
For $i = 1 To UBound($passwords) - 1
    $passwords[$i] = ''
Next
MsgBox(0, '', $passwords[1] & @CRLF & $passwords[2] & @CRLF & $passwords[3])

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.

Link to comment
Share on other sites

  • Moderators

try this

Dim $numpasswords = 10
Dim $passwords[$numpasswords]

; Status 1

$passwords[1]=chr(97)
$passwords[2]=chr(96)
$passwords[3]=chr(96)

; Status 2

ReDim $passwords[$numpasswords]= ""

8)

??

Edit:

I think you meant something like this?

Dim $numpasswords = 10
Dim $passwords[$numpasswords]

; Status 1

$passwords[1]=chr(97)
$passwords[2]=chr(96)
$passwords[3]=chr(96)

; Status 2
MsgBox(0, '', $passwords[1] & @CRLF & $passwords[2] & @CRLF & $passwords[3])
ReDim $passwords[$numpasswords]
Dim $passwords[$numpasswords]
MsgBox(0, '', $passwords[1] & @CRLF & $passwords[2] & @CRLF & $passwords[3])
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.

Link to comment
Share on other sites

??

Edit:

I think you meant something like this?

Dim $numpasswords = 10
Dim $passwords[$numpasswords]

; Status 1

$passwords[1]=chr(97)
$passwords[2]=chr(96)
$passwords[3]=chr(96)

; Status 2
MsgBox(0, '', $passwords[1] & @CRLF & $passwords[2] & @CRLF & $passwords[3])
ReDim $passwords[$numpasswords]
Dim $passwords[$numpasswords]
MsgBox(0, '', $passwords[1] & @CRLF & $passwords[2] & @CRLF & $passwords[3])

no

to clear them only

Dim $numpasswords = 10
Dim $passwords[$numpasswords]

; Status 1

$passwords[1]=chr(97)
$passwords[2]=chr(96)
$passwords[3]=chr(96)

; Status 2
MsgBox(0, '', $passwords[1] & @CRLF & $passwords[2] & @CRLF & $passwords[3])
ReDim $passwords[$numpasswords] = ""
;Dim $passwords[$numpasswords]
MsgBox(0, '', $passwords[1] & @CRLF & $passwords[2] & @CRLF & $passwords[3])

yes... the second message box gets an error... thats because the re-dim worked like the posted requested

8)

NEWHeader1.png

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...