afunction QMPlugin.DeleteLine(FileName, LineNum)
local Lines = {}
pcall(
function()
local curLineNum = 0
io.input(FileName)
while true do
local ReadContent = io.read()
--为了和按键精灵的语法保持一致,注意 lua 中的 nil 需要写为 null
if ReadContent == null then
break
end
curLineNum = curLineNum + 1
if curLineNum ~= LineNum then
ReadContent=string.gsub(tostring(ReadContent),"\r","")
table.insert(Lines,ReadContent)
end
end
--此处不能调用io.close(),由于后面要继续操作该文件,如果关闭的话后面会报错,提示:操作已关闭的文件
--io.close()
-- write all the lines
io.output(FileName)
for i, v in ipairs(Lines) do
io.write(string.gsub(v,"\r",""), '\r\n')
end
io.close()
end
)
end