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

www lon-capa-cvs@mail.lon-capa.org
Fri, 05 Jul 2002 01:31:25 -0000


www		Thu Jul  4 21:31:25 2002 EDT

  Modified files:              
    /loncom/interface	lonspreadsheet.pm 
  Log:
  Working on better debugging
  
  
Index: loncom/interface/lonspreadsheet.pm
diff -u loncom/interface/lonspreadsheet.pm:1.94 loncom/interface/lonspreadsheet.pm:1.95
--- loncom/interface/lonspreadsheet.pm:1.94	Thu Jul  4 16:09:31 2002
+++ loncom/interface/lonspreadsheet.pm	Thu Jul  4 21:31:25 2002
@@ -1,5 +1,5 @@
 #
-# $Id: lonspreadsheet.pm,v 1.94 2002/07/04 20:09:31 www Exp $
+# $Id: lonspreadsheet.pm,v 1.95 2002/07/05 01:31:25 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -106,6 +106,13 @@
 my %useropt;
 my %parmhash;
 
+#
+# Some hashes for stats on timing and performance
+#
+
+my %starttimes;
+my %usedtimes;
+
 # Stuff that only the screen handler can know
 
 my $includedir;
@@ -165,6 +172,10 @@
 
 $usymb='';
 
+# error messages
+
+$errormsg='';
+
 sub mask {
     my ($lower,$upper)=@_;
 
@@ -820,28 +831,29 @@
 }
 
 sub calc {
-    %v=();
+    undef %v;
     &sett();
     my $notfinished=1;
     my $depth=0;
+    my $errormsg;
     while ($notfinished) {
 	$notfinished=0;
         foreach (keys(%t)) {
             my $old=$v{$_};
             $v{$_}=eval($t{$_});
 	    if ($@) {
-		%v=();
-                return $@;
+		$v{$_}='"error"';
+                $errormsg.=$_.': '.$@."\n";
             }
 	    if ($v{$_} ne $old) { $notfinished=1; }
         }
         $depth++;
         if ($depth>100) {
-	    %v=();
+	    undef %v;
             return 'Maximum calculation depth exceeded';
         }
     }
-    return '';
+    return $errormsg;
 }
 
 sub templaterow {
@@ -956,7 +968,7 @@
 
 sub calcsheet {
     my $safeeval=shift;
-    $safeeval->reval('&calc();');
+    return $safeeval->reval('&calc();');
 }
 
 # ------------------------------------------------------------------ Get values
@@ -1490,7 +1502,7 @@
         }
     } elsif ($nfield eq 'insertrow') {
         $countrows++;
-        my $newrow=substr('000000'.$i,-7);
+        my $newrow=substr('000000'.$countrows,-7);
         if ($nform eq 'top') {
 	    $fo{'A'.$countrows}='--- '.$newrow;
         } else {