home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Shareware / Comunicatii / advwebrank / awr.msi / disk1.cab / bsh_1.2b6.jar / bsh / commands / print.bsh < prev    next >
Encoding:
Text File  |  2002-05-24  |  851 b   |  33 lines

  1. /**
  2.     Print the string value of the argument, which may be of any type.
  3.     If beanshell is running interactively, the output will always go to the 
  4.     command line, otherwise it will go to System.out.
  5.     <p>
  6.  
  7.     Most often the printed value of an object will simply be the Java 
  8.     toString() of the object.  However if the argument is an array the contents 
  9.     of the array will be (recursively) listed in a verbose way.
  10.     <p>
  11.  
  12.     Note that you are always free to use System.out.println() 
  13.     instead of print().
  14. */
  15. bsh.help.print = "usage: print( value )";
  16.  
  17. void print( arg ) {
  18.     if ( arg == null )
  19.         arg = "null";
  20.  
  21.     if ( arg instanceof Object [] ) {
  22.         len = arg.length;
  23.         print( "Array: "+arg +" {");
  24.         for( int i=0; i< len; i++ ) {
  25.             this.interpreter.print("   ");
  26.             print( arg[i] );
  27.         }
  28.         print ( "}");
  29.     } else
  30.         this.interpreter.println(String.valueOf(arg));
  31. }
  32.  
  33.