⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 idspcli.jse

📁 javascript source code part2
💻 JSE
字号:
//~    title: Simple iDSP Client Script

   /*
      Copyright 1999 by Ronald Terry Constant
      http://www.rtconstant.com
   */

   /*.
idspcli.jse
    syntax: sewin32.exe idspcli.jse [host] [port]
     where: host - the Internet address (IP/URL/Computer name) of the
            computer running an iDSP server script. Default is "localhost".
            port - Port to which to listen for internet connection.
            Default is DEFAULT_IDSP_PORT (defined as 1066 in idsp.jsh).
      desc: This script starts a connection with a computer that is running
            an iDSP server script. The connection is accomplished using
            Internet protocol. The purpose of the connection is to run
            ScriptEase commands on the host/server computer by means of
            distributed scripting.

            This script is simple and sends several simple statements to be
            executed on the server computer.
   example:    // Start idsp client on default port 1066
            sewin32.exe idspcli.jse
               // Start idsp client, specifying the default port
            secon32.exe idspcli.jse 1066
               // Start idsp client, specifying another port. If the default
               // is not used, then the server script must specify the
               // same port.
            secon32.exe idspcli.jse 1011
   .*/

#include "idsp.jsh"

function main(argc, argv)
{
      // Get host IP/URL/Computer name and port, or defaults
      // Use the conditional operators to set host and port values
   var host = (argv[1]) ? argv[1] : "localhost";
   var port = (argv[2]) ? Number(argv[2]) : DEFAULT_IDSP_PORT;

   var connection = new iDSP(host, port);
   if(connection != null)
   {
         // If a connection is made, send the following commands

         // Display a hello message on the host/server computer
      connection.Screen.writeln("Hello from idspClient!");
         // Include write.jsh, which has enhanced write methods, and display
         // a message, using one of the methods, on the host computer.
      connection.eval(`#include "write.jsh"; Writeln("write.jsh was included");`);
         // Run multiple statments as if they were script on the host
         // computer.
      var ScriptLines =
         `Screen.writeln("This is line one");`
         `Screen.writeln("This is line two");`
         `Screen.writeln("This is line three");`;
      connection.eval(ScriptLines);
         // Execute an external program on the host computer, assuming that
         // the host computer has the program "Notepad.exe".
      connection.SElib.spawn(P_NOWAIT, "Notepad.exe");

         // Close this current connection. The host will continue to listen
         // to port for other connections/scripts.
      connection.dspClose();
   }
   else
   {
         // Show error message
      throw "Unable to connect to " + host + ":" + port;
   }
} //main

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -