[LON-CAPA-cvs] cvs: loncom /interface lonspreadsheet.pm

matthew lon-capa-cvs@mail.lon-capa.org
Thu, 29 Aug 2002 15:35:01 -0000


matthew		Thu Aug 29 11:35:01 2002 EDT

  Modified files:              
    /loncom/interface	lonspreadsheet.pm 
  Log:
  Added MINPARM and MAXPARM, which return minimum and maximum values associated
  with a parameter name.  Invoke as follows: localtime(MINPARM('duedate'));
  Note, these functions do regular expression matches of their inputs on the
  parameters available in a spreadsheet, not any string substitutioni, as in 
  the EXPANDSUM function.
  
  
Index: loncom/interface/lonspreadsheet.pm
diff -u loncom/interface/lonspreadsheet.pm:1.102 loncom/interface/lonspreadsheet.pm:1.103
--- loncom/interface/lonspreadsheet.pm:1.102	Wed Aug 28 15:50:29 2002
+++ loncom/interface/lonspreadsheet.pm	Thu Aug 29 11:35:01 2002
@@ -1,5 +1,5 @@
 #
-# $Id: lonspreadsheet.pm,v 1.102 2002/08/28 19:50:29 matthew Exp $
+# $Id: lonspreadsheet.pm,v 1.103 2002/08/29 15:35:01 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -721,6 +721,53 @@
     return $sum;   
 }
 
+#-------------------------------------------------------
+
+=item MINPARM(parametername)
+
+Returns the minimum value of the parameters matching the parametername.
+parametername should be a string such as 'duedate'.
+
+=cut
+
+#-------------------------------------------------------
+sub MINPARM {
+    my ($expression) = @_;
+    my $min = undef;
+    study($expression);
+    foreach $parameter (keys(%c)) {
+        next if ($parameter !~ /$expression/);
+        if ((! defined($min)) || ($min > $c{$parameter})) {
+            $min = $c{$parameter} 
+        }
+    }
+    return $min;
+}
+
+#-------------------------------------------------------
+
+=item MAXPARM(parametername)
+
+Returns the maximum value of the parameters matching the input parameter name.
+parametername should be a string such as 'duedate'.
+
+=cut
+
+#-------------------------------------------------------
+sub MAXPARM {
+    my ($expression) = @_;
+    my $max = undef;
+    study($expression);
+    foreach $parameter (keys(%c)) {
+        next if ($parameter !~ /$expression/);
+        if ((! defined($min)) || ($max < $c{$parameter})) {
+            $max = $c{$parameter} 
+        }
+    }
+    return $max;
+}
+
+#--------------------------------------------------------
 sub expandnamed {
     my $expression=shift;
     if ($expression=~/^\&/) {