1. fixed Julian routines
authordjk <djk>
Sat, 1 Jan 2000 14:13:04 +0000 (14:13 +0000)
committerdjk <djk>
Sat, 1 Jan 2000 14:13:04 +0000 (14:13 +0000)
2. fixed gdx so that it allows spots to be gathered 'off-line'.

Changes
perl/Julian.pm
perl/Spot.pm
perl/gdx.pl

diff --git a/Changes b/Changes
index c5741356ee61c09bf4387bc4cfc042e7f2e0ffa4..b8538845c4621c50717b0a71416024fff4512d44 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,6 @@
+01Jan00=======================================================================
+1. Fixed Julian routines to get rid of the millenium bug! (do as I say, not
+as I do!).
 11Dec99=======================================================================
 1. added missing pc48 so that it calls the DXDb::process routine 
 10Dec99=======================================================================
index 8b3b74fdb8dd235b5c3dbb24e5376fe65106952c..07bf3849aa65df00fcdb34b82e24c51ca2c90496 100644 (file)
@@ -20,9 +20,7 @@ sub unixtoj
        my $t = shift;
        my ($year, $day) = (gmtime($t))[5,7];
        
-       if ($year < 100) {
-               $year += ($year < 50) ? 2000 : 1900;
-       }
+       $year += 1900;
        return ($year, $day+1);
 }
 
@@ -31,9 +29,8 @@ sub unixtojm
 {
        my $t = shift;
        my ($mon, $year) = (gmtime($t))[4..5];
-       if ($year < 100) {
-               $year += ($year < 50) ? 2000 : 1900;
-       }
+
+       $year += 1900;
        return ($year, $mon + 1);
 }
 
index cdd7393d21803c8f85931cf525e79664bec6eb89..d663c9bd3e973a82e1a9b55637ab96255c4d1a49 100644 (file)
@@ -29,7 +29,7 @@ $dirprefix = "spots";
 sub init
 {
        mkdir "$dirprefix", 0777 if !-e "$dirprefix";
-       $fp = DXLog::new($dirprefix, "dat", 'd')
+       $fp = DXLog::new($dirprefix, "dat", 'd');
 }
 
 sub prefix
index 759af1352353668cb1ab282fb8c1c183b89a246d..c3e22364f79062fff340640990aefe5347c5b350 100755 (executable)
@@ -3,27 +3,29 @@
 # grep for expressions in various fields of the dx file
 #
 
-use IO::File;
+# search local then perl directories
+BEGIN {
+       # root of directory tree for this system
+       $root = "/spider"; 
+       $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
+       
+       unshift @INC, "$root/perl";     # this IS the right way round!
+       unshift @INC, "$root/local";
+}
+
+use IO::Handle;
 use DXUtil;
-use DXDebug;
 use Spot;
 
-# initialise spots file
-STDOUT->autoflush(1);
-
-#print "reading in spot data ..";
-#$t = time;
-#$count = Spot->init();
-#$t = time - $t;
-#print "done ($t secs)\n";
-
-dbgadd('spot');
+$dxdir = "/spider/cmd/show";
+$dxcmd = "dx.pl";
+$s = readfilestr($dxdir, $dxcmd);
+$dxproc = eval "sub { $s }";
+die $@ if $@;
 
-$field = $ARGV[0];
-$expr = $ARGV[1];
-$time = time;
+STDOUT->autoflush(1);
+Spot::init();
 
-#loada();
 for (;;) {
   print "expr: ";
   $expr = <STDIN>;
@@ -31,106 +33,8 @@ for (;;) {
 
   chomp $expr;
 
-  print "doing field $field with /$expr/\n";
-
-#a();
-  b();
-}
-
-sub b
-{
-  my @spots;
-  my @dx;
-  my $ref;
-  my $count;
-  my $i;
-  
-  my $t = time;
-  @spots = Spot::search($expr);
-  if ($spots[0] eq "error") {
-    print $spots[1];
-       return;
-  }
-  foreach $ref (@spots) {
-    @dx = @$ref;
-       my $t = ztime($dx[2]);
-       my $d = cldate($dx[2]);
-       print "$dx[0] $dx[1] $d $t $dx[4] <$dx[3]>\n";
-       ++$count;
-  }
-  $t = time - $t;
-  print "$count records found, $t secs\n";
-}
-
-sub search
-{
-  my ($expr, $from, $to) = @_;
-  my $eval;
-  my @out;
-  my @spots;
-  my $ref;
-  my $i;
-
-
-  $expr =~ s/\$f(\d)/zzzref->[$1]/g;               # swap the letter n for the correct field name
-  $expr =~ s/[\@\$\%\{\}]//g;                           # remove any other funny characters
-  $expr =~ s/\&\w+\(//g;                           # remove subroutine calls
-  $expr =~ s/eval//g;                              # remove eval words
-  $expr =~ s/zzzref/\$ref/g;                       # put back the $ref
-  
-  print "expr = $expr\n";
-  
-  # build up eval to execute
-  $eval = qq(my \$c;
-    for (\$c = \$#spots; \$c >= 0; \$c--) {
-         \$ref = \$spots[\$c];
-         if ($expr) {
-        push(\@out, \$ref);
-         }
-  });
-
-  my @today = Julian::unixtoj(time);
-  for ($i = 0; $i < 60; ++$i) {
-    my @now = Julian::sub(@today, $i);
-       my @spots;
-       my $fp = Spot->open(@now);
-       if ($fp) {
-         my $fh = $fp->{fh};
-         my $in;
-         foreach $in (<$fh>) {
-           chomp $in;
-        push @spots, [ split('\^', $in) ];
-         }
-         my $ref;
-         eval $eval;
-         return ("error", $@) if $@;
-       }
-  }
-                               # execute it
-  return @out;
-}
-
-
-sub loada
-{
-  while (<IN>) {
-    chomp;
-       my @dx =  split /\^/;
-       next if $time - $dx[2] > (84600 * 60);  
-       unshift @spots, [ @dx ];
-       ++$count;
-  }
-}
-
-sub a
-{
-  foreach $ref (@spots) {
-    if ($$ref[$field] =~ /$expr/i) {
-         my @dx = @$ref;
-         my $t = ztime($dx[2]);
-         my $d = cldate($dx[2]);
-      print "$dx[0] $dx[1] $d $t $dx[4] <$dx[3]>\n";
-       }
-  }
+  my @out = map {"$_\n"} &$dxproc({priv=>0,call=>'GDX'}, $expr);
+  shift @out;   # remove return code
+  print @out;
 }