Using Scripting Host Console

IntroductionQuick ReferencesHow Do I ... TopicsBuilt-in ToolsScripting and Programming

Hpmbcalc Scripting Host Console is a normal dialog box. With the console, you can edit, load, run, and debug your scripts. To display the console, you can choose Run Scripts... item From the Script menu.

Hpmbcalc supports both VBScript and JScript scripting engines. When Hpmbcalc starts, it searches Windows registry entries to determine which scripting engines can be used. If either scripting engine is useless, the script type will be disabled. So, before you can run a script under Hpmbcalc Scripting Host, you need install one of the scripting engines in your system.

With the Input Script box of the console, you can edit your script. You can also load a script file into the box by clicking the Browse... button of the console.

You can set the language that your script uses by selecting the VBScript button or the JScript button of the console.

After you have entered or loaded your script, you can click the Execute button of the console to run it. When a script is being run, its output and error information will be routed to the Script Output box. Your script can invoke object method Output to output any text.

You can click the Terminate button of the console to terminate a running script. It is used to cause current script executing thread to exit and should only be used in the most extreme cases.

What do you want to do?

To see console options

To write a script

To run a script

To see console options

The following console options exist:

To write a script

Here are the general guides to write a script for running under Hpmbcalc Scripting Host:

  1. Examine the script languages that can be used in your system. If both VBScript and JScript are available, choose the one you prefer.
  2. Choose your favorite text editor to create your script, or enter script to the Input Script box.
  3. Use any valid language-dependent code to write your script.
  4. Optionally, use Hpmbmath as object name to invoke Hpmbmath object methods.
  5. Optionally, invoke Hpmbmath.Output method to output any text to the Script Output box.

The following JScript code checks the primality of argument strHex for 4 times using Fermat Primality Test.


///////////////////////////////////////////////////////////
// Probabilistic Primality Test Script
// -----------------------------------
// This JScript code checks the primality of strHex for 4 
// times using Fermat Primality Test.
// 
// strHex = "10 9f e4 57 14 86 6e 56 " + 
//          "fd d4 ad 9b 6b 68 6d f2 " + 
//          "72 24 af b7 86 8c f4 f0 " + 
//          "cb b7 94 52 69 32 85 3c " + 
//          "bf 0b ee a6 15 94 16 66 " + 
//          "54 d1 3c d9 fe 0d 9d a5 " + 
//          "94 a9 7e e2 02 30 f1 2f " + 
//          "b5 43 4d e7 3f b4 f8 10 " + 
//          "27 25 a0 16 22 b3 1b 1e " + 
//          "a4 2e 3a 26 50 19 03 9a " + 
//          "c1 df 31 86 9b d9 79 30 " + 
//          "d7 92 fb 72 cd aa 97 1d " + 
//          "8a 80 15 af"
// is a known 800-bit prime.
///////////////////////////////////////////////////////////

var strHex, nPrime

strHex = "10 9f e4 57 14 86 6e 56 " + 
         "fd d4 ad 9b 6b 68 6d f2 " + 
         "72 24 af b7 86 8c f4 f0 " + 
         "cb b7 94 52 69 32 85 3c " + 
         "bf 0b ee a6 15 94 16 66 " + 
         "54 d1 3c d9 fe 0d 9d a5 " + 
         "94 a9 7e e2 02 30 f1 2f " + 
         "b5 43 4d e7 3f b4 f8 10 " + 
         "27 25 a0 16 22 b3 1b 1e " + 
         "a4 2e 3a 26 50 19 03 9a " + 
         "c1 df 31 86 9b d9 79 30 " + 
         "d7 92 fb 72 cd aa 97 1d " + 
         "8a 80 15 af"

nPrime = Hpmbmath.FermatTest(strHex, 4)
if (nPrime == 1) {
    Hpmbmath.Output("strHex is a prime.")
}
else if (nPrime == 0) {
    Hpmbmath.Output("strHex is not a prime.")
}
else {
    Hpmbmath.Output("internal error.")
}

To run a script

Here are the general steps to run a script under Hpmbcalc Scripting Host:

  1. From the Script menu, choose Run Scripts... to start Hpmbcalc Scripting Host console.
  2. Edit your script in the Input Script box, or load a script file into the box by clicking the Browse... button.
  3. Set the language that your script uses by selecting the VBScript button or the JScript button.
  4. Click the Execute button to run your script.