|
August 19, 2002 Printing from JScript .NET Tips: August 2002
Yehuda Shiran, Ph.D.
|
|
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:
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:
People who read this tip also read these tips: Look for similar tips by subject: |