[WT-support] Little help with LUA-stuff

Bob Wilson, N6TV n6tv at arrl.net
Tue Sep 14 12:13:42 CEST 2010


Ok here is version 2 (attached).  You should be able to spin the Secondary
Radio dial while the PSE QSY is sending.

Save these two files to your /scripts directory (File | Explore | /scripts
directory), then assign to function keys using Tools | Scripts Manager.

PseQSY.wts (assign to F12, perhaps, or use #FREQS in the Alt-C messages):

-- PSEQSY - Send PSE QSY message to the frequency of the Secondary Radio,
--          to the nearest 100 Hz, 500 Hz, or 1 kHz.
--
-- Assign to:   F8, F9, F10, or F12 or user choice.
-- 
-- Argument:  none
--
-- Time-stamp: "14 September 2010 09:52 UTC"
--
-- Written by N6TV
   wtKeyer:Play("-PSE QSY+ #FREQS(0)")   -- Round to nearest whole kHz
-- wtKeyer:Play("-PSE QSY+ #FREQS(5)")   -- Round to nearest 500 Hz
-- wtKeyer:Play("-PSE QSY+ #FREQS(1)")   -- Round to nearest 100 Hz like
$FREQnn msgs variables

-- No further keystroke processing.
return -1

FreqS.wts (assign to F10, perhaps, to resend *only* the QSY frequency):

-- FreqS - Send the frequency of the Secondary Radio, to the nearest 100 Hz,
500 Hz, or 1 kHz.
--
-- Assign to:   F8, F9, F10, or F12 or user choice, to send QSY FREQ only,
if asked for repeat.
-- 
-- Argument:  1, 5, or 0, meaning send the QSY frequency to the nearest 0.1,
0.5, or whole kHz
--            Default:  1 kHz (no fractions).  Fuzzing rounding used (>=0.6
rounds up to next kHz).
--
-- Time-stamp: "14 September 2010 09:51 UTC"
--
-- Can be called from CW msgs or another script e.g. for 14020.6
--    wtKeyer:Play( "PSE QSY #FREQS(0)"    )  -- To nearest kHz "14021"
--    wtKeyer:Play( "PSE QSY #FREQS(5)" )  -- To nearest 500 Hz "14025R5"
--    wtKeyer:Play( "PSE QSY #FREQS(1)" )  -- To nearest 100 Hz "14025R1"
--
-- Written by N6TV

-- Windows MessageBox constant
MB_ICONINFORMATION = 0x00000040

local QSYfreq = ""
local freqFrac = ""
local argErr = false

-- Get the VFO A frequency of the secondary radio
local freqS = wtRadioSecondary:GetFreq()

-- If VFO frequency obtained OK
if freqS ~= nil and freqS ~= 0 then
   -- Split the frequency into the whole kHz and the fractional kHz, if any.
   -- Pattern extracts any string of digits, followed by 0 or 1 decimal
point character,
   -- followed by zero or one digit representing fractional kHz (e.g.
3830.8)
   _, _, QSYfreq, freqFrac = string.find(freqS, "([%d]+)%.?([%d]?)")

   -- If no fractional kHz is to be sent, round up if fractional part >= 0.6
kHz
   if wtArg == nil or wtArg == "0" or wtArg == 0 then
      if freqFrac >= "6" then
     QSYfreq = QSYfreq + 1
      end
   elseif wtArg == "5" or wtArg == 5 then
      -- Send "R5" only if freq ends with .4, .5, or .6, otherwise round up
or down
      if freqFrac >= "7" then
     QSYfreq = QSYfreq + 1
      elseif freqFrac >= "4" then
     QSYfreq = QSYfreq .. "R5"
      end
   elseif wtArg == "1" or wtArg == 1 then
      -- Send Rn just like the $FREQnn message variables do
      if freqFrac >= "1" and freqFrac <= "9" then
         QSYfreq = QSYfreq .. "R" .. freqFrac
      end
   else
      argErr = true
   end
end

-- Play the secondary radio's frequency, 4 WPM slower than current CW keyer
speed.
wtKeyer:Play("--" .. QSYfreq .. "++ ?")

-- Finally, let the user know about any unrecognized arguments passed and
ignored.
if argErr then
   wtApp:MessageBox("Argument " .. wtArg .. " passed to LUA script " ..
     wtCurrentScript .. " ignored.  " ..
     "Use 1 for 100 Hz, 5 for 500 Hz, or no argument for 1 kHz rounding.",
      MB_ICONINFORMATION, wtCurrentScript)
end

-- Reset global in case next call specifies no argument
wtArg = nil

-- No further keystroke processing
return -1

Please test and report if this works to your liking.  If you don't like the
trailing question mark being sent, you can delete it.  Unfortunately the "?"
can't be placed after the call to #FREQS(0) as Laurent already mentioned.

73,
Bob, N6TV
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.f5mzn.org/pipermail/support/attachments/20100914/c12abf43/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PseQSY.wts
Type: application/octet-stream
Size: 572 bytes
Desc: not available
Url : http://www.f5mzn.org/pipermail/support/attachments/20100914/c12abf43/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: FreqS.wts
Type: application/octet-stream
Size: 2701 bytes
Desc: not available
Url : http://www.f5mzn.org/pipermail/support/attachments/20100914/c12abf43/attachment-0001.obj 


More information about the Support mailing list