HeyHo,
habe ein kleines Problem mit meinem Script, das Script soll einen Kontoauszug in eine Datei als JSON schreiben.
Das Problem ist, fileWrite gibt mir "0" zurück (Z. 24) und schreibt nichts in die Datei.
Aus Zeile 23 erhalte ich aber bspw. folgenden String als Output:
fileWrite in Zeile 6 funktioniert aber komischerweise.
Ich hänge da seit einer halben Stunde dran, kann aber keinen Fehler finden.
Fehler oder Warnings kommen auch nicht.
Code:
Lua
function outputKontoauszug_func(zweck, summe)
if zweck and summe then
local fPath = "userfiles/bank.json"
if (not fileExists(fPath)) then
local jsonFile = fileCreate(fPath)
fileWrite(jsonFile, "{}")
fileClose(jsonFile)
end
local jsonFile = fileOpen(fPath)
local jsonData = fileRead(jsonFile, fileGetSize(jsonFile))
local json = fromJSON(jsonData)
local time = getRealTime()
local year = time.year + 1900
local month = time.month + 1
local day = time.monthday
local ymd = day.."."..month.."."..year
json[(#json + 1)] = {
["date"] = ymd,
["subject"] = zweck,
["amount"] = summe
}
jsonData = toJSON(json, true)
outputChatBox(jsonData)
outputChatBox(fileWrite(jsonFile, jsonData))
fileClose(jsonFile)
kontoAuszugData = json
end
end
Alles anzeigen
Hoffe es kann mir da jemand weiterhelfen
LG
Lars