PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: NU-Pulse on 08 February, 2005, 21:54:21

Title: Help with files IO and other stuff
Post by: NU-Pulse on 08 February, 2005, 21:54:21
Hi everybody!.

I'm having some trouble with files...the problem is... i don't know how to edit a file once it's written. ?(


for example, i have a file that contains this:

Entry{
User = "CPRS"
SlotCount = 3
HubsCount = 1
GiB = 37.61028316058218
}
Entry{
User = "TEST"
SlotCount = 3
HubsCount = 1
GiB = 37.61028316058218
}
Entry{
User = "Problem"
SlotCount = 3
HubsCount = 1
GiB = 37.61028316058218
}

What I want to do, is to search for a user "TEST", if exist to delete that entry.

I've read the manual but still can't figure out how to do it.
So I need an example...:D

Thanks guys! :))  
Title:
Post by: plop on 09 February, 2005, 01:47:03
if that is the file you wanne write you better think it over.
here's a real lua table.
tUserInfo = {
   ["CPRS"] = {
iSlotCount = 3,
iHubsCount = 1,
iGiB = 37.61028316058218,
   },
   ["TEST"] = {
iSlotCount = 3,
iHubsCount = 1,
iGiB = 37.61028316058218,
   },
   ["Problem"] = {
iSlotCount = 3,
iHubsCount = 1,
iGiB = 37.61028316058218,
   }
}
which you can proces really easy.
if tUserInfo["TEST"] then -- check if it excists
   tUserInfo["TEST"] = nil -- and delete
end
and opening the file.
dofile(filename)
plop
Title:
Post by: NU-Pulse on 09 February, 2005, 16:55:13
Thanks! I will try that and see.. :D  :D