
Сообщение от
0xDEAD
Как сделать, чтобы в файл писался не только номер билда, но и содержимое TIME?
А если содержимое BUILD и TIME будет при компиляции писаться еще и в код, через DB, например - будет вообще идеально.
Да вроде обе хотелки в лоб реализуются
Код:
LUA
-- Function reads number from file <fname>, increases it, creates define "BUILD" with the number and saves the number to <fname>.
-- With this function you can control count of compilations.
function increase_build(fname)
local fp
local build
local time
fp = assert(io.open(fname, "rb"))
build = tonumber(fp:read("*number"))
assert(fp:close())
if type(build) == "nil" then
build = 0
end
build = build + 1;
sj.insert_define("BUILD", '"' .. build .. '"')
fp = assert(io.open(fname, "wb"))
assert(fp:write( build, " ", os.date("%d-%m-%Y %H:%M:%S") ))
assert(fp:flush())
assert(fp:close())
end
-- Before using you must create empty file "build.txt"!
increase_build("build.txt")
-- Creates define "TIME" with current time
sj.insert_define("TIME", '"' .. os.date("%d-%m-%Y %H:%M:%S") .. '"')
ENDLUA
DEVICE ZXSPECTRUM48
ORG #5B00
DB TIME
DB BUILD
SAVEBIN "output.bin", #5B00, $-#5B00