Jump to content

$CmdLine[n]


Recommended Posts

Can someone explain what $CmdLine does, like used in a script? thanks.

My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote]
Link to comment
Share on other sites

if you go to dos and call your script :

AutoIt3.exe myscript.au3 "THIS IS FUN"

of course your script called myscript.au3 should be the following:

;myscript.au3

If $CmdLine[0] = 0 Then

MsgBox(0, "Error", "Unable to find stuff on command line")

Exit

EndIf

MsgBox(0, "from command prompt", $CmdLine[1])

;end of myscript.au3

; I am only taking the first parameter on this command line

you probably wont use it unless you call your scripts from batch files or DOS :idiot:

Link to comment
Share on other sites

Next question, I tried doing ControlGetPos and it returned a value that wasn't an array. It just returned 1. It's possible that the X coordinate was 1, but it wasn't the @error. It was the return value.

My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote]
Link to comment
Share on other sites

Here's an example.

NOTE: You need Au3check in the same folder if you want to run this script.

$Times = 1
If NOT $CmdLine[0] Then
   $Filename = FileOpenDialog("Choose an Au3 script", @ScriptDir, "Au3 Scripts (*.au3)", 1)
   If @error Then Exit
   
   CheckFile()
ElseIf $CmdLine[0] = 1 Then
   $Filename = $CmdLine[1]
   CheckFile()
Else
   For $i = 1 To $CmdLine[0]
      $Filename = $CmdLine[$i]
      CheckFile()
   Next
EndIf

Func CheckFile()
   If StringInStr($Filename, " ") Then $Filename = '"' & $Filename & '"'
   RunWait(@ComSpec & ' /c ' & @ScriptDir & '\Au3Check.exe -q ' & $Filename & ' > %TEMP%\Output.tmp', @SystemDir, @SW_HIDE)
   If NOT FileExists(@TempDir & "\Output.bat") Then WriteBat()
   RunWait(@TempDir & "\Output.bat " & $Filename, @SystemDir)
EndFunc

Func WriteBat()
   Local $BatFile
   Local $OpenedFile
   $BatFile = @TempDir & "\Output.bat"
   $OpenedFile = FileOpen($BatFile, 2)
      FileWriteLine($OpenedFile, '@ECHO OFF')
      FileWriteLine($OpenedFile, 'TITLE Au3Check Wrapper')
      FileWriteLine($OpenedFile, 'FIND /C %TEMP%\Output.tmp "error" > NUL')
      FileWriteLine($OpenedFile, 'ECHO Filename: %1')
      FileWriteLine($OpenedFile, 'ECHO --------------------------')
      FileWriteLine($OpenedFile, 'ECHO.')
      FileWriteLine($OpenedFile, 'IF %ERRORLEVEL%==0 (TYPE %TEMP%\output.tmp) ELSE (ECHO No errors found!)')
      FileWriteLine($OpenedFile, 'PAUSE > NUL')
      FileWriteLine($OpenedFile, 'EXIT')
   FileClose($OpenedFile)
EndFunc
Edited by SlimShady
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...