Sign in to follow this  
Followers 0
Simmy

<application.exe> /?

5 posts in this topic

Hi guys,

Id like to learn how for example, in the following code:

If $CmdLine[0] = 0 Then
    MsgBox(64, "Result", "No parameter was entered!")
    Exit
EndIf
MsgBox(64, "Entry", $CmdLine[1])

You can add help information for the user, displayed at the command line.

For example, if at a command line, the user enters:

c:\test.exe

A msgbox will appear saying that "no parameter was entered".

What I would like is, if no parameter was entered, or the user types:

c:\test.exe /?

Then information will appear in the command window stating application usage, eg:

Usage: test.exe param1

Any help greatly appreciated.

Share this post


Link to post
Share on other sites



Hi,compile and try

If $CmdLine[0] = 0 Then
    MsgBox(64, "Result", "No parameter was entered!")
    Exit
Else
    Switch $CmdLine[1]
        Case "/?"
            MsgBox(64, "Help", "Usage: " & @AutoItExe & " /param1")
        Case "/param1"
            MsgBox(64, "param1", "1st parameter received: "  & $CmdLine[1])
            If $CmdLine[0] > 1 Then ContinueCase
        Case Else
            MsgBox(64, "Commandline Raw", "$CmdLineRaw: "  & $CmdLineRaw)
    EndSwitch
EndIf

Cheers

Share this post


Link to post
Share on other sites

Hi Smashly, thanks so much for your kind help.

That works Smashly, but what I really wanted was to write the output not to a msgbox, but to a command line prompt.

I tried the following:

If $CmdLine[0] = 0 Then
    MsgBox(64, "Result", "No parameter was entered!")
    Exit
Else
    Switch $CmdLine[1]
        Case "/?"
            ;MsgBox(64, "Help", "Usage: " & @AutoItExe & " /param1")
            ConsoleWrite ("sdf")
        Case "/param1"
            MsgBox(64, "param1", "1st parameter received: "  & $CmdLine[1])
            If $CmdLine[0] > 1 Then ContinueCase
        Case Else
           ; MsgBox(64, "Commandline Raw", "$CmdLineRaw: "  & $CmdLineRaw)
            consolewrite ("nos")
    EndSwitch
EndIf

And this worked in Scite, but not at a prompt.

Share this post


Link to post
Share on other sites

Hi guys,

I just did some research on ConsoleWrite, where it said that:

"This does not write to a DOS console unless the script is compiled as a console application."

http://www.autoitscript.com/autoit3/docs/functions/ConsoleWrite.htm

So, I compiled it with CUI instead of GUI.exe and it worked.

I just thought I would put it here for others to see.

Thanks for your help.

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  
Followers 0