home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / os2 / pmsw2.zip / CSOURCE / PMSW2 / PMSW2.INF (.txt) < prev    next >
OS/2 Help File  |  1993-04-20  |  14KB  |  150 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. Function and Command Line Syntax ΓòÉΓòÉΓòÉ
  3.  
  4. PMSW2 is used in REXX programs to switch desktop focus to an application whose 
  5. name appears in the DESKTOP switch list. 
  6.  
  7. PMSW2 is called as a REXX function with two arguments: 
  8.  
  9.  1. Name mask of task in switch list 
  10.  
  11.  2. Optional "/r" switch to suppress actual focus change 
  12.  
  13. If the string passed as the first argument matches a name in the WorkPlace 
  14. Shell "Switch List" that is made the focus with the Ctrl+Esc keys, then that 
  15. task is given the focus with a call to WinSwitchToProgram.  The name mask may 
  16. contain - usually does contain - wild card characters.  These characters are 
  17. the asterisk and question mark, and they have their usual DOS command line 
  18. meanings. 
  19.  
  20. o * wild card matches zero or more characters 
  21.  
  22. o ? wild card matches exactly one character 
  23.  
  24. Mask=*ABC*
  25. This mask matches a name containing the letters ABC. 
  26.  
  27. Mask=*A*B*C*
  28. This mask matches a name containing the letters A, B, C, but not necessarily 
  29. next to each other. 
  30.  
  31.  
  32. ΓòÉΓòÉΓòÉ 2. Sample Application ΓòÉΓòÉΓòÉ
  33.  
  34. PMSW2 can be used to launch a DOS program from an OS/2 REXX and switch control 
  35. to it. The REXX can contain logic such that, if the target DOS application is 
  36. already active when the REXX begins, the DOS application receives the focus 
  37. instead of the REXX starting another DOS application window. This is important 
  38. to PC LAN administrators who want to place central applications on the LAN but 
  39. who need to provide OS/2 users with the tools to automatically acquire LAN 
  40. connection to the application, tailoring the DOS startup parameters for the 
  41. target application so that its environment, PATH, etc. are properly 
  42. initialized. 
  43.  
  44. At the author's customer's site, the CCMAIL application resides on the LAN.  A 
  45. MAIL program folder can be defined on the desktop that invokes the MAIL.CMD 
  46. REXX program.  This program tests to see if the target CCMAIL application is 
  47. now active, and switches focus to it if so. If the CCMAIL application is not 
  48. active, then MAIL.CMD REXX checks to see if the user is now logged onto the LAN 
  49. (a LOGON command has been done), and if the CCMAIL LAN drive has been connected 
  50. before issuing a START command for CCMAIL and switching focus to it. 
  51.  
  52. The logic for starting a DOS application: 
  53.  
  54. RESULT=PMSW2('*APPNAMESTRING*','/R');
  55. IF RESULT='READY:' THEN DO;
  56.    RESULT=PMSW2('*APPNAMESTRING*');
  57.    IF RESULT='FOCUS:' THEN EXIT;
  58.    SAY 'COULD NOT SWITCH FOCUS'
  59.    EXIT;
  60. END;
  61. 'START "APPNAMESTRING" /C /MIN DOSAPP.EXE'
  62. /* OR START A REXX TO DEFINE A DOS OBJECT WITH OPEN=PROGRAM */
  63. BSUCCESS=0;
  64. DO WHILE BSUCCESS<1;
  65.    RESULT=PMSW2('*APPNAMESTRING*','/R');
  66.    IF RESULT='READY:' THEN BSUCCESS=1;
  67.    ELSE CALL SYSSLEEP(2); /* WAIT FOR 2 SECONDS OR SO */
  68.    /* PUT A LIMIT ON CALLS HERE */
  69. END;
  70.  
  71.  
  72. ΓòÉΓòÉΓòÉ 3. Technical Details ΓòÉΓòÉΓòÉ
  73.  
  74. Processing outline: 
  75.  
  76.  1. PMSW2 is defined as a Rexx function handler 
  77.  
  78.  2. It examines the input parameters to see if there is a task name and 
  79.     optional /r flag. 
  80.  
  81.  3. It requests a count of items in the switch list using WinQuerySwitchList. 
  82.  
  83.  4. It allocates memory to hold the full switch list array. 
  84.  
  85.  5. It requests return of items in the switch list using WinQuerySwitchList. 
  86.  
  87.  6. It scans the entries in the switch list array and matches the name mask 
  88.     given against each item. 
  89.  
  90.  7. The MSKCHK function supports use of multiple "*" and "?" wild cards with 
  91.     the usual meanings 
  92.  
  93.  8. On finding a name match, if the /r switch was used, the REXX return string 
  94.     value is set to READY:, else the REXX return string value is set to FOCUS:. 
  95.  
  96.  9. If FOCUS:, then call WinSwitchToProgram using the switch list entry handle 
  97.     in the SWCNTRL structure of the matching switch list entry. 
  98.  
  99. 10. RETURN from PMSW2 to the REXX program that invoked it. 
  100.  
  101. Note that return is immediate, regardless of change in focus. The calling REXX 
  102. program continues execution while the user sees the focus change to the target 
  103. task. To the person at the keyboard, it appears as though the REXX program 
  104. window, if visible, has been replaced by the target application window, which 
  105. now has the keyboard focus. 
  106.  
  107.  
  108. ΓòÉΓòÉΓòÉ 4. Author & Legal Stuff ΓòÉΓòÉΓòÉ
  109.  
  110.  
  111. ΓòÉΓòÉΓòÉ 4.1. Copyright ΓòÉΓòÉΓòÉ
  112.  
  113. Copyright (C) 1993 by Bruce E. H╨ñgman. All Rights Reserved. PMSW2 may be used 
  114. by any person, corporation, or government agency without cost.  PMSW2 may be 
  115. distributed by any computer bulletin board service (BBS), including but not 
  116. limited to Compuserve, BIX, and Prodigy, provided that no fees are charged for 
  117. this distribution other than usual and customary line or session connect 
  118. charges, or charges usual and customary for shipping and handling of magnetic 
  119. media and documentation. 
  120.  
  121.  
  122. ΓòÉΓòÉΓòÉ 4.2. Author ΓòÉΓòÉΓòÉ
  123.  
  124. PMSW2 was developed for the US Dept of Energy, Energy Information 
  125. Administration (EIA), Forrestal Bldg. MailStop EI-10, 1000 Independence Ave. 
  126. S.W., Washington DC 20585, (202) 586-1965 by Bruce E. H╨ñgman of Electronic Data 
  127. Systems Corporation (EDS). The author can be reached via Compuserve 72050,1327 
  128. or at the above mailing address. 
  129.  
  130. The author was an instructor in computer sciences while on active duty with the 
  131. Air Force during the Vietnam years, and has been programming since 1965 on 
  132. every type of weird iron, stranger operating systems, and most popular and 
  133. arcane programming languages. He's proudest of having taught US Marines at 
  134. Quantico Virginia. 
  135.  
  136.  
  137. ΓòÉΓòÉΓòÉ 4.3. Warranty ΓòÉΓòÉΓòÉ
  138.  
  139. This software is provided without warranty as a public service by the author. 
  140. Neither the author, nor the federal government or EDS Corporation makes any 
  141. guarantee as to the usefulness of this software or its correct operation. 
  142.  
  143.  
  144. ΓòÉΓòÉΓòÉ <hidden> EIA OS/2 Application ΓòÉΓòÉΓòÉ
  145.  
  146.  
  147. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  148.  
  149. The "*" means zero or more characters in this position, and "?" means exactly 
  150. one character in this