Jump to content
Sign in to follow this  
Skrip

Array Problem - Different one..

Recommended Posts

Skrip

Code:

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
    $Time = $TS
    $u = 1
    $hours[1] = $TS
    $lock = 1
    Do
        $u = $u + 1
        $Time += 1
        If $Time <= $TE Then
            $hours[$u] = $Time
        EndIf
    Until $Time = $TE
    $hours[$u] = $TE
    $u = 1
    $done = 0
    Do
        $u = $u + 1
        If $done = 0 Then
            If @HOUR = $hours[$u] Then
                GUIDelete($Form1)
                GUIDelete($Form2)
                MsgBox(0, "", "You logged in as " & $test_user & @CRLF & "You may be on from " & $TS & " and " & $TE & "..." & @CRLF & "PLEASE LOGOUT WITH THE ICON IN THR CORNER - WHEN YOU ARE DONE.", 5)
                $done = 1
            EndIf
        EndIf
        If $done >= 1 Then
            $limit = 0
            $hour = @HOUR
            If Not $hour = $hours[$u] Then;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ERROR HERE
                $done += 1
            EndIf
        EndIf
    Until $done = $u
    _GO()
EndFunc  ;==>_Timer

Array problem..

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

I hate arrays..anybody know the problem?


[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
JFee

Can you show me where you dimensioned $hours?

P.S. I love your signature


Regards,Josh

Share this post


Link to post
Share on other sites
weaponx

I see many problems.

-You aren't starting your array index at zero ($hours[1] = $TS)

-You use Do...Until even though you already have start and end hour ($TS and $TE), making For...Next a much cleaner solution

The whole function doesn't make sense. If you are trying to limit access to a certain time period then what is the purpose of the array?

Just check: If @HOUR <= $TE AND @HOUR >= $TS Then....

That eliminates most of this function.

Share this post


Link to post
Share on other sites
Skrip

I see many problems.

-You aren't starting your array index at zero ($hours[1] = $TS)

-You use Do...Until even though you already have start and end hour ($TS and $TE), making For...Next a much cleaner solution

The whole function doesn't make sense. If you are trying to limit access to a certain time period then what is the purpose of the array?

Just check: If @HOUR <= $TE AND @HOUR >= $TS Then....

That eliminates most of this function.

Holy f***ing shit. How did I not think of that?

[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
weaponx

double post..

You can delete your own posts.

Share this post


Link to post
Share on other sites
Skrip

You can delete your own posts.

Sorry. I am pretty out of it. Deleted..

If @HOUR <= $TE & $user_num AND @HOUR >= $TS & $user_num Then
            GUIDelete($Form1)
            GUIDelete($Form2)
            MsgBox(0, "", "You logged in as " & $test_user & @CRLF & "You may be on from " & $TS & " and " & $TE & "..." & @CRLF & "PLEASE LOGOUT WITH THE ICON IN THR CORNER - WHEN YOU ARE DONE.", 5)
            $done = 1
        Else
            _GO("You have been locked out. Your time is up. Start Time: " & $TS & " To: " & $TE & " C Hour: " & @HOUR)
        EndIf

The _GO always returns...$TS = 9 | @HOUR = 10 | $TE = 11 and it should not be false right now...what is the deal?


[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
weaponx

Sorry. I am pretty out of it. Deleted..

If @HOUR <= $TE & $user_num AND @HOUR >= $TS & $user_num Then
             GUIDelete($Form1)
             GUIDelete($Form2)
             MsgBox(0, "", "You logged in as " & $test_user & @CRLF & "You may be on from " & $TS & " and " & $TE & "..." & @CRLF & "PLEASE LOGOUT WITH THE ICON IN THR CORNER - WHEN YOU ARE DONE.", 5)
             $done = 1
         Else
             _GO("You have been locked out. Your time is up. Start Time: " & $TS & " To: " & $TE & " C Hour: " & @HOUR)
         EndIf

The _GO always returns...$TS = 9 | @HOUR = 10 | $TE = 11 and it should not be false right now...what is the deal?

RegRead is probably returning a string value, use Number() to force $TS and $TE to be numbers.

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  

×

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.