Jump to content

Line Replace Script


Recommended Posts

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

Link to comment
Share on other sites

  • Moderators

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

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.

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