home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Raytrace & Morphing / SOS-RAYTRACE.ISO / programm / best_66 / hawtd1 / dowjones.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-28  |  3.1 KB  |  113 lines

  1. /* This program dowjones.c created by Hilgraeve and assigned to the DowJones session*/
  2. /* runs an automated logon script for connecting to Dow Jones.                  */
  3.  
  4. /*    $Revision: 1.2 $  */
  5. /*    $Date: 1993/10/28 08:35:27 $  */
  6.  
  7. /* Define main function, which is always the starting point of C programs. */
  8. /* (The term "void" indicates that the function returns no value.) */
  9. void main()
  10.     {
  11.     /* Declare variables */
  12.     long ScriptHandle;
  13.     int ReturnValue;
  14.     char Buffer[128], LogLine[128];
  15.  
  16.     /* Initialize variables */
  17.     ReturnValue = 0;
  18.     ScriptHandle = 0;
  19.  
  20.     /* Establish a link between this script program and HA/Win */
  21.     ScriptHandle = haInitialize(0,0,0,0);
  22.  
  23.     /* Exit if intialization of link with HA/Win failed */
  24.     if (ScriptHandle == 0) exit();
  25.  
  26.     /* Set local echo on */
  27.     ReturnValue = haSetLocalEcho(ScriptHandle, 1);
  28.  
  29.     /* Type a '@' then <enter> */
  30.     if (ReturnValue >= 0)
  31.         ReturnValue = haTypeText(ScriptHandle, 0, "@");
  32.  
  33.     /* Pause */
  34.     if (ReturnValue >= 0)
  35.         haSleep(ScriptHandle, 1000L);
  36.  
  37.     /* Type a  <enter> */
  38.     if (ReturnValue >= 0)
  39.         ReturnValue = haTypeText(ScriptHandle, 0, "\r");
  40.  
  41.     /* Turn local echo off */
  42.     if (ReturnValue >= 0)
  43.         ReturnValue = haSetLocalEcho(ScriptHandle, 0);
  44.  
  45.     /* Wait for one of three prompts possible with Tymenet or Telenet */
  46.     if (ReturnValue >= 0)
  47.         ReturnValue = haWaitForPrompt(ScriptHandle, 3, "ERMINAL=\0r name: \0identifier", 300L, 32000L);
  48.  
  49.     /* If Tymenet do this block */
  50.     if (ReturnValue == 0)
  51.         {
  52.         /* Type an <enter> */
  53.         ReturnValue = haTypeText(ScriptHandle, 0, "\r");
  54.  
  55.         /* Wait for a prompt */
  56.         if (ReturnValue >= 0)
  57.             ReturnValue = haWaitForPrompt(ScriptHandle, 1, "\r\n\r\n@", 300L, 32000L);
  58.  
  59.         /* Type text to request Dow Jones */
  60.         if (ReturnValue >= 0)
  61.             ReturnValue = haTypeText(ScriptHandle, 0, "c dow\r");
  62.         }
  63.     /* If Telenet do this block */
  64.     else
  65.         {
  66.         /* Type an 'a' */
  67.         ReturnValue = haTypeText(ScriptHandle, 0, "a");
  68.  
  69.         /* Wait for a prompt */
  70.         if (ReturnValue >= 0)
  71.             ReturnValue = haWaitForPrompt(ScriptHandle, 1, "log in: ", 300L, 32000L);
  72.  
  73.         /* Type text requesting Dow Jones */
  74.         if (ReturnValue >= 0)
  75.             ReturnValue = haTypeText(ScriptHandle, 0, "dow1;;");
  76.         }
  77.  
  78.     /* Wait for a prompt */
  79.     if (ReturnValue >= 0)
  80.         ReturnValue = haWaitForPrompt(ScriptHandle, 1, "SE????\r\n", 300L, 32000L);
  81.  
  82.     /* Type text to request Dow Jones */
  83.     if (ReturnValue >= 0)
  84.         ReturnValue = haTypeText(ScriptHandle, 0, "djns\r");
  85.  
  86.     /* Pause */
  87.     if (ReturnValue >= 0)
  88.         ReturnValue = haSleep(ScriptHandle, 2000L);
  89.  
  90.     /* Get Password value from Runtime Values dialog box and add to logline */
  91.     if (ReturnValue >= 0)
  92.         {
  93.         ReturnValue = haGetRuntimeValue(ScriptHandle, 3, 1, 128, Buffer);
  94.         strncat(LogLine, Buffer, strlen(Buffer)-1);
  95.         }
  96.  
  97.     /* Get User ID value from Runtime Values dialog box and add to logline */
  98.     if (ReturnValue >= 0)
  99.         {
  100.         ReturnValue = haGetRuntimeValue(ScriptHandle, 2, 1, 128, Buffer);
  101.         strcat(LogLine, Buffer);
  102.         }
  103.  
  104.     /* Type the logline */
  105.     if (ReturnValue >= 0)
  106.         ReturnValue = haTypeText(ScriptHandle, 0, LogLine);
  107.  
  108.     /* Terminate link between HA/Win and script program */
  109.     haTerminate(ScriptHandle, 0);
  110.     }
  111.  
  112.  
  113.