Jump to content

Command Line Limits


Recommended Posts

I need to write a program that writes to a file with the information given by command line. I wrote one just fine and dandy, however it fails to work correctly when I pass large amounts of data to it.

Here's the code:

If $CmdLine[0] < 3 Then Exit(1)

If $CmdLine[0] = 4 Then
    $strin = StringReplace($CmdLine[2],$CmdLine[4]," ")
Else
    $strin = $CmdLine[2]
EndIf
$strout = StringSplit($strin,$CmdLine[3]);returns

For $i = 1 To $strout[0] Step 1
    FileWrite($CmdLine[1],$strout[$i] & @CRLF)
Next
Exit

It will exit if there are less than 3 params in the command line.

The params are as follow: [filepath] [text to write] [new line delimiter] {space delimiter}

So I can pass: "C:\test.txt" "this_is_a_test~line2" "~" "_"

And it will write:

this is a test

line2

However, if I pass a large amount of information to be written (for instance, html code) it screws up and doesn't write anything correctly. I don't know if there are any limits on how large a string can be that is passed by command line.

I could, I guess...run the program several times with small amounts of data, however I could just use DOS instead if this was the case. The reason why I don't want to use DOS originally is because it pops up that shell console which isn't cool.

Link to comment
Share on other sites

@qafrost

The file isn't for the script to read. The script is exporting the file. I'm using another scripting engine that is totally seperate from AutoIt. I want to export it's variables to an HTML file that I have defined in the script with the file exporting program that I have written in AutoIt. The other scripting engine cannot write to files, however it can execute files and pass on command line parameters.

@Valuater

Thats because it requires 3 parameters, the 4th is optional. Hence the [] and {}. If the 4th param is present (as I said, the 4th param is the space delimiter) then parse out spaces. Then continue on.

Edited by ending
Link to comment
Share on other sites

I don't know if there are any limits on how large a string can be that is passed by command line.

63 parameters

4096 characters per parameter

You maybe able to use more parameters in AutoIt 3.1.1.0, but the AutoIt Beta enforces the specs above.

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