Sign in to follow this  
Followers 0
Shyke

Ini find and delete?

2 posts in this topic

Alright, here is another problem I have found that needs to be done and I have no idea about...

In AutoIt how would I go through a giant ini file (4mb) and remove every line that says money=-1 ?

Here is how some of the things look like:

[creature 38]damage=2.628571 3.028571

flags1=080000

name=Defias Thug

type=7

family=7

level=4

npcflags=00

maxmana=0

faction=17

model=5035

bounding_radius=0.208

combat_reach=1.5

attack=2000 2000

loottemplate=38

speed=0.92

equipmodel=0 7487 2 7 1 13 3 0 0 0

loot=752 34.8714

money=-1

I need to get that money thing out on a large scale.

Can anyone help me?

Share this post


Link to post
Share on other sites



Personally I would suggest just opening the file in the standard way and copying any line not matching 'money=-1' to a new file. You could then just replace the old file with the new one and the job's done.

Something like this maybe (warning: no error checking implemented) --

local $path = "c:\file.ini"

local $tempPath = @tempDir & "\tempFile.ini"

local $file = fileOpen($path, 0)

local $temp = fileOpen($tempPath, 2)

while 1

local $data = fileReadLine($file)

if @error then exitLoop

if stringLower($data) <> "money=-1" then fileWriteLine($tempPath, $data)

wEnd

fileClose($file)

fileClose($temp)

fileDelete($path)

fileMove($tempPath, $path)

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