spinter Posted September 26, 2009 Posted September 26, 2009 Work program tssimcomms I have a problem with the programming. Lua! I have to extract the frequency of BS, but I have a programming problem. How can I extract the correct frequency? This is the code I use: local R_800 = GetDevice(devices.R_800) local radio = R_800:l_get_state() local radionoff = R_800:l_get_state() if R_800 then radio = canaleradio(radio["frequency"]) if (radionoff["isOn"] == true) then socket.try(c:send(string.format("ON = %.2f", radio))) else socket.try(c:send(string.format("OFF"))) end end The problem is that changing the frequency value is not correct ! Exemple 127,400 back to me 127 399 why? How can I avoid the error? sorry my eng traslated by google ====VIAF==== Spinter 155° "Pantere Nere" TsSimComms My Site aiupgrade.net
dragony Posted September 26, 2009 Posted September 26, 2009 Hmm, looks like rounding problem... Considering that frequency changing with 0,025 MHz step you can place instead of something like "if value = 127.400 then ..." with "if value < 127.420 and value > 127.380 then ..." in your program. WBR, =FV=BlackDragon. [sIGPIC][/sIGPIC]
spinter Posted September 26, 2009 Author Posted September 26, 2009 .lua can not get with my head, my program is written in vb.net ====VIAF==== Spinter 155° "Pantere Nere" TsSimComms My Site aiupgrade.net
spinter Posted September 27, 2009 Author Posted September 27, 2009 Solved! ====VIAF==== Spinter 155° "Pantere Nere" TsSimComms My Site aiupgrade.net
Recommended Posts