Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARRL DX: accept 1TT or 100 as valid power entries #151

Merged
merged 3 commits into from
Dec 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Log.pas
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,16 @@ procedure LastQsoToScreen;


procedure CheckErr;
// Reduce Power characters (T, O, A, N) to (0, 0, 1, 9) respectively.
function ReducePowerStr(const text: string): string;
begin
assert(Mainform.RecvExchTypes.Exch2 = etPower);
Result := text.Replace('T', '0', [rfReplaceAll])
.Replace('O', '0', [rfReplaceAll])
.Replace('A', '1', [rfReplaceAll])
.Replace('N', '9', [rfReplaceAll]);
end;

begin
with QsoList[High(QsoList)] do begin
Err := '';
Expand All @@ -688,7 +698,8 @@ procedure CheckErr;
etStateProv: if TrueExch2 <> Exch2 then Err := 'ST ';
//etItuZone:
//etAge:
etPower: if TrueExch2 <> Exch2 then Err := 'PWR';
etPower: if ReducePowerStr(TrueExch2) <> ReducePowerStr(Exch2) then
Err := 'PWR';
//etJarlOblastCode:
else
assert(false, 'missing exchange 2 case');
Expand Down
18 changes: 15 additions & 3 deletions Main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ TFieldDefinition = record
(C: 'Nr.'; R: '([0-9][0-9]*)|(#)'; L: 4; T:Ord(etSerialNr)),
(C: 'Number'; R: '[1-9][0-9]*'; L: 10; T:Ord(etCwopsNumber)),
(C: 'Section'; R: '([A-Z][A-Z])|([A-Z][A-Z][A-Z])'; L: 3; T:Ord(etArrlSection)),
(C: 'State/Prov'; R: '[A-Z][A-Z]*'; L: 6; T:Ord(etStateProv)),
(C: 'State/Prov'; R: '[ABCDFGHIKLMNOPQRSTUVWY][ABCDEFHIJKLMNORSTUVXYZ]';
L: 6; T:Ord(etStateProv)),
(C: 'CQ-Zone'; R: '[0-9]*'; L: 2; T:Ord(etCqZone)),
(C: 'Zone'; R: '[0-9]*'; L: 4; T:Ord(etItuZone)),
(C: 'Age'; R: '[0-9][0-9]'; L: 2; T:Ord(etAge)),
(C: 'Power'; R: '([0-9]*)|(K)|(KW)|([0-9][OT]*)'; L: 4; T:Ord(etPower)),
(C: 'Power'; R: '([0-9]*)|(K)|(KW)|([0-9A]*[OTN]*)'; L: 4; T:Ord(etPower)),
(C: 'Number'; R: '[0-9]*[A-Z]'; L: 12; T:Ord(etJarlOblastCode))
);

Expand Down Expand Up @@ -574,6 +575,14 @@ procedure TMainForm.Edit2KeyPress(Sender: TObject; var Key: Char);
end;
end;

{
Exchange field 2 key press. This procedure is called upon any keystroke
in the Exchange 2 field. Depending on the exchange field type, it will
map some keys into an equivalent numeric value. For example, the 'N'
key is mapped to it's equivalent '9' value. this allows the user
to type what they hear and this function will convert to the equivalent
numeric value.
}
procedure TMainForm.Edit3KeyPress(Sender: TObject; var Key: Char);
begin
case RecvExchTypes.Exch2 of
Expand All @@ -591,13 +600,16 @@ procedure TMainForm.Edit3KeyPress(Sender: TObject; var Key: Char);
end;
etPower:
begin
{ K6OK recommends not mapping these characters (PR #138)
case Key of
'a', 'A': Key := '1';
'n', 'N': Key := '9';
't', 'T': Key := '0';
end;
}
// valid Power characters, including KW...
if not CharInSet(Key, ['0'..'9', 'K', 'k', 'W', 'w', #8]) then
if not CharInSet(Key, ['0'..'9', 'K', 'k', 'W', 'w', 'A', 'a',
'n', 'N', 'o', 'O', 't', 'T', #8]) then
Key := #0;
end;
etArrlSection:
Expand Down