Hi, can anyone tell me why the file that is being read and closed will not let itself be deleted?
Manual delete will create an error 'The file is being used....".
A similar script in another function works perfectly.
Only difference with that other function is that this file should only be deleted if vUser is online and has been sent the message (WatchMess)
function CheckWatch(curUser)
local WatchFile = "Watch/"..curUser.sName..".txt"
local MessSent = 0
if readfrom(WatchFile) ~= nil then
readfrom(WatchFile)
local line = read()
local _,_,tmpOP,tmpDate,tmpReason = strfind(line, "(.*)|(.*)|(.*)|")
local vUser = GetItemByName(tmpOP)
if vUser then
local WatchMess = "\r\n\t*** On "..tmpDate.." you have asked to watch the arrival of "..curUser.sName
WatchMess = WatchMess.."\r\n\t*** Reason: "..tmpReason
WatchMess = WatchMess.."\r\n\t*** The user has just entered the hub. :) "
SendPmToNick(vUser.sName, BotName, WatchMess)
MessSent = 1
end
end
readfrom()
if MessSent == 1 then
remove(WatchFile)
end
return 1
end
Any help is appreciated! Thnx.