[LON-CAPA-cvs] cvs: loncom / lonr

raeburn raeburn at source.lon-capa.org
Thu Nov 13 15:09:08 EST 2014


raeburn		Thu Nov 13 20:09:08 2014 EDT

  Modified files:              
    /loncom	lonr 
  Log:
  - Reverse part of change in rev. 1.4 which was causing evaluation of 
    expressions such as: &cas("R", "2*(1-pt($t, df=$n-1));"); to fail.
  - Improved detection of index in indexed line following regexp used in
    Statistics::R (cpan)
  - Passing integer to R in sync() routine should result in exact echoing of 
    the integer (i.e., avoid scientific notation in R's response format).   
  
  
Index: loncom/lonr
diff -u loncom/lonr:1.7 loncom/lonr:1.8
--- loncom/lonr:1.7	Thu Oct 30 19:09:06 2014
+++ loncom/lonr	Thu Nov 13 20:09:08 2014
@@ -3,7 +3,7 @@
 # The LearningOnline Network with CAPA
 # Connect to R CAS
 #
-# $Id: lonr,v 1.7 2014/10/30 19:09:06 raeburn Exp $
+# $Id: lonr,v 1.8 2014/11/13 20:09:08 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -317,10 +317,15 @@
 	my ($command)=@_;
 	$counter++;
 	my $expect=$counter;
-	print $command "$expect;\n";
+        if (length($expect) > 10) {
+            $counter = 1;
+            $expect = $counter;
+        }
+	print $command "print($expect,digits=10);\n";
 	while (1) {
 	    my $output=&getroutput($command);
-	    if (($output=~/\Q$expect\E/) || ($output=~/^Error\:/)) {
+            chomp($output);
+	    if (($output=~/^\Q$expect\E/) || ($output=~/^Error\:/)) {
 		return;
 	    }
 	}
@@ -352,7 +357,7 @@
     foreach my $line (split(/\n/,$output)) {
        $line=~s/\s$//gs;
        if ($line=~/^Error\:/) { $syntaxerr=1; next; }
-       if (my ($result)=($line=~/^\[?\d+\,*\]?\s*(.*)/)) { $realoutput.=$result."\n"; }
+       if (my ($result)=($line=~/^\s*\[\d+\]\s*(.*)/)) { $realoutput.=$result."\n"; }
     }
     if (wantarray) {
         return ($realoutput,$syntaxerr);




More information about the LON-CAPA-cvs mailing list