That’s way simpler. You may notice me giving out similar advice every time I see something like this. As you’ve figured you can bypass the if..else for these things because it’s just not necessary. It’s particularly wasteful to do
Code: Select all
function callback(var)
If var == 1 then
xpl_dataref_write(dataref, type, 1)
elseif == 0 then
xpl_dataref_write(dataref, type, 0)
end
end
Code: Select all
function callback(var)
xpl_dataref_write(dataref, type, var)
end
Glad to see some thought has gone into what existing code is doing and spotting a better solution. I’m sure we can all learn new little ways to improve our code from time to time so it’s good to highlight these to the wider community. As I said previously I’ve been trying to guide folks down this route already so I hope others see this and take note of the simplicity as it’s a common block of code that’s used in the vast majority of instruments.