spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column116


JScript .NET, Part X: Displaying Information

Technical Lead
Thomson Reuters (Markets) LLC
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume
Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?


Using print()

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 of this 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:


Next: How to use System.Console

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

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

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: August 12, 2002
Revised: August 12, 2002

URL: http://www.webreference.com/js/column116/2.html