File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -320,11 +320,23 @@ function normalizeTxPwr(adifdata) {
320320 } ) ;
321321}
322322
323+ function normalizeKIndex ( adifdata ) {
324+ return adifdata . replace ( / < K _ I N D E X : ( \d + ) > ( [ ^ < ] + ) / gi, ( match , length , value ) => {
325+ const numValue = parseFloat ( value . trim ( ) ) ;
326+ if ( isNaN ( numValue ) ) return '' ; // Remove if not a number
327+
328+ // Round to nearest integer and clamp to 0-9 range
329+ let kIndex = Math . round ( numValue ) ;
330+ if ( kIndex < 0 ) kIndex = 0 ;
331+ if ( kIndex > 9 ) kIndex = 9 ;
332+
333+ return `<K_INDEX:${ kIndex . toString ( ) . length } >${ kIndex } ` ;
334+ } ) ;
335+ }
336+
323337function manipulateAdifData ( adifdata ) {
324338 adifdata = normalizeTxPwr ( adifdata ) ;
325-
326- // Remove K_INDEX fields - fix for Log4OM
327- adifdata = adifdata . replace ( / < K _ I N D E X : \d + > [ ^ < ] + / gi, '' ) ;
339+ adifdata = normalizeKIndex ( adifdata ) ;
328340 // add more manipulation if necessary here
329341 // ...
330342 return adifdata ;
You can’t perform that action at this time.
0 commit comments