Sign in to follow this  
Followers 0
ending

Command Line Limits

6 posts in this topic

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.

Share this post


Link to post
Share on other sites



just have the information written to a file

then your script could read in the file.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

this doesn't make sense

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

If $CmdLine[0] = 4 Then....

if it is less than 3 ( 2 or 1 only )... then ask if it = 4

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

@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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Ok, that solves my problem. I'll have to use DOS then. Thanks MHz.

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