The following code shows a similar example
for JavaScript.
// Test1.JS shows how to use functions within a WSH script.
WScript.Echo("The value returned was: " + MyFunction(1));
function MyFunction(nSomeValue)
{
WScript.Echo("The value received was: " + nSomeValue);
return nSomeValue + 1;
}
JavaScript only provides functions, so that??™s all this example demonstrates. It??™s also important
to notice that VBScript requires you to convert numeric values to a string, while JavaScript performs
the conversion automatically. The following sections show how to perform certain command line??“
oriented tasks using scripting.
Scripting the Command Line and System Environment
Many of your scripts require access to the command line. The command line is where you type
switches to modify the behavior of the script, as many of the utilities described in this book do. The
system environment contains user, application, and operating system values, such as the user??™s
name or the version of the operating system. The JavaScript code in Listing 6.1 retrieves information
from the command line. It also retrieves information about the application environment.
Pages:
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448