From ef646bd5c8fc8606448c8ac2019e048427741f67 Mon Sep 17 00:00:00 2001 From: minima Date: Sun, 23 Dec 2001 17:27:01 +0000 Subject: [PATCH] Fix dx/dx so it can do 'on 1000/4000' and also merge sh/dxcc into sh/dx so that I only have one sh/dx to maintain. --- Changes | 4 ++ cmd/Aliases | 1 + cmd/Commands_en.hlp | 24 ++++++++- cmd/show/dx.pl | 119 ++++++++++++++++++++++++++++++++++++-------- cmd/show/dxcc.pl | 99 ------------------------------------ 5 files changed, 126 insertions(+), 121 deletions(-) delete mode 100644 cmd/show/dxcc.pl diff --git a/Changes b/Changes index 0d19ff90..ced1490d 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,7 @@ +23Dec01======================================================================= +1. allow sh/dx on 1000/4000 (or 1000-4000). +2. merge sh/dx and sh/dxcc commands (Alias sh/dxcc to sh/dx dxcc). You can +now do things like 'sh/dxcc oq2 by w dxcc'. 20Dec01======================================================================= 1. Fix 'not' in filtering 2. alter default max spots to 100 and the no of WWV to 5 diff --git a/cmd/Aliases b/cmd/Aliases index 2d58d60e..2bedd5dc 100644 --- a/cmd/Aliases +++ b/cmd/Aliases @@ -117,6 +117,7 @@ package CmdAlias; '^sho?w?/c/n', 'show/configuration nodes', 'show/configuration', '^sho?w?/c$', 'show/configuration', 'show/configuration', '^sho?w?/com', 'dbavail', 'dbavail', + '^sho?w?/dxcc', 'show/dx dxcc', 'show/dx', '^sho?w?/dx/(\d+)-(\d+)', 'show/dx $1-$2', 'show/dx', '^sho?w?/dx/(\d+)', 'show/dx $1', 'show/dx', '^sho?w?/dx/d(\d+)', 'show/dx from $1', 'show/dx', diff --git a/cmd/Commands_en.hlp b/cmd/Commands_en.hlp index b9d59a9a..8e7d4872 100644 --- a/cmd/Commands_en.hlp +++ b/cmd/Commands_en.hlp @@ -1522,9 +1522,12 @@ any order to the basic SHOW/DX command, they are:- on - eg 160m 20m 2m 23cm 6mm on - eg hf vhf uhf shf (see SHOW/BANDS) +on / - eg 1000/4000 14000-30000 (in Khz) + - - the number of spots you want - - spot no spot no in the selected list +/ - for a spotted callsign beginning with * - for a spotted callsign ending in @@ -1532,7 +1535,8 @@ on - eg hf vhf uhf shf (see SHOW/BANDS) day - starting days ago day - - days days ago - + / + info - any spots containing in the info or remarks by - any spots spotted by (spotter is the @@ -1548,6 +1552,13 @@ iota [] - If the iota island number is missing it will look for qra [] - this will look for the specific locator if you specify one or else anything that looks like a locator. + +dxcc - treat the prefix as a 'country' and look for spots + from that country regardless of actual prefix. + eg dxcc oq2 + + You can also use this with the 'by' keyword so + eg by W dxcc e.g. @@ -1558,17 +1569,26 @@ e.g. SH/DX iota SH/DX iota eu-064 SH/DX qra jn86 + SH/DX dxcc oq2 + SH/DX dxcc oq2 by w dxcc === 0^SHOW/DXCC ^Interrogate the spot database by country This command takes the (which can be a full or partial callsign if desired), looks up which internal country number it is and then displays all the spots as per SH/DX for that country. + +This is now an alias for 'SHOW/DX DXCC' The options for SHOW/DX also apply to this command. e.g. SH/DXCC G - SH/DXCC W on 20m info iota + SH/DXCC W on 20m iota + +This can be done with the SHOW/DX command like this:- + + SH/DX dxcc g + SH/DX dxcc w on 20m iota === 0^SHOW/DXSTATS^Show the DX Statistics for last 31 days Show the total DX spots for the last 31 days diff --git a/cmd/show/dx.pl b/cmd/show/dx.pl index b2257c49..6d9ad3ad 100644 --- a/cmd/show/dx.pl +++ b/cmd/show/dx.pl @@ -19,33 +19,45 @@ my $spotter; my $info; my $expr; my $hint; +my $dxcc; +my $fromdxcc; my ($doqsl, $doiota, $doqra); while ($f = shift @list) { # next field # print "f: $f list: ", join(',', @list), "\n"; if (!$from && !$to) { - ($from, $to) = $f =~ /^(\d+)-(\d+)$/o; # is it a from -> to count? + ($from, $to) = $f =~ m|^(\d+)[-/](\d+)$|; # is it a from -> to count? next if $from && $to > $from; } if (!$to) { ($to) = $f =~ /^(\d+)$/o if !$to; # is it a to count? next if $to; } + if (lc $f eq 'dxcc') { + $dxcc = 1; + next; + } if (lc $f eq 'on' && $list[0]) { # is it freq range? # print "yup freq\n"; - my @r = split '/', lc $list[0]; - # print "r0: $r[0] r1: $r[1]\n"; - my @fr = Bands::get_freq($r[0], $r[1]); - if (@fr) { # yup, get rid of extranous param - # print "freq: ", join(',', @fr), "\n"; + if ($list[0] =~ m|^(\d+)(?:\.\d+)?[-/](\d+)(?:\.\d+)?$|) { + push @freq, $1, $2; shift @list; - push @freq, @fr; # add these to the list next; + } else { + my @r = split '/', lc $list[0]; + # print "r0: $r[0] r1: $r[1]\n"; + my @fr = Bands::get_freq($r[0], $r[1]); + if (@fr) { # yup, get rid of extranous param + # print "freq: ", join(',', @fr), "\n"; + push @freq, @fr; # add these to the list + shift @list; + next; + } } } if (lc $f eq 'day' && $list[0]) { # print "got day\n"; - ($fromday, $today) = split '-', shift(@list); + ($fromday, $today) = split m|[-/]|, shift(@list); next; } if (lc $f eq 'info' && $list[0]) { @@ -56,6 +68,10 @@ while ($f = shift @list) { # next field if ((lc $f eq 'spotter' || lc $f eq 'by') && $list[0]) { # print "got spotter\n"; $spotter = uc shift @list; + if ($list[0] && lc $list[0] eq 'dxcc') { + $fromdxcc = 1; + shift @list; + } next; } if (lc $f eq 'qsl') { @@ -86,11 +102,42 @@ while ($f = shift @list) { # next field # first deal with the prefix if ($pre) { - $pre .= '*' unless $pre =~ /[\*\?\[]/o; - $pre = shellregex($pre); - $expr = "\$f1 =~ m{$pre}"; - $pre =~ s/[\^\$]//g; - $hint = "m{\U$pre}"; + my @ans; + + if ($dxcc) { + @ans = Prefix::extract($pre); # is it a callsign/prefix? + + if (@ans) { + + # first deal with the prefix + my $pre = shift @ans; + my $a; + my $str = "Prefix: $pre"; + my $l = length $str; + my @expr; + my @hint; + + # build up a search string for this dxcc country/countries + foreach $a (@ans) { + my $n = $a->dxcc(); + push @expr, "\$f5 == $n"; + push @hint, "m{$n}"; + my $name = $a->name(); + $str .= " Dxcc: $n ($name)"; + push @out, $str; + $str = ' ' x $l; + } + $expr = @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0]; + $hint = @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0]; + } + } + unless (@ans) { + $pre .= '*' unless $pre =~ /[\*\?\[]/o; + $pre = shellregex($pre); + $expr = "\$f1 =~ m{$pre}"; + $pre =~ s/[\^\$]//g; + $hint = "m{\U$pre}"; + } } # now deal with any frequencies specified @@ -120,13 +167,45 @@ if ($info) { # any spotter if ($spotter) { - $expr .= " && " if $expr; - $spotter .= '*' unless $spotter =~ /[\*\?\[]/o; - $spotter = shellregex($spotter); - $expr .= "\$f4 =~ m{\U$spotter}"; - $hint .= " && " if $hint; - $spotter =~ s/[\^\$]//g; - $hint .= "m{\U$spotter}"; + + if ($fromdxcc) { + @ans = Prefix::extract($spotter); # is it a callsign/prefix? + + if (@ans) { + + # first deal with the prefix + my $pre = shift @ans; + my $a; + $expr .= ' && ' if $expr; + $hint .= ' && ' if $hint; + my $str = "Spotter: $pre"; + my $l = length $str; + my @expr; + my @hint; + + # build up a search string for this dxcc country/countries + foreach $a (@ans) { + my $n = $a->dxcc(); + push @expr, "\$f6 == $n"; + push @hint, "m{$n}"; + my $name = $a->name(); + $str .= " Dxcc: $n ($name)"; + push @out, $str; + $str = ' ' x $l; + } + $expr .= @expr > 1 ? '(' . join(' || ', @expr) . ')' : $expr[0]; + $hint .= @hint > 1 ? '(' . join(' || ', @hint) . ')' : $hint[0]; + } + } + unless (@ans) { + $expr .= " && " if $expr; + $spotter .= '*' unless $spotter =~ /[\*\?\[]/o; + $spotter = shellregex($spotter); + $expr .= "\$f4 =~ m{\U$spotter}"; + $hint .= " && " if $hint; + $spotter =~ s/[\^\$]//g; + $hint .= "m{\U$spotter}"; + } } # qsl requests diff --git a/cmd/show/dxcc.pl b/cmd/show/dxcc.pl deleted file mode 100644 index f5826e47..00000000 --- a/cmd/show/dxcc.pl +++ /dev/null @@ -1,99 +0,0 @@ -# -# show dx using the dxcc number as the basis for searchs for each callsign or prefix entered -# -# $Id$ -# - -my ($self, $line) = @_; -my @list = split /\s+/, $line; # split the line up - -my @out; -my $f; -my $call; -my ($from, $to); -my ($fromday, $today); -my @freq; -my @ans; - -while ($f = shift @list) { # next field -# print "f: $f list: ", join(',', @list), "\n"; - if (!$from && !$to) { - ($from, $to) = $f =~ /^(\d+)-(\d+)$/o; # is it a from -> to count? - next if $from && $to > $from; - } - if (!$to) { - ($to) = $f =~ /^(\d+)$/o if !$to; # is it a to count? - next if $to; - } - if (lc $f eq 'on' && $list[0]) { # is it freq range? -# print "yup freq\n"; - my @r = split '/', $list[0]; -# print "r0: $r[0] r1: $r[1]\n"; - @freq = Bands::get_freq($r[0], $r[1]); - if (@freq) { # yup, get rid of extranous param -# print "freq: ", join(',', @freq), "\n"; - shift @list; - next; - } - } - if (lc $f eq 'day' && $list[0]) { -# print "got day\n"; - ($fromday, $today) = split '-', $list[0]; - shift @list; - next; - } - if (!@ans) { - @ans = Prefix::extract($f); # is it a callsign/prefix? - } -} - -# no dxcc country, no answer! -if (@ans) { # we have a valid prefix! - - # first deal with the prefix - my $pre = shift @ans; - my $a; - my $expr = "("; - my $str = "Prefix: $pre"; - my $l = length $str; - - # build up a search string for this dxcc country/countries - foreach $a (@ans) { - $expr .= " || " if $expr ne "("; - my $n = $a->dxcc(); - $expr .= "\$f5 == $n"; - my $name = $a->name(); - $str .= " Dxcc: $n ($name)"; - push @out, $str; - $str = pack "A$l", " "; - } - $expr .= ")"; - push @out, $str; - - # now deal with any frequencies specified - if (@freq) { - $expr .= " && ("; - my $i; - for ($i = 0; $i < @freq; $i += 2) { - $expr .= "(\$f0 >= $freq[$i] && \$f0 <= $freq[$i+1]) ||"; - } - chop $expr; - chop $expr; - $expr .= ")"; - } - -# print "expr: $expr from: $from to: $to fromday: $fromday today: $today\n"; - - # now do the search - my @res = Spot::search($expr, $fromday, $today, $from, $to); - my $ref; - my @dx; - foreach $ref (@res) { - @dx = @$ref; - push @out, Spot::formatl(@dx); - } -} else { - @out = $self->msg('e4'); -} - -return (1, @out); -- 2.43.0