--- loncom/xml/scripttag.pm 2000/08/16 18:32:58 1.13
+++ loncom/xml/scripttag.pm 2000/10/02 22:22:25 1.17
@@ -14,25 +14,38 @@ sub BEGIN {
sub start_script {
my ($target,$token,$parstack,$parser,$safeeval)=@_;
+ my $args ='';
+ if ( $#$parstack > -1 ) {
+ $args=$$parstack[$#$parstack];
+ }
+ my $type = &Apache::run::run("{$args;".'return $type}',$safeeval);
+ &Apache::lonxml::debug("found type of $type");
my $result="";
-# my $bodytext=$$parser[$#$parser]->get_text("/script");
- my $bodytext=&Apache::lonxml::get_all_text("script",$$parser[$#$parser]);
-
- if ( $target eq "modified" ) {
+ if ($type eq "loncapa/perl") {
+ $safeeval->share('$Apache::scripttag::start_script::result');
+ # my $bodytext=$$parser[$#$parser]->get_text("/script");
+ my $bodytext=&Apache::lonxml::get_all_text("script",$$parser[$#$parser]);
- }
+ if ( $target eq "modified" ) {
+
+ }
-# print "
script runs $bodytext";
- $result = &Apache::run::run($bodytext,$safeeval);
-
- if ($target eq "edit" ) {
- $result= "
<$token->[1]> output:
$bodytext
Source:
";
- $result.=&editfield($token->[1],$bodytext);
+ # print "
script runs $bodytext";
+ &Apache::run::run($bodytext,$safeeval);
+
+ if ($target eq "edit" ) {
+ $result= "
<$token->[1]> output:
$bodytext
Source:
";
+ $result.=&editfield($token->[1],$bodytext);
+ }
+ } else {
+ $result = $token->[4];
}
- return $result;
}
-sub end_script {}
+sub end_script {
+ my ($target,$token,$parstack,$parser,$safeeval)=@_;
+ return $token->[2];
+}
sub start_scriptlib {
my ($target,$token,$parstack,$parser,$safeeval)=@_;
@@ -76,6 +89,10 @@ sub start_import {
$bodytext=Apache::run::evaluate($bodytext,$safeeval,$$parstack[$#$parstack]);
my $file=&getfile($bodytext);
+ if ($file eq -1) {
+ return " Unable to find $bodytext for import";
+ }
+
my $tempparser=HTML::TokeParser->new(\$file);
push (@$parser,$tempparser);
@@ -110,6 +127,7 @@ sub getfile {
&Apache::lonnet::subscribe($filename);
&Apache::lonnet::repcopy($filename);
}
+ if (! -e $filename ) { return -1; };
my $fh=Apache::File->new($filename);
while (<$fh>) {
$a .=$_;