Fix dx/dx so it can do 'on 1000/4000' and also merge sh/dxcc into sh/dx
authorminima <minima>
Sun, 23 Dec 2001 17:27:01 +0000 (17:27 +0000)
committerminima <minima>
Sun, 23 Dec 2001 17:27:01 +0000 (17:27 +0000)
so that I only have one sh/dx to maintain.

Changes
cmd/Aliases
cmd/Commands_en.hlp
cmd/show/dx.pl
cmd/show/dxcc.pl [deleted file]

diff --git a/Changes b/Changes
index 0d19ff9082c585050a7770e37bfa8785d56380a9..ced1490d2c7d1af2c67b7b13709768c87646a06e 100644 (file)
--- 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
index 2d58d60e19a25da7bf9a6eac2557ff19fc7fa122..2bedd5dca5fd872e1f3fc68864856df90a983e66 100644 (file)
@@ -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',
index b9d59a9a623f3d610a0cc1af8de9e0495ce0ad0b..8e7d4872f856399adb3b68874f5961f948f1d5b0 100644 (file)
@@ -1522,9 +1522,12 @@ any order to the basic SHOW/DX command, they are:-
    
 on <band>       - eg 160m 20m 2m 23cm 6mm
 on <region>     - eg hf vhf uhf shf      (see SHOW/BANDS)
+on <from>/<to>  - eg 1000/4000 14000-30000  (in Khz)
+   <from>-<to>
    
 <number>        - the number of spots you want
 <from>-<to>     - <from> spot no <to> spot no in the selected list
+<from>/<to>
    
 <prefix>        - for a spotted callsign beginning with <prefix>
 *<suffix>       - for a spotted callsign ending in <suffix>
@@ -1532,7 +1535,8 @@ on <region>     - eg hf vhf uhf shf      (see SHOW/BANDS)
    
 day <number>    - starting <number> days ago
 day <from>-<to> - <from> days <to> days ago
-   
+    <from>/<to>   
+
 info <text>     - any spots containing <text> in the info or remarks
    
 by <call>       - any spots spotted by <call> (spotter <call> is the 
@@ -1548,6 +1552,13 @@ iota [<iota>]   - If the iota island number is missing it will look for
 
 qra [<locator>] - 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 <prefix>^Interrogate the spot database by country
 This command takes the <prefix> (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
index b2257c49b48ac04e412be931cc731f459e84174b..6d9ad3add54c47abae7c2203a57dc05b52a91d25 100644 (file)
@@ -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 (file)
index f5826e4..0000000
+++ /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);