20.09.2019, 12:09
(This post was last modified: 20.09.2019, 12:12 by Trond Hoyem.)
(20.09.2019, 12:02)Daniel. Wrote: You will have quite a lot of logs there
Yep, I used it during debugging and forgot to remove it :-)
It is no longer there in my live script.
Updated version, now as function so that one can add several ranges to delete.
Now without extensive logging
Code:
function deleteGA(start, stop)
startHG = tonumber(string.split(start, '/')[1])
startMG = tonumber(string.split(start, '/')[2])
startUG = tonumber(string.split(start, '/')[3])
startID = (startHG * 2048) + (startMG * 256) + startUG
stopHG = tonumber(string.split(stop, '/')[1])
stopMG = tonumber(string.split(stop, '/')[2])
stopUG = tonumber(string.split(stop, '/')[3])
stopID = (stopHG * 2048) + (stopMG * 256) + stopUG
if stopID < startID then
log('Start has higher value than stop. Delete is not possible')
else
log('Addresses within range are deleted')
adresser = db:getall('SELECT address, name FROM objects WHERE ID BETWEEN "' .. startID .. '" AND "' .. stopID .. '"')
for _, addr in ipairs(adresser) do
--log(addr.name)
grp.delete(addr.name)
end
end
end
start = '26/0/0'
stop = '26/0/10'
deleteGA(start, stop)
start = '26/0/51'
stop = '26/0/70'
deleteGA(start, stop)
There are 10 kinds of people in the world; those who can read binary and those who don't