What does this LUA line mean? ""%i (%.3f GHz)" %{ f.channel, f.mhz / 1000 })" -
i have question concerning snippet of code
ch = s:taboption("general", value, "channel", translate("channel")) ch:value("auto", translate("auto")) _, f in ipairs(iw , iw.freqlist or { }) if not f.restricted ch:value(f.channel, "%i (%.3f ghz)" %{ f.channel, f.mhz / 1000 }) //this line? end end
what doing line?
ch:value(f.channel, "%i (%.3f ghz)" %{ f.channel, f.mhz / 1000 })
i think assigning value ch cannot understand one, because cannot understand section "%i (%.3f ghz)" %{ f.channel, f.mhz / 1000 }
thanks in advance!
complete code
-- check whether there client interface on same radio, -- if yes, lock channel choice station dicatate freq local has_sta = nil local _, net _, net in ipairs(wdev:get_wifinets()) if net:mode() == "sta" , net:id() ~= wnet:id() has_sta = net break end end if has_sta ch = s:taboption("general", dummyvalue, "choice", translate("channel")) ch.value = translatef("locked channel %d used %s", has_sta:channel(), has_sta:shortname()) else ch = s:taboption("general", value, "channel", translate("channel")) ch:value("auto", translate("auto")) -- _, f in ipairs(iw , iw.freqlist or { }) _.iw.chanlist, f in ipairs(iw , iw.freqlist or iw.channels) if not f.restricted ch:value(f.channel, "%i (%.3f ghz)" %{ f.channel, f.mhz / 1000 }) end end end
"%i (%.3f ghz)" %{ f.channel, f.mhz / 1000 }
- the
%i
parse argument integer. %.3f
formats second argument floating point number 3 decimal places.%{}
defines arguments being passed previous string formatting.- first parameter
f.channel
- second argument
f.mhz/1000
.
- first parameter
ch:value( f.value, ... )
is same following:
ch.value( ch, f.value, ... )
Comments
Post a Comment