Page 1 of 1

dzVents Error Expression Expected >> Operator

Posted: Tuesday 22 March 2022 10:41
by rwblinn
Domoticz 2022.1; Raspberry Pi 3B+, Raspberry Pi OS,

Got an error message "Expression expected near >" when declaring the >> operator:

Code: Select all

t[i+1] = (value >> (i * 16)) & 0xFFFF
in the code below. Also tried to use the << operator.

What is the correct way to use the << and >> operators in dzVents.

Code: Select all

...
execute = function(domoticz, device)
	domoticz.log(("%s: %s"):format(device.name, device.sValue))
	local value = tonumber(device.sValue)
        local t = {}
        for i = 0, 3 do
	    'ERROR
            t[i+1] = (value >> (i * 16)) & 0xFFFF
        end
        domoticz.log(t)
end
...

Re: dzVents Error Expression Expected >> Operator  [Solved]

Posted: Tuesday 22 March 2022 11:22
by boum
Shift operators do not exist in Lua. You'll have to convert to math:

Code: Select all

t[i+1] = (value // (2 ^ (i * 16))) % (2 ^ 16)

Re: dzVents Error Expression Expected >> Operator

Posted: Tuesday 22 March 2022 12:05
by rwblinn
Thats it. Thanks for help.