home *** CD-ROM | disk | FTP | other *** search
/ Freelog Special Freeware 25 / FreelogHS25.iso / Dessin / ArtOfIllusion2.2.1 / ArtOfIllusion.jar / bsh / commands / source.bsh < prev    next >
Text File  |  2005-05-23  |  705b  |  24 lines

  1. /**
  2.     Read filename into the interpreter and evaluate it in the current
  3.     namespace.  Like the Bourne Shell "." command.
  4.     This command acts exactly like the eval() command but reads from a file 
  5.     or URL source.
  6.     @see eval() for more information.
  7.     @throws bsh.EvalError or bsh.TargetError on errors in the sourced script.
  8. */
  9.  
  10. bsh.help.source = "usage: source( filename | URL )";
  11.  
  12. Object source( String filename ) {
  13.     // source with filename preserves file name in error messages
  14.     return this.interpreter.source( filename, this.caller.namespace );
  15. }
  16.  
  17. Object source( URL url ) {
  18.     return this.interpreter.eval( 
  19.         new InputStreamReader(url.openStream()), this.caller.namespace,  
  20.         "URL: "+url.toString()
  21.     );
  22. }
  23.  
  24.