# Array Problem - Different one..

## Recommended Posts

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 on other sites

Can you show me where you dimensioned \$hours?

Regards,Josh

##### Share on other sites

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 on other sites

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 on other sites

double post..

You can delete your own posts.

##### Share on other sites

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 on other sites

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 on other sites

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]

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...