spacer
Yehuda Shiran August 19, 2002
Printing from JScript .NET
Tips: August 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
HP to Microsoft: Thanks for Nothing
iPhone Remains Left Out as Android Scores Flash
The Year of Living the OpenSocial
The most common way to display information is with the print statement. The print statement takes one argument, a string, and displays it in the command-line window, followed by a new line character. The print statement works only with the JScript command-line compiler, jsc. Trying to use print in an ASP.NET page will yield a compiler error. So will an attempt to use it in a Code Behind JScript .NET. Here is a JScript .NET script that uses the print statement:

  import System;
  class HelloWorld{
    //constructor
    function HelloWorld() {
      print("Object Constructed");
    }
  
    //method
    function TypeHello() {
      print("Hello World.");
    }
  }

  var myHelloWorldObj = new HelloWorld();
  myHelloWorldObj.TypeHello();
The program defines a class, HelloWorld, with two methods: the constructor HelloWorld() and TypeHello(). Each method prints one string. The constructor prints the message "Object Constructed" when an object of type HelloWorld is constructed. The TypeHello() method prints the message "Hello World". Compiling this program, col116ex2.js, with the jsc compiler yields the default executable col116ex2.exe. When you run this executable (just type col116ex2 at the command line), you'll see the two print messages. The following command-line window shows the code listing, the compilation step, the execution step, and the output of the program:

To learn more about JScript .NET and ASP.NET, go to Column 116, JScript .NET, Part X: Displaying Information.


People who read this tip also read these tips:

Look for similar tips by subject:

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Administering RBAC in PHP 5 CMS Framework · xref: Automatic Cross Referencing Script · Book Review: Content Rich
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Gateway Launches New Core i7-powered FX-Series Gaming PCs · Review: Lenovo ThinkPad SL300 · EBay, Alternative Site Holiday Resources for Sellers