home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cenvi23.zip / TEXTWIN.CMD < prev    next >
OS/2 REXX Batch file  |  1995-02-14  |  3KB  |  107 lines

  1. EXTPROC CEnvi2
  2. //****************************************************************
  3. //*** TextWin.cmd - Get text from, or put text into a windowed ***
  4. //*** ver.5         OS/2 or DOS session by session name.       ***
  5. //****************************************************************
  6.  
  7. Instructions()
  8. {
  9.    puts("\a")
  10.    puts(`TextWin - GET/PUT text from/into a DOS or OS/2 session`)
  11.    puts(``)
  12.    puts(`SYNTAX: TextWin [OPTIONS} <Name> [Text]`)
  13.    puts(``)
  14.    puts(`WHERE: Name - Partial matching title of windowed session. If using FSSlave or`)
  15.    puts(`              DOSSlave options then this is the name for those slaves`)
  16.    puts(`       Text - Text to send to window, if not supplied then will get`)
  17.    puts(`              text from window and display.  End in \r to send`)
  18.    puts(`              carriage-return`)
  19.    puts(`OPTIONS: /DOSSlave - Send keys to DOS session running SERVEOS2.COM;`)
  20.    puts(`                     Note: cannot read text from SERVEOS2.COM method`)
  21.    puts(`         /FSSlave - Send keys to full-screen OS/2 session running FSSlave.cmm`)
  22.    puts(``)
  23.    puts(`Examples: TextWin "DOS Window"`)
  24.    puts(`          TextWin "OS/2 Win" "Hello"`)
  25.    puts(`          TextWin "OS/2 Win" "Dir c:\*.*\r"`)
  26.    puts(`          TextWin /FSSlave NOTES QUIT\r`)
  27.    puts(``)
  28. }
  29.  
  30. #include <TextBoss.lib>
  31. #include <OptParms.lib>
  32.  
  33. main(argc,argv)
  34. {
  35.    FSSlave = OptionalParameter(argc,argv,"FSSlave");
  36.    DOSSlave = OptionalParameter(argc,argv,"DOSSlave");
  37.    SessionTitle = argv[1];
  38.    if ( argc == 2 ) {
  39.       if ( FSSlave )
  40.          FullOS2TextGet(SessionTitle);
  41.       else if ( DOSSlave )
  42.          DOSSlaveTextGet(SessionTitle);
  43.       else
  44.          WinTextGet(SessionTitle);
  45.    } else if ( argc == 3 ) {
  46.       Text = argv[2];
  47.       // if text ends in carriage return '\r' then add a real carriage return
  48.       if ( !stricmp("\\r",Text + strlen(Text) - 2) )
  49.          strcpy(Text + strlen(Text) - 2,"\r");
  50.       if ( FSSlave )
  51.          FullOS2TextPut(SessionTitle,Text);
  52.       else if ( DOSSlave )
  53.          DOSSlaveTextPut(SessionTitle,Text);
  54.       else
  55.          WinTextPut(SessionTitle,Text);
  56.    } else
  57.       Instructions();
  58. }
  59.  
  60. WinTextGet(SessionTitle)
  61. {
  62.    if ( !(Data = ReadTextWindow(SessionTitle)) )
  63.       printf("\aCould not read data from session \"%s\"\n",SessionTitle);
  64.    else {
  65.       DataLines = CopyTextBufferToLines(Data,LineCount);
  66.       for ( i = 0; i < LineCount; i++ )
  67.          printf("\n%s",DataLines[i]);
  68.    }
  69. }
  70.  
  71. WinTextPut(SessionTitle,Text)
  72. {
  73.    if ( !GetWindowHandle(SessionTitle) )
  74.       printf("\aCould not find session \"%s\"\n",SessionTitle);
  75.    else {
  76.       // send this text to the window
  77.       PasteToTextWindow(SessionTitle,Text);
  78.    }
  79. }
  80.  
  81. FullOS2TextGet(QueueName)
  82. {
  83.    if ( !(Data = ReadFullOS2Text(QueueName,Col,Row,10000)) )
  84.       printf("\aCould not find FSSlave \"%s\"\n",QueueName);
  85.    else
  86.       puts(Data);
  87. }
  88.  
  89. FullOS2TextPut(QueueName,Text)
  90. {
  91.    if ( !SendFullOS2Key(QueueName,Text) )
  92.       printf("\aError sending to full-screen FSSlave \"%s\"\n",QueueName);
  93. }
  94.  
  95. DosSlaveTextGet(SlaveName)
  96. {
  97.    printf("\aCannot read DOS screen via SERVEOS2.COM.\n");
  98. }
  99.  
  100. DosSlaveTextPut(SlaveName,Text)
  101. {
  102.    if ( !SendDOSKey(SlaveName,Text) )
  103.       printf("\aError sending to DOS ServeOS2 \"%s\"\n",SlaveName);
  104. }
  105.  
  106.  
  107.