Wednesday 19 March 2014

Jscript Function Statement | How To Write Jscript Functions

Jscript Function Statement, Jscript Functions Vs Jscript Functions, Jscript Functions Example, Jscript Blog.
In order to create a JScript, you only need to open your text editor, create a plain text file, add a few JScript statements to it, and then save it with a .js file extension. For example, create a new JScript called my_first_prog.js and add the following statements to it.
//Script 1.5 - Your first JScript
WScript.Echo("Well To ProgrammingDost!");

The first statement is a comment that was embedded within the file to document the script's name and purpose. The second statement displays a text message. The composition of the second statement is as follows. First the WScript object is referenced. This object is different from the WScript execution host. Then a method called Echo, which belongs to the WScript object, is executed and passed the text string "Well To ProgrammingDost!". Don't worry if this all sounds a little confusing or overwhelming now. By the time that you get through Sunday evening, you'll understand how this stuff works. For now, just follow along and focus on the steps involved in creating and executing your first JScript.
When executed by either the WScript or CScript execution host, this JScript displays its message. However, depending on which execution host you choose to use when running the script, the results will vary significantly.
If you were to run the scripts directly from the Windows desktop by double-clicking on it, Windows would, by default, run it using the WScript execution host. As a result, the script's output would be displayed in the form of a graphical pop-up dialog.
NOTE
You can also use the WScript execution host to run scripts from the Windows command prompt,in which case the script will run exactly as if you had started it from the Windows desktop.
Even some of the most experienced computer users have limited experience working with the Windows command prompt and little if any understanding of the Windows commands that are available. However, if you plan on becoming a serious JScript programmer, you need to get comfortable working with the Windows shell.
The Windows shell provides a text-based interface between the user and the operating system. Instead of using the computer's mouse to point and click your way through the Windows graphical user interface, you work with the Windows shell by typing in text commands. The Windows shell translates these commands into a format the operating system can understand. Likewise, the Windows shell translates any output returned by the operating system into a format that people can understand.
You enter commands for the Windows shell to process by typing them in at the Windows command prompt. For example, on a computer running Windows XP, you would start up a new Windows shell session by clicking on Start, All Programs, Accessories, and then Command Prompt.
TIP
As a shortcut, you can start up a new Windows shell session and access the Windows command prompt by clicking on Start, Run, typing CMD, and then clicking on OK.
NOTE
If your script resides in a folder other than the folder upon which the Windows shell is currently focused, you must supply the complete path to the folder where the script is stored. For example, if your script were stored in C:\Jscripts, then you would need to use the following command to run it using the WScript execution host.
TIP
If you are faster at the keyboard than you are with your mouse then you can also close the Command Prompt windows by typing EXIT and pressing the Enter key.

No comments:

Post a Comment