JScript .NET, Part II: Major Features: Printing - Doc JavaScript
JScript .NET, Part II: Major Features
Printing
Use the print()
function to send a string to the console, followed by a newline character. The print
statement allows you to display data from a JScript .NET application compiled with the JScript .NET command-line compiler, jsc.exe
. The print statement takes a single string as a parameter and displays it to the console. For example, the line:
print("Hello World!");
will send "Hello World!"
to the console. You can use escape sequences to specify actions such as carriage returns and tab movement. Escape sequences are character combinations consisting of a backslash (\
) followed by a letter or by a combination of digits. The combination "\n"
is new line. The combination "\t"
is tab.
The print
statement is enabled by default in the JScript .NET command-line compiler, jsc.exe
. You can disable it by using the /print-
option. When there is no console to print to (for example, Windows GUI), the print statement will silently fail. Output from the print
statement can be redirected to a file from the command line. If you want to make sure redirected output is correctly formatted, include the "\r"
combination at the end of each printed line. It does not affect the way lines are displayed on the console.
The following print
statement:
print("Student: \t" + student + "\nGrade: \t" + grade);
will yield the following console output:
Student: John Grade: 98
Next: How to define classes
Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: April 22, 2002
Revised: April 22, 2002
URL: https://www.webreference.com/js/column108/5.html