Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Get client's info from DB
- function getDB(card_num) do
- n = 0
- file = io.open("client_base.txt")
- for line in file:lines() do
- arr = {}
- temp = {}
- temp = string.gmatch(line, "[^ ]+")
- c = 0
- arr = {num = "", name = "", bal = 0.0, pass = "", index = 0}
- for i in temp do
- if c == 0 then arr.num=i
- elseif c == 1 then arr.name=i
- elseif c == 2 then arr.bal=i
- elseif c == 3 then arr.pass=i
- end
- c = c + 1
- end
- if tostring(arr.num) == tostring(card_num) then
- io.close(file)
- arr.index = n
- return arr
- end
- n = n + 1
- end
- end
- end
- --Edit file's line
- function editLine(path, num, ncont)
- local file = io.open(path, 'r')
- local fileContent = {}
- for line in file:lines() do
- table.insert (fileContent, line)
- end
- io.close(file)
- fileContent[tonumber(num) + 1] = tostring(ncont)
- file = io.open(path, 'w')
- for index, value in ipairs(fileContent) do
- --print(value)
- file:write(value .. '\n')
- end
- io.close(file)
- end
Add Comment
Please, Sign In to add comment