1
votes

Why does this work to determine the type

if delay is integer
{
    MsgBox You set delay = %delay% seconds
    return
}
else
{
    MsgBox "%delay%" is not a valid number.
    goSub, input    
}

But not this - this also allowes non integer values, as long as it's greater than 0

if (delay is integer and delay > 0)
{
    MsgBox You set delay = %delay% seconds
    return
}
else
{
    MsgBox "%delay%" is not a valid number.
    goSub, input    
}

Both snippets are for checking the result of an input box. The script is meant to help extracting a movie or sth. while u still download and already watching it after having finished the first part or so..

Here's the full script in case someones interested.

delay := 120
help = Help - Unzip Auto Extractor`nF1: Help`nF2: Get Unzip Window`n(must be in foreground)`nF3: Set unpack delay (seconds, default 120)`nF4: Start or stop unpacking`nF5: Exit
MsgBox %help%
F1::
MsgBox %help%
return

F2::
WinGetTitle, title, A
MsgBox Selected window "%title%"
return

F3::
input:
InputBox, delay, Set extraction timeout in seconds..,Use numbers only,,,,,,,,%delay%
;InputBox, OutputVar [, Title, Prompt, HIDE, Width, Height, X, Y, Font, Timeout, Default] 
if delay is integer
{
    MsgBox You set delay = %delay% seconds
    return
}
else
{
    MsgBox "%delay%" is not a valid number.
    goSub, input    
}

#MaxThreadsPerHotkey 3
F4::
#MaxThreadsPerHotkey 1
if KeepWinZRunning
{
    KeepWinZRunning := 0
    return
}
else
{
KeepWinZRunning := 1
}
Loop
{   
    Loop %delay%
    {
        sleep 1000
        if not KeepWinZRunning
        {
            break   
        }
    }
    if not KeepWinZRunning
    {
        break           
    }   
    ControlSend,,{Enter},%title%    
}
KeepWinZRunning := 0
return

F5::
ExitApp
return
1

1 Answers

0
votes

I think this quote from autohotkey If var is [not] type documentation will answer your question:

Note: The operators "between", "is", "in", and "contains" are not supported in expressions.

Note the second example work fine for me regardless of this rule.