Jump to content

possible in autoit?


Recommended Posts

I have a file that contains two fields with an ip address. I need my autoit script to take an ip address as an argument, and replace the two ip addresses in the file with the one given in the argument.

Is this possible in AutoIt?

Any help is appreciated

Link to comment
Share on other sites

You can use command line arguments with a set variable and you can edit files with the File commands. It's all in the help file.

[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Link to comment
Share on other sites

You can use command line arguments with a set variable and you can edit files with the File commands. It's all in the help file.

http://www.autoitscript.com/autoit3/docs/f...leWriteLine.htm

I tried using readline along with some regexps to do this. As it is, I have the lines of text the way I want them, but FileWriteLine() doesn't seem to work the same as readline does. It seems to just be the same as FileWrite().

e.g. this is what i have:

$linetoedit = FileReadLine("c:\blah", 3)

$editedline=StringRegExpReplace($linetoedit, "([my regexp])", $replacetext))

FileWriteLine("c:\blah", $editedline, 3)

However, FileWriteLine doesn't work like that, it only appends to the end of the file ... you can only do this:

FileWriteLine("c:\blah", $editedline)

-- unless I'm missing something. Unfortunately my file is really really big, so reading thru every line to recreate the file is something I'd like to avoid.

Edited by skrewler
Link to comment
Share on other sites

Well, I'm just rewriting the whole file and taking the performance hit as I don't see any other option right now..

Wondering how the builtin ini functions do this?

FileWrite ( filehandle or "filename", "line" )

Try putting "" around the lines.

Link to comment
Share on other sites

Well, I'm just rewriting the whole file and taking the performance hit as I don't see any other option right now..

Wondering how the builtin ini functions do this?

I don't know.

No matter how big the file is, try this on a temporary copy of the file:

; if $linetoedit is unique

$replacetext = "replacetext"
$linetoedit = FileReadLine("c:\blah", 3)
FileWrite("c:\blah2", StringReplace(FileRead("c:\blah"), $linetoedit, $replacetext))
FileMove("c:\blah2", "c:\blah", 1)
If $linetoedit will match more than one line, then post the code (or a summary of the code) that you are using for your work around... maybe someone knows of some speed tweaks for that code.

Edit: What is the size of the file?

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

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