Sign in to follow this  
Followers 0
Moonwaltz

Line Replace Script

5 posts in this topic

here is my code so far

; SET PATH

FileChangeDir("C:\Program Files\Nortel Networks")

; SET VARIABLES

$myfile = "baynet.tbk"

$file = FileRead($myfile, FileGetSize($myfile))

$file = StringSplit($file, @CRLF, 1)

; NO FILE OPEN

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

; IDENTIFY VALUE AND WRITE LINE

for $i = 0 to $file[0] Step 1

If StringInStr($file[$i], "server=") Then

_FileWritetoLine($myfile, $i, "my entry", 1)

EndIf

Next

I pulled most of this from another similar post. I have two problems actually.

1st: the string to identify starts with server= but could have an ip or name after it that needs to be replaced with my data

2nd: _filewritetoline keeps causing an unknown function error

I am running AutoIt v3

Share this post


Link to post
Share on other sites



_filewritetoline is a udf thats needs to be placed in the include folder

and #include that file at the top of your script

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

You need to use beta for _FileWriteToLine() and the Beta #include <file.au3>


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

You need to use beta for _FileWriteToLine() and the Beta #include <file.au3>

cool... i didn't know it was in the File.au3

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

I installed the beta, added #incude <file.au3>, and copied the file.au3 from the beta folder to the 3.1 include folder and all is good. :think:

Thanks for all the 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