[LON-CAPA-cvs] cvs: loncom / lonr
raeburn
raeburn at source.lon-capa.org
Sat Nov 15 21:10:41 EST 2014
raeburn Sun Nov 16 02:10:41 2014 EDT
Modified files:
/loncom lonr
Log:
- Support evaluation of R expressions which begin with a digit (see rev 1.8)
- Modify regexp used to detect indexed line to support legacy use of
&cas("R") for R output from a<-matrix and data.frame (i.e., without
serialization) -- the preferred way is to use &cas_hashref("R").
- Remove unused scalars added in rev 1.1 when lonr was originally modelled
after lonmaxima.
Index: loncom/lonr
diff -u loncom/lonr:1.8 loncom/lonr:1.9
--- loncom/lonr:1.8 Thu Nov 13 20:09:08 2014
+++ loncom/lonr Sun Nov 16 02:10:41 2014
@@ -3,7 +3,7 @@
# The LearningOnline Network with CAPA
# Connect to R CAS
#
-# $Id: lonr,v 1.8 2014/11/13 20:09:08 raeburn Exp $
+# $Id: lonr,v 1.9 2014/11/16 02:10:41 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -316,12 +316,12 @@
sub sync {
my ($command)=@_;
$counter++;
- my $expect=$counter;
- if (length($expect) > 10) {
+ my $digits = length($counter);
+ if ($digits > 10) {
$counter = 1;
- $expect = $counter;
}
- print $command "print($expect,digits=10);\n";
+ my $expect=$counter;
+ print $command "print($expect,digits=$digits);\n";
while (1) {
my $output=&getroutput($command);
chomp($output);
@@ -351,13 +351,12 @@
return 'Error: '.$error;
}
- my $foundoutput=0;
- my $found_label=0;
my $realoutput='';
foreach my $line (split(/\n/,$output)) {
$line=~s/\s$//gs;
if ($line=~/^Error\:/) { $syntaxerr=1; next; }
- if (my ($result)=($line=~/^\s*\[\d+\]\s*(.*)/)) { $realoutput.=$result."\n"; }
+ if ($line=~ /\;$/) { next; }
+ if (my ($result)=($line=~/^\s*\[?\d+\,?\]?\s*(.*)/)) { $realoutput.=$result."\n"; }
}
if (wantarray) {
return ($realoutput,$syntaxerr);
More information about the LON-CAPA-cvs
mailing list