Jump to content
Sign in to follow this  
Skrip

Array Help

Recommended Posts

Skrip

Code...

Dim $done
Dim $user_num
Global $hours[24];; One for each hour of the day..
$test_user = 0
$i = 0

Func Login()
    $user = GUICtrlRead($Input1)
    $pass = GUICtrlRead($Input2)
    If $user = _StringEncrypt(0, RegRead("HKLM\Software\security\lockout", "AU"), "encryptpazz", 3) And $pass = _StringEncrypt(0, RegRead("HKLM\Software\security\lockout", "AP"), "encryptpazz", 3) Then;; IF THE ADMIN LOGS IN;; READ THE REGISTERY FOR USER/PASS
        GUICtrlSetData($Input1, "")
        GUICtrlSetData($Input2, "")
        _panel()
    EndIf
    $done = 0
    $i = 0
    $num_users = RegRead("HKLM\Software\security\lockout", "Num")
    Do
        $i = $i + 1
        $test_user = _StringEncrypt(0, RegRead("HKLM\Software\security\lockout", "U" & $i), "encryptpazz", 3)
        If $user = $test_user Then
            $done = 1
            _Timer($i); IF NOT ADMIN - START THE TIMER
;~      ;Exit
;~      GUIDelete($Form1)
;~      GUIDelete($Form2);THIS IS HERE JUST FOR DEBUGGING;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;~      MsgBox(0, "", $test_user & @CRLF & $i)
;~      Exit
        EndIf
        If $i = $num_users Then
            $done = 1
        EndIf
    Until $done = 1
EndFunc  ;==>Login


Func _Timer($user_num)
    $TS = RegRead("HKLM\Software\security\lockout", "TS" & $user_num)
    $TE = RegRead("HKLM\Software\security\lockout", "TE" & $user_num)
;Lets see what hours are between TS and TE..
;example:
;TS = 5; TE = 8
;Time between = 6 and 7
;Allowed times then equals...5,6,7,8 = 4hours
    $u = 0
    $hours[0] = $TS
    Do
        $u = $u + 1
        $Time = $TS + 1
        If $Time <= $TE Then
            $hours[$u] = $Time;;;;;;;;;;;;   LINE 133
        EndIf
    Until $Time = $TE
    GUIDelete($Form1)
    GUIDelete($Form2)
    _ArrayDisplay($hours)
EndFunc

If you need the whole thing..let me know...I commented some of it...

--

Error:

C:\Program Files\AutoIt3\CHRISTIAN_PASSWORD.au3 (133) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$hours[$u] = $Time
^ ERROR

I am bad with arrays...help?


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites
enaiman

It looks like your array is a lil bit too small - you get that error when $u is equal or greater than 24

$hours[24]

You have to increase the dimension of your array

$hours[25]
and test it.

Arrays are 0 based so if you declare an array like $hours[24] it will have elements $hours[0], $hours[1], $hours[2] ... $hours[23] ... you can see here that when your variable ($u) reaches the value 24 it will be out ...


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
Skrip

I forgot about that 0...I changed it..

C:\Program Files\AutoIt3\CHRISTIAN_PASSWORD.au3 (133) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$hours[$u] = $Time
^ ERROR

Error still.

I am using a login where TS = 0 and TE = 24

EDIT: I tried with TS = 5 and TE = 8 same error. So it is not the vars.

Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites
enaiman

Your error is here:

$Time = $TS + 1

Since your $TS is constant the $Time value is also constant muttley

Correct:

$Time = $TS
    $u = 0
    Do
        $u = $u + 1
        $Time += 1
        If $Time <= $TE Then
            $hours[$u] = $Time;;;;;;;;;;;;   LINE 133
        EndIf
    Until $Time = $TE
    _ArrayDisplay($hours)

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
Skrip

Perfect. Thanks alot.


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

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  

×