Jump to content

$CmdLine[0] Questions


Recommended Posts

CODE
HotKeySet("^!x", "end001")

HotKeySet("{Esc}", "end001")

If $CmdLine[0] = 0 Then Exit

$vdelay001 = $cmdline[1]

;sleep99()

;Func sleep99()

; $vdelay001 = 99

;EndFunc

delay001()

Func delay001()

$dt01 = 0

Do

$dt01 = $dt01 + 1

Sleep (1000)

Until $dt01 = $vdelay001

EndFunc

end001()

Func end001()

Exit

EndFunc

In a batch file I can check to see if a command line option is being added simply by check to see what %1 is. In many of my programs if there is not a option I would add one by defult. (this is usually done when its a timer variable) I can not seem to figure out how to read it properly with out turning it into anouhter varible first. Is there a way to do this? Is there a way to see if If $CmdLine[1] is not there or a null value?

Also is the included code I am trying to insted of exiting get the code to got to the sleep99 function. Or better insted of checking If $CmdLine[0] = 0 can I check If $CmdLine[1] insted. I know the code is REMed out but If I dont then I get some really funny errors or the progam goes to la la land and just sits there.

Any help would be great.

Curtiss W.

Link to comment
Share on other sites

CODE

HotKeySet("^!x", "end001")

HotKeySet("{Esc}", "end001")

;If $CmdLine[0] = 0 Then Exit

$vdelay001 = $cmdline[1]

If $CmdLine[0]=1 Then

MsgBox (0, 'Test', 'Cmdline was ' & $CmdLine[1])

; Do what you specified , e.g. sleep 99 sec

Else

MsgBox (0, 'Test', 'Cmdline was not used.')

; Do your default stuff, e.g. sleep 1 sec

EndIf

;sleep99()

;Func sleep99()

; $vdelay001 = 99

;EndFunc

delay001()

Func delay001()

$dt01 = 0

Do

$dt01 = $dt01 + 1

Sleep (1000)

Until $dt01 = $vdelay001

EndFunc

end001()

Func end001()

Exit

EndFunc

I assume thats were you code should go but when I try to test it I get the same error that I have been running into.

elay4.au3 (15) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$vdelay001 = $cmdline[1]

$vdelay001 = ^ ERROR

+>AutoIT3.exe ended.rc:0

Link to comment
Share on other sites

Hi,

HotKeySet("^!x", "end001")
HotKeySet("{Esc}", "end001")

If $cmdline[0] = 1 Then
    $vdelay001 = $cmdline[1]
    MsgBox(0, 'Test', 'Cmdline was ' & $cmdline[1])
; Do what you specified , e.g. sleep 99 sec
Else
    MsgBox(0, 'Test', 'Cmdline was not used.')
; Do your default stuff, e.g. sleep 1 sec
EndIf



;sleep99()
;Func sleep99()
; $vdelay001 = 99
;EndFunc

delay001()
Func delay001()
    $dt01 = 0
    Do
        $dt01 = $dt01 + 1
        Sleep(1000)
    Until $dt01 = $vdelay001
EndFunc  ;==>delay001

Func end001()
EndFunc  ;==>end001

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Well that works sorta the problem is when you do it that way if a send option is added it always go to the second setting. IN a batch file it was pretty simple.

at the start of the program I would look at the %1

CODE
if "%1"=="repoll" goto repoll

if "%1"=="menu" goto menu

if "%1"=="payroll" goto payroll

I can get away from not using the goto command but not I need to find an easy way to check what command line options were passed to the program. Using If $cmdline[0] its ounting how many options were there but I really need to know what they are.

Link to comment
Share on other sites

Hi,

why not:

If $CmdLine[0] > 0 Then
    Switch $CmdLine[1]
        Case "Hello"
            out("hello")
        Case "Test"
            out("Test")
        Case "para"
            out("para")
        Case "hmmh"
            out("hmmh")
        Case Else
            out("unknown Parameter!")
    EndSwitch
Else
    MsgBox(0, "Info", "No parameter --> exit", 4)
    Exit (0)
EndIf

Func out($txt)
    MsgBox(0, "Info", $txt)
EndFunc   ;==>out

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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...