home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxipc.zip / REXXIPC.INF (.txt) < prev    next >
OS/2 Help File  |  1996-01-14  |  65KB  |  3,353 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. Copyright (c) Serge Brisson 1994, 1995 ΓòÉΓòÉΓòÉ
  3.  
  4. Copyright (c) Serge Brisson 1994, 1995.  All rights reserved. 
  5.  
  6.  
  7. Distribution 
  8.  
  9. The copyright owner allows the free distribution of the following files, as 
  10. long as they are kept together, unmodified: 
  11.  
  12.    o REXXIPC.DLL -- The library. 
  13.    o REXXIPC.INF -- The documentation. 
  14.    o REXXIPC.TXT -- Distribution text. 
  15.    o TESTIPC.CMD -- A test program. 
  16.    o TESTIPC.CFG -- A test configuration. 
  17.    o FILE_ID.DIZ -- Identification. 
  18.  
  19.  
  20. ΓòÉΓòÉΓòÉ 2. Introduction ΓòÉΓòÉΓòÉ
  21.  
  22. The RexxIPC library provides access to OS/2 Inter Process Communication 
  23. capabilities for Rexx programs. Threads, named pipes, semaphores (event, mutex 
  24. and muxwait) and queues are supported. 
  25.  
  26. The design requirements for this library specified support of multi-threaded 
  27. Rexx applications, support of access to the same IPC services by other C or C++ 
  28. functions, simplicity of use and non-interference in the application's design. 
  29.  
  30. Since the underlying system services already meet these requirements, the 
  31. library's design is mostly a straightforward Rexx interface to these services. 
  32. This document is supplied as a reference to this interface.  It assumes that 
  33. the reader has access to the Control Program Guide and Reference from the 
  34. Developer's Toolkit for OS/2. 
  35.  
  36. Note:   The explicit use of system handles in the Pipe interface allows the 
  37.         access to multiple instances of the same pipe (useful in a 
  38.         multi-threaded environment). 
  39.  
  40. The explicit use of system handles in the Semaphore interface allows the use of 
  41. unnamed semaphores. 
  42.  
  43.  
  44. ΓòÉΓòÉΓòÉ 3. IPC Procedures and Functions ΓòÉΓòÉΓòÉ
  45.  
  46. The IPC prefix identifies a few generic routines related to the operation of 
  47. the library. 
  48.  
  49. The IPCLoadFuncs and IPCDropFuncs register and deregister all the external 
  50. routines.  It is possible to be more specific by using the PipeLoadFuncs, 
  51. SemLoadFuncs and PipeDropFuncs, SemLoadFuncs procedures. 
  52.  
  53. The IPCVersion function returns a version identification string. 
  54.  
  55. The IPCContext functions are used to support threads and asynchronous services. 
  56.  
  57.  
  58. ΓòÉΓòÉΓòÉ 3.1. IPCContextClose function ΓòÉΓòÉΓòÉ
  59.  
  60.  
  61. Syntax 
  62.  
  63. rc = IPCContextClose(ctxHandle) 
  64.  
  65. Description 
  66.  
  67. IPCContextClose is used to free the memory resources consumed by the IPC 
  68. Context structure. 
  69.  
  70. Arguments 
  71.  
  72. ctxHandle      as obtained from IPCCreateContext. 
  73.  
  74.  Returns 
  75.  
  76.  IPCContextClose returns 0. 
  77.  
  78.  Notes 
  79.  
  80.  If a thread is still associated with the context when IPCContextClose is 
  81.  called, that thread is killed. 
  82.  
  83.  See also 
  84.  
  85.  IPCContextCreate. 
  86.  
  87.  Examples 
  88.  
  89.  To close an IPC Context: 
  90.  
  91.       call IPCContextClose myContext
  92.       if result \= 0 then signal ContextCloseError
  93.  
  94.  
  95. ΓòÉΓòÉΓòÉ 3.2. IPCContextCreate function ΓòÉΓòÉΓòÉ
  96.  
  97.  
  98. Syntax 
  99.  
  100. rc = IPCContextCreate(handleVar, [ semHandle ]) 
  101.  
  102. Description 
  103.  
  104. IPCContextCreate is used to create a context for the execution of an 
  105. asynchronous (multi-threaded) function.  This context holds the completion 
  106. status and may hold an event semaphore handle to signal the completion of the 
  107. requested function.  It will also hold the result string returned by a thread 
  108. started with ProcCreateThread. 
  109.  
  110. Arguments 
  111.  
  112.  handleVar      is the name of the variable which is to receive the handle to 
  113.                 the allocated context. 
  114.  
  115.  semHandle      is the handle of the event semaphore which will be used to 
  116.                 signal the completion of the asynchronous function.  If this 
  117.                 semaphore is not supplied, the function IPCContextWait may be 
  118.                 used to wait for completion. 
  119.  
  120.  Returns 
  121.  
  122.  IPCContextCreate returns 0. 
  123.  
  124.  Notes 
  125.  
  126.  An IPCContext is a structure local to the RexxIPC library.  It consumes a few 
  127.  bytes and an internal event semaphore in the current process.  The memory and 
  128.  the semaphore is released by a call to IPCContextClose. 
  129.  
  130.  The internal event semaphore is used for thread synchronization and is not 
  131.  related to the optional semaphore supplied as an argument to this function. 
  132.  
  133.  See also 
  134.  
  135.  IPCContextClose, SemEventCreate, PipeConnectAsync, ProcCreateThread. 
  136.  
  137.  Examples 
  138.  
  139.  To create an IPC Context: 
  140.  
  141.       call SemEventCreate 'myContextEvent'
  142.       if result \= 0 then signal SemCreateError
  143.       call IPCContextCreate 'myContext', myContextEvent
  144.       if result \= 0 then signal ContextCreateError
  145.       .
  146.       .
  147.       .
  148.       call IPCContextClose myContext
  149.       if result \= 0 then signal ContextCloseError
  150.       call SemEventClose myContextEvent
  151.       if result \= 0 then signal SemCloseError
  152.  
  153.  
  154. ΓòÉΓòÉΓòÉ 3.3. IPCContextQuery function ΓòÉΓòÉΓòÉ
  155.  
  156.  
  157. Syntax 
  158.  
  159. rc = IPCContextQuery(ctxHandle, [ threadVar ]) 
  160.  
  161. Description 
  162.  
  163. IPCContextQuery is used to get the completion code of the last thread 
  164. associated with the context.  If the thread is still active, the system Id may 
  165. be returned in an optional parameter. 
  166.  
  167. Arguments 
  168.  
  169.  ctxHandle      as obtained from IPCCreateContext. 
  170.  
  171.  threadVar      is the name of the variable which is to receive the system Id 
  172.                 of the thread active on the context.  If there is no such 
  173.                 thread, the value will be 0 (zero). 
  174.  
  175.  Returns 
  176.  
  177.  IPCContextQuery returns the completion code. 
  178.  
  179.  Notes 
  180.  
  181.  If a thread is still active on the context, IPCContextQuery will return the 
  182.  code ERROR_BUSY (170).  It will also put a non-zero value in the optional 
  183.  variable parameter. 
  184.  
  185.  See also 
  186.  
  187.  IPCContextCreate, IPCContextWait. 
  188.  
  189.  Examples 
  190.  
  191.  To query an IPC Context used in a PipeConnectAsync: 
  192.  
  193.       call IPCContextQuery myContext
  194.       if result \= 0 then signal PipeConnectError
  195.  
  196.  To query an IPC Context used in a ProcCreateThread: 
  197.  
  198.       call IPCContextQuery myContext, 'threadId'
  199.       if result = 170 then say 'Thread' threadId 'is still active.'
  200.       else say 'Thread completed with return code' result'.'
  201.  
  202.  
  203. ΓòÉΓòÉΓòÉ 3.4. IPCContextResult function ΓòÉΓòÉΓòÉ
  204.  
  205.  
  206. Syntax 
  207.  
  208. threadResult = IPCContextResult(ctxHandle) 
  209.  
  210. Description 
  211.  
  212. IPCContextResult is used to get the string returned by the thread associated 
  213. with the context. 
  214.  
  215. Arguments 
  216.  
  217.  ctxHandle      as obtained from IPCCreateContext. 
  218.  
  219.  Returns 
  220.  
  221.  IPCContextResult returns the string produced by the last Rexx thread 
  222.  associated with the context.  It will return a null string if the thread is 
  223.  still active or did not return a string. 
  224.  
  225.  See also 
  226.  
  227.  IPCContextCreate, IPCContextQuery, IPCContextWait, ProcCreateThread. 
  228.  
  229.  Examples 
  230.  
  231.  To get the result from the last thread started by ProcCreateThread: 
  232.  
  233.       call IPCContextResult myContext
  234.       say 'The thread returned: "'result'".'
  235.  
  236.  
  237. ΓòÉΓòÉΓòÉ 3.5. IPCContextWait function ΓòÉΓòÉΓòÉ
  238.  
  239.  
  240. Syntax 
  241.  
  242. rc = IPCContextWait(ctxHandle) 
  243.  
  244. Description 
  245.  
  246. IPCContextWait is used to wait for the thread associated with the context and 
  247. get the completion code.  If the thread has already completed execution at the 
  248. time of the call, there will be no wait but the completion code will be 
  249. returned. 
  250.  
  251. Arguments 
  252.  
  253.  ctxHandle      as obtained from IPCCreateContext. 
  254.  
  255.  Returns 
  256.  
  257.  IPCContextWait returns the completion code. 
  258.  
  259.  Notes 
  260.  
  261.  After IPCContextWait returns, IPCContextResult may be called to get the string 
  262.  (if any) returned by the thread. 
  263.  
  264.  See also 
  265.  
  266.  IPCContextCreate, IPCContextQuery, IPCContextResult, ProcCreateThread. 
  267.  
  268.  Examples 
  269.  
  270.  To wait for an IPC Context used in a PipeConnectAsync: 
  271.  
  272.       call IPCContextWait myContext
  273.       if result \= 0 then signal PipeConnectError
  274.  
  275.  
  276. ΓòÉΓòÉΓòÉ 3.6. IPCDropFuncs procedure ΓòÉΓòÉΓòÉ
  277.  
  278.  
  279. Syntax 
  280.  
  281. call IPCDropFuncs 
  282.  
  283. Description 
  284.  
  285. IPCDropFuncs deregisters all the library procedures and functions. 
  286.  
  287. Arguments 
  288.  
  289. No arguments are required by IPCDropFuncs. 
  290.  
  291. Returns 
  292.  
  293. Nothing is returned by IPCDropFuncs. 
  294.  
  295. Notes 
  296.  
  297. IPC procedures and functions may be deregistered individually.  IPCDropFuncs is 
  298. only a shortcut to have them all deregistered with one call. 
  299.  
  300. See also 
  301.  
  302. IPCLoadFuncs, PipeLoadFuncs, PipeDropFuncs, ProcLoadFuncs, ProcDropFuncs, 
  303. SemLoadFuncs, SemDropFuncs. 
  304.  
  305.  
  306. ΓòÉΓòÉΓòÉ 3.7. IPCLoadFuncs procedure ΓòÉΓòÉΓòÉ
  307.  
  308.  
  309. Syntax 
  310.  
  311. call IPCLoadFuncs 
  312.  
  313. Description 
  314.  
  315. IPCLoadFuncs registers all the library procedures and functions. 
  316.  
  317. Arguments 
  318.  
  319. No arguments are required by IPCLoadFuncs. 
  320.  
  321. Returns 
  322.  
  323. Nothing is returned by IPCLoadFuncs. 
  324.  
  325. Notes 
  326.  
  327. IPC procedures and functions must be registered before they can be used.  They 
  328. may be registered individually.  IPCLoadFuncs is only a shortcut to have them 
  329. all registered with one call. 
  330.  
  331. See also 
  332.  
  333. IPCDropFuncs, PipeLoadFuncs, PipeDropFuncs, ProcLoadFuncs, ProcDropFuncs, 
  334. SemLoadFuncs, SemDropFuncs. 
  335.  
  336. Examples 
  337.  
  338. To register all the RexxIPC functions: 
  339.  
  340.     call RxFuncAdd 'IPCLoadFuncs', 'REXXIPC', 'IPCLoadFuncs'
  341.     call IPCLoadFuncs
  342.  
  343.  
  344. ΓòÉΓòÉΓòÉ 3.8. IPCVersion function ΓòÉΓòÉΓòÉ
  345.  
  346.  
  347. Syntax 
  348.  
  349. versionString = IPCVersion() 
  350.  
  351. Description 
  352.  
  353. IPCVersion may be used to identify the version of the IPC library. 
  354.  
  355. Arguments 
  356.  
  357. No arguments are required by IPCVersion. 
  358.  
  359. Returns 
  360.  
  361. IPCVersion currently returns a string with the format producer product 
  362. major.minor-revision but this may change in the future. 
  363.  
  364.  
  365. ΓòÉΓòÉΓòÉ 4. Pipe Procedures and Functions ΓòÉΓòÉΓòÉ
  366.  
  367. The Pipe prefix identifies named pipe related functions.  Some of these are not 
  368. pipe specific in the operating system implementation (like DosRead used by 
  369. PipeRead, or DosClose used by PipeClose), but are needed for pipe operations. 
  370.  
  371. Some functions are most often used by the server side of an application (like 
  372. PipeCreate, PipeConnect and PipeDisconnect), while others are used by the 
  373. client side (like PipeOpen, PipeWait, PipeCall and PipeTransact). 
  374.  
  375. The "Control Program Guide and Reference" (Developer's Toolkit for OS/2) or 
  376. "Client/Server Programming with OS/2" (Van Nostrand Reinhold) are valuable 
  377. sources of information. 
  378.  
  379. Note:   The pipe handle mentionned in the individual Pipe functions description 
  380.         is the actual value used by the operating system, converted to an 
  381.         unsigned decimal number character string.  It is not associated with 
  382.         internal structures of the RexxIPC library and may be created/used by 
  383.         other modules of the same process. 
  384.  
  385.  
  386. ΓòÉΓòÉΓòÉ 4.1. PipeCall function ΓòÉΓòÉΓòÉ
  387.  
  388.  
  389. Syntax 
  390.  
  391. rc = PipeCall(name, output, inputVar, [ inputLimit ], [ timeout ]) 
  392.  
  393. Description 
  394.  
  395. PipeCall executes a call operation.  It combines the effect of PipeOpen, 
  396. PipeTransact and PipeClose. 
  397.  
  398. Arguments 
  399.  
  400.  name           specifies the name for the pipe. It must have the form: 
  401.  
  402.                     [\\serverName ]\PIPE\pipeName 
  403.  
  404.                 where: 
  405.  
  406.           serverName              is the name of the server on which the pipe 
  407.                                   has been created; 
  408.  
  409.           pipeName                is the actual name of the pipe. 
  410.  
  411.  output         is the string expression to be sent on the pipe. 
  412.  
  413.  inputVar       is the name of the variable which will receive the response. 
  414.  
  415.  inputLimit     is the size limit (in bytes) for the response.  If zero or 
  416.                 omitted, a default of 4096 is used. 
  417.  
  418.  timeout        is the wait timeout in milliseconds.  The default is 50.  This 
  419.                 timeout refers to the time the directive will wait for a pipe 
  420.                 instance to become available. 
  421.  
  422.  Returns 
  423.  
  424.  PipeCall returns the code supplied by the DosCallNPipe system directive. 
  425.  
  426.  Expected: 
  427.  
  428.     000 -- NO_ERROR 
  429.     002 -- ERROR_FILE_NOT_FOUND 
  430.     011 -- ERROR_BAD_FORMAT 
  431.     095 -- ERROR_INTERRUPT 
  432.     231 -- ERROR_PIPE_BUSY 
  433.  
  434.  Notes 
  435.  
  436.  The named pipe must have been created in duplex mode with message format. 
  437.  
  438.  See also 
  439.  
  440.  PipeOpen, PipeWait, PipeTransact, PipeClose. 
  441.  
  442.  Examples 
  443.  
  444.  To make a call on a named pipe: 
  445.  
  446.       call PipeCall '\PIPE\MY_PIPE', 'Hello?', 'answer'
  447.       if result \= 0 then signal PipeCallError
  448.       say 'Pipe answer: "'answer'".'
  449.  
  450.  
  451. ΓòÉΓòÉΓòÉ 4.2. PipeClose function ΓòÉΓòÉΓòÉ
  452.  
  453.  
  454. Syntax 
  455.  
  456. rc = PipeClose(pipeHandle) 
  457.  
  458. Description 
  459.  
  460. PipeClose closes a pipe.  It is called both for a created pipe (server side), 
  461. and for an opened pipe (client side). 
  462.  
  463. Arguments 
  464.  
  465.  pipeHandle     as obtained from PipeCreate or PipeOpen. 
  466.  
  467.  Returns 
  468.  
  469.  PipeClose returns the code supplied by the DosClose system directive. 
  470.  
  471.  Expected: 
  472.  
  473.     000 -- NO_ERROR 
  474.     006 -- ERROR_INVALID_HANDLE 
  475.  
  476.  See also 
  477.  
  478.  PipeCreate, PipeOpen. 
  479.  
  480.  Examples 
  481.  
  482.  To close a named pipe: 
  483.  
  484.       call PipeClose pipe
  485.       if result \= 0 then signal PipeCloseError
  486.  
  487.  
  488. ΓòÉΓòÉΓòÉ 4.3. PipeConnect function ΓòÉΓòÉΓòÉ
  489.  
  490.  
  491. Syntax 
  492.  
  493. rc = PipeConnect(pipeHandle) 
  494.  
  495. Description 
  496.  
  497. PipeConnect listens for a connection on a named pipe. 
  498.  
  499. Arguments 
  500.  
  501.  pipeHandle     as obtained from PipeCreate. 
  502.  
  503.  Returns 
  504.  
  505.  PipeConnect returns the code supplied by the DosConnectNPipe system directive. 
  506.  
  507.  Expected: 
  508.  
  509.     000 -- NO_ERROR 
  510.     095 -- ERROR_INTERRUPT 
  511.     109 -- ERROR_BROKEN_PIPE 
  512.     230 -- ERROR_BAD_PIPE 
  513.  
  514.  See also 
  515.  
  516.  PipeCreate, PipeConnectAsync, PipeOpen, PipeDisconnect. 
  517.  
  518.  Examples 
  519.  
  520.  To create a named pipe and listen for a connection: 
  521.  
  522.       call PipeCreate 'pipe', '\PIPE\MY_PIPE'
  523.       if result \= 0 then signal PipeCreateError
  524.  
  525.       call PipeConnect pipe
  526.       if result \= 0 then signal PipeConnectError
  527.  
  528.  To answer requests from PipeCall or PipeTransact calls: 
  529.  
  530.       call PipeCreate 'pipe', '\PIPE\MY_PIPE'
  531.       if result \= 0 then signal PipeCreateError
  532.  
  533.       do forever
  534.           call PipeConnect pipe
  535.           if result \= 0 then signal PipeConnectError
  536.  
  537.           do forever
  538.               call PipeRead pipe, 'request'
  539.               if result \= 0 then signal PipeReadError
  540.               if request = '' then leave
  541.               .
  542.               .
  543.               .
  544.               call PipeWrite pipe, 'answer'
  545.               if result \= 0 then signal PipeWriteError
  546.           end
  547.  
  548.           call PipeDisconnect pipe
  549.           if result \= 0 then signal PipeDisconnectError
  550.       end
  551.  
  552.  
  553. ΓòÉΓòÉΓòÉ 4.4. PipeConnectAsync function ΓòÉΓòÉΓòÉ
  554.  
  555.  
  556. Syntax 
  557.  
  558. rc = PipeConnectAsync(pipeHandle, ctxHandle) 
  559.  
  560. Description 
  561.  
  562. PipeConnectAsync listens for a connection on a named pipe. 
  563.  
  564. Arguments 
  565.  
  566.  pipeHandle     as obtained from PipeCreate. 
  567.  
  568.  ctxHandle      as obtained from IPCContextCreate. 
  569.  
  570.  Returns 
  571.  
  572.  PipeConnectAsync returns the code supplied by the DosCreateThread system 
  573.  directive. 
  574.  
  575.  Expected: 
  576.  
  577.     000 -- NO_ERROR 
  578.     008 -- ERROR_NOT_ENOUGH_MEMORY 
  579.     095 -- ERROR_INTERRUPT 
  580.     164 -- ERROR_MAX_THRDS_REACHED 
  581.  
  582.  See also 
  583.  
  584.  IPCContextCreate, PipeConnect, SemEventWait. 
  585.  
  586.  Examples 
  587.  
  588.  To create a pipe and start a process which will immediately open the pipe: 
  589.  
  590.       call PipeCreate 'pipe', '\PIPE\REDIRECTED_INPUT'
  591.       if result \= 0 then signal PipeCreateError
  592.  
  593.       call IPCContextCreate 'context'
  594.       if result \= 0 then signal ContextCreateError
  595.  
  596.       call PipeConnectAsync pipe, context
  597.       if result \= 0 then signal PipeConnectAsyncError
  598.  
  599.       'DETACH RED_PROC <\PIPE\REDIRECTED_INPUT >NUL'
  600.  
  601.       call IPCContextWait context
  602.       if result \= 0 then signal PipeConnectError
  603.  
  604.  
  605. ΓòÉΓòÉΓòÉ 4.5. PipeCreate function ΓòÉΓòÉΓòÉ
  606.  
  607.  
  608. Syntax 
  609.  
  610. rc = PipeCreate(handleVar, name, [ mode ], [ format ], [ instances ], 
  611. [ outBufSize ], [ inpBufSize ], [ timeout ]) 
  612.  
  613. Description 
  614.  
  615. PipeCreate is used to create a named pipe. 
  616.  
  617. Arguments 
  618.  
  619.  handleVar      is the name of a variable which will receive the handle to the 
  620.                 named pipe. 
  621.  
  622.  name           specifies the name for the pipe. It must have the form: 
  623.  
  624.                     \PIPE\pipeName 
  625.  
  626.                 where: 
  627.  
  628.           pipeName                is the actual name of the pipe. 
  629.  
  630.  mode           is the pipe access mode.  If present, it must be one of the 
  631.                 following keywords: 
  632.  
  633.           Inbound                 for an inbound pipe (receive only); 
  634.  
  635.           Outbound                for an outbound pipe (transmit only); 
  636.  
  637.           Duplex                  for a duplex pipe (transmit and receive), 
  638.                                   this is the default. 
  639.  
  640.                 The keywords are case insensitive and may be abbreviated. 
  641.  
  642.  format         is the pipe format.  If present, it must be one of the 
  643.                 following keywords: 
  644.  
  645.           Byte                    for a byte pipe (no implicit length); 
  646.  
  647.           Message                 for a message pipe (implicit length), this is 
  648.                                   the default. 
  649.  
  650.                 The keywords are case insensitive and may be abbreviated. 
  651.  
  652.  instances      is the maximum number of instances for this pipe.  It must be a 
  653.                 value between 1 and 255, or -1 (meaning no limit).  The default 
  654.                 is 1. 
  655.  
  656.  outBufSize     is the output buffer size.  The default is 1024. 
  657.  
  658.  inpBufSize     is the input buffer size.  The default is 1024. 
  659.  
  660.  timeout        is the default wait timeout in milliseconds.  The default is 
  661.                 50. 
  662.  
  663.  Returns 
  664.  
  665.  PipeCreate returns the code supplied by the DosCreateNPipe system directive. 
  666.  
  667.  Expected: 
  668.  
  669.     000 -- NO_ERROR 
  670.     003 -- ERROR_PATH_NOT_FOUND 
  671.     008 -- ERROR_NOT_ENOUGH_MEMORY 
  672.     084 -- ERROR_OUT_OF_STRUCTURES 
  673.     231 -- ERROR_PIPE_BUSY 
  674.  
  675.  Notes 
  676.  
  677.  If the return code is non-zero, handleVar is not created or modified. 
  678.  
  679.  See also 
  680.  
  681.  PipeOpen, PipeClose. 
  682.  
  683.  Examples 
  684.  
  685.  To create a named pipe: 
  686.  
  687.       call PipeCreate 'pipe', '\PIPE\MY_PIPE'
  688.       if result \= 0 then signal PipeCreateError
  689.  
  690.  
  691. ΓòÉΓòÉΓòÉ 4.6. PipeDisconnect function ΓòÉΓòÉΓòÉ
  692.  
  693.  
  694. Syntax 
  695.  
  696. rc = PipeDisconnect(pipeHandle) 
  697.  
  698. Description 
  699.  
  700. PipeDisconnect drops a connection on a named pipe. 
  701.  
  702. Arguments 
  703.  
  704.  pipeHandle     as obtained from PipeCreate. 
  705.  
  706.  Returns 
  707.  
  708.  PipeDisconnect returns the code supplied by the DosDisConnectNPipe system 
  709.  directive. 
  710.  
  711.  Expected: 
  712.  
  713.     000 -- NO_ERROR 
  714.     230 -- ERROR_BAD_PIPE 
  715.  
  716.  See also 
  717.  
  718.  PipeCreate, PipeConnect. 
  719.  
  720.  
  721. ΓòÉΓòÉΓòÉ 4.7. PipeDropFuncs procedure ΓòÉΓòÉΓòÉ
  722.  
  723.  
  724. Syntax 
  725.  
  726. call PipeDropFuncs 
  727.  
  728. Description 
  729.  
  730. PipeDropFuncs deregisters all the Pipe procedures and functions. 
  731.  
  732. Arguments 
  733.  
  734. No arguments are required by PipeDropFuncs. 
  735.  
  736. Returns 
  737.  
  738. Nothing is returned by PipeDropFuncs. 
  739.  
  740. Notes 
  741.  
  742. Pipe procedures and functions may be deregistered individually.  PipeDropFuncs 
  743. is only a shortcut to have them all deregistered with one call. 
  744.  
  745. IPCDropFuncs will by itself call PipeDropFuncs and deregister it. 
  746.  
  747. See also 
  748.  
  749. IPCDropFuncs, PipeLoadFuncs. 
  750.  
  751.  
  752. ΓòÉΓòÉΓòÉ 4.8. PipeFlush function ΓòÉΓòÉΓòÉ
  753.  
  754.  
  755. Syntax 
  756.  
  757. rc = PipeFlush(pipeHandle) 
  758.  
  759. Description 
  760.  
  761. PipeFlush flushes the write buffer of a named pipe.  It may be called both for 
  762. a created pipe (server side), and for an opened pipe (client side). 
  763.  
  764. Arguments 
  765.  
  766.  pipeHandle     as obtained from PipeCreate or PipeOpen. 
  767.  
  768.  Returns 
  769.  
  770.  PipeFlush returns the code supplied by the DosResetBuffer system directive. 
  771.  
  772.  Expected: 
  773.  
  774.     000 -- NO_ERROR 
  775.     005 -- ERROR_ACCESS_DENIED 
  776.     006 -- ERROR_INVALID_HANDLE 
  777.  
  778.  See also 
  779.  
  780.  PipeClose. 
  781.  
  782.  Examples 
  783.  
  784.  To flush a named pipe: 
  785.  
  786.       call PipeFlush pipe
  787.       if result \= 0 then signal PipeFlushError
  788.  
  789.  
  790. ΓòÉΓòÉΓòÉ 4.9. PipeLoadFuncs procedure ΓòÉΓòÉΓòÉ
  791.  
  792.  
  793. Syntax 
  794.  
  795. call PipeLoadFuncs 
  796.  
  797. Description 
  798.  
  799. PipeLoadFuncs registers all the Pipe procedures and functions. 
  800.  
  801. Arguments 
  802.  
  803. No arguments are required by PipeLoadFuncs. 
  804.  
  805. Returns 
  806.  
  807. Nothing is returned by PipeLoadFuncs. 
  808.  
  809. Notes 
  810.  
  811. Pipe procedures and functions must be registered before they can be used.  They 
  812. may be registered individually.  PipeLoadFuncs is only a shortcut to have them 
  813. all registered with one call. 
  814.  
  815. IPCLoadFuncs will by itself register and call PipeLoadFuncs. 
  816.  
  817. See also 
  818.  
  819. IPCLoadFuncs, PipeDropFuncs. 
  820.  
  821.  
  822. ΓòÉΓòÉΓòÉ 4.10. PipeOpen function ΓòÉΓòÉΓòÉ
  823.  
  824.  
  825. Syntax 
  826.  
  827. rc = PipeOpen(handleVar, name, [ mode ], [ format ]) 
  828.  
  829. Description 
  830.  
  831. PipeOpen is used to open a named pipe. 
  832.  
  833. Arguments 
  834.  
  835.  handleVar      is the name of a variable which will receive the handle to the 
  836.                 named pipe. 
  837.  
  838.  name           specifies the name for the pipe. It must have the form: 
  839.  
  840.                     [\\serverName ]\PIPE\pipeName 
  841.  
  842.                 where: 
  843.  
  844.           serverName              is the name of the server on which the pipe 
  845.                                   has been created; 
  846.  
  847.           pipeName                is the actual name of the pipe. 
  848.  
  849.  mode           is the pipe access mode.  If present, it must be one of the 
  850.                 following keywords: 
  851.  
  852.           Inbound                 for an inbound pipe (receive only); 
  853.  
  854.           Outbound                for an outbound pipe (transmit only); 
  855.  
  856.           Duplex                  for a duplex pipe (transmit and receive), 
  857.                                   this is the default. 
  858.  
  859.                 The keywords are case insensitive and may be abbreviated. 
  860.  
  861.  format         is the pipe format.  If present, it must be one of the 
  862.                 following keywords: 
  863.  
  864.           Byte                    for a byte pipe (no implicit length); 
  865.  
  866.           Message                 for a message pipe (implicit length), this is 
  867.                                   the default. 
  868.  
  869.                 The keywords are case insensitive and may be abbreviated. 
  870.  
  871.  Returns 
  872.  
  873.  PipeOpen returns the code supplied by the DosOpen system directive. 
  874.  
  875.  Expected: 
  876.  
  877.     000 -- NO_ERROR 
  878.     002 -- ERROR_FILE_NOT_FOUND 
  879.     003 -- ERROR_PATH_NOT_FOUND 
  880.     005 -- ERROR_ACCESS_DENIED 
  881.     087 -- ERROR_INVALID_PARAMETER 
  882.     231 -- ERROR_PIPE_BUSY 
  883.  
  884.  Notes 
  885.  
  886.  If the return code is non-zero, handleVar is not created or modified. 
  887.  
  888.  See also 
  889.  
  890.  PipeCreate, PipeClose. 
  891.  
  892.  Examples 
  893.  
  894.  To open a named pipe: 
  895.  
  896.       call PipeOpen 'pipe', '\PIPE\MY_PIPE'
  897.       if result \= 0 then signal PipeOpenError
  898.  
  899.  
  900. ΓòÉΓòÉΓòÉ 4.11. PipePeek function ΓòÉΓòÉΓòÉ
  901.  
  902.  
  903. Syntax 
  904.  
  905. rc = PipePeek(pipeHandle, [ inputVar ], [ inputLimit ], [ pipeBytesVar ], 
  906. [ msgBytesVar ], [ stateVar ]) 
  907.  
  908. Description 
  909.  
  910. PipePeek performs a read operation on a named pipe.  The operation returns 
  911. immediatly with the currently available data as well as with other requested 
  912. informations. 
  913.  
  914. Arguments 
  915.  
  916.  pipeHandle     as obtained from PipeCreate or PipeOpen. 
  917.  
  918.  inputVar       is the name of the variable which will receive the data. 
  919.  
  920.  inputLimit     is the allowed size limit for the response.  If zero or 
  921.                 omitted, a default limit of 4096 is used. 
  922.  
  923.  pipeBytesVar   is the name of the variable which will receive the number of 
  924.                 bytes held in the pipe buffer. 
  925.  
  926.  msgBytesVar    is the name of the variable which will receive the number of 
  927.                 bytes held in the pipe buffer for the current message. 
  928.  
  929.  stateVar       is the name of the variable which will receive a code 
  930.                 identifying the state of the pipe: 
  931.  
  932.           1:       the pipe is disconnected; 
  933.           2:       the pipe is listening for a connection; 
  934.           3:       the pipe is connected; 
  935.           4:       the pipe is closing. 
  936.  
  937.  Returns 
  938.  
  939.  PipePeek returns the code supplied by the DosPeekNPipe system directive. 
  940.  
  941.  Expected: 
  942.  
  943.     000 -- NO_ERROR 
  944.     230 -- ERROR_BAD_PIPE 
  945.     231 -- ERROR_PIPE_BUSY 
  946.     233 -- ERROR_PIPE_NOT_CONNECTED 
  947.  
  948.  See also 
  949.  
  950.  PipeRead. 
  951.  
  952.  Examples 
  953.  
  954.  To peek for a maximum of 80 bytes from a named pipe: 
  955.  
  956.       call PipePeek pipe, 'data', 80, 'pipeBytes', 'msgBytes', 'state'
  957.       if result \= 0 then signal PipePeekError
  958.       say 'Pipe data:' data
  959.       say 'Pipe bytes held:' pipeBytes
  960.       say 'Pipe bytes in message:' msgBytes
  961.       say 'Pipe state:' state
  962.  
  963.  
  964. ΓòÉΓòÉΓòÉ 4.12. PipeRead function ΓòÉΓòÉΓòÉ
  965.  
  966.  
  967. Syntax 
  968.  
  969. rc = PipeRead(pipeHandle, inputVar, [ inputLimit ]) 
  970.  
  971. Description 
  972.  
  973. PipeRead performs a blocking read operation on a named pipe. 
  974.  
  975. Arguments 
  976.  
  977.  pipeHandle     as obtained from PipeCreate or PipeOpen. 
  978.  
  979.  inputVar       is the name of the variable which will receive the data. 
  980.  
  981.  inputLimit     is the allowed size limit for the response.  If zero or 
  982.                 omitted, a default limit of 4096 is used. 
  983.  
  984.  Returns 
  985.  
  986.  PipeRead returns the code supplied by the DosRead system directive. 
  987.  
  988.  Expected: 
  989.  
  990.     000 -- NO_ERROR 
  991.     005 -- ERROR_ACCESS_DENIED 
  992.     006 -- ERROR_INVALID_HANDLE 
  993.     109 -- ERROR_BROKEN_PIPE 
  994.  
  995.  See also 
  996.  
  997.  PipeReadAsync, PipeWrite, PipePeek. 
  998.  
  999.  Examples 
  1000.  
  1001.  To read from a named pipe: 
  1002.  
  1003.       call PipeRead pipe, 'data'
  1004.       if result \= 0 then signal PipeReadError
  1005.       say 'Pipe data:' data
  1006.  
  1007.  
  1008. ΓòÉΓòÉΓòÉ 4.13. PipeReadAsync function ΓòÉΓòÉΓòÉ
  1009.  
  1010.  
  1011. Syntax 
  1012.  
  1013. rc = PipeReadAsync(pipeHandle, ctxHandle, [ inputLimit ]) 
  1014.  
  1015. Description 
  1016.  
  1017. PipeReadAsync starts a read operation on a named pipe.  It does not wait for 
  1018. completion.  When the read has completed (see IPCContextCreate), the data can 
  1019. be obtained with IPCContextResult. 
  1020.  
  1021. Arguments 
  1022.  
  1023.  pipeHandle     as obtained from PipeCreate or PipeOpen. 
  1024.  
  1025.  ctxHandle      as obtained from IPCContextCreate. 
  1026.  
  1027.  inputLimit     is the allowed size limit for the response.  If zero or 
  1028.                 omitted, a default limit of 4096 is used. 
  1029.  
  1030.  Returns 
  1031.  
  1032.  PipeReadAsync returns the code supplied by the DosCreateThread system 
  1033.  directive. 
  1034.  
  1035.  Expected: 
  1036.  
  1037.     000 -- NO_ERROR 
  1038.     008 -- ERROR_NOT_ENOUGH_MEMORY 
  1039.     095 -- ERROR_INTERRUPT 
  1040.     164 -- ERROR_MAX_THRDS_REACHED 
  1041.  
  1042.  See also 
  1043.  
  1044.  IPCContextCreate, IPCContextResult, PipeRead, PipeWriteAsync. 
  1045.  
  1046.  Examples 
  1047.  
  1048.  To start a read operation from a named pipe and, later, get the data: 
  1049.  
  1050.       call IPCContextCreate 'context'
  1051.       if result \= 0 then signal ContextCreateError
  1052.  
  1053.       call PipeReadAsync pipe, context
  1054.       if result \= 0 then signal PipeReadAsyncError
  1055.       .
  1056.       .
  1057.       .
  1058.       call IPCContextWait context
  1059.       if result \= 0 then signal ContextWaitError
  1060.  
  1061.       data = IPCContextResult(context)
  1062.  
  1063.  
  1064. ΓòÉΓòÉΓòÉ 4.14. PipeSetSem function ΓòÉΓòÉΓòÉ
  1065.  
  1066.  
  1067. Syntax 
  1068.  
  1069. rc = PipeSetSem(pipeHandle, semHandle) 
  1070.  
  1071. Description 
  1072.  
  1073. PipeSetSem associates a shared event semaphore with the pipe.  Read and write 
  1074. operations on the other end of the pipe will post events on that semaphore. 
  1075.  
  1076. Arguments 
  1077.  
  1078.  pipeHandle     as obtained from PipeCreate or PipeOpen. 
  1079.  
  1080.  semHandle      as obtained from SemEventCreate or SemEventOpen 
  1081.  
  1082.  Returns 
  1083.  
  1084.  PipeSetSem returns the code supplied by the DosSetNPipeSem system directive. 
  1085.  
  1086.  Expected: 
  1087.  
  1088.     000 -- NO_ERROR 
  1089.     001 -- ERROR_INVALID_FUNCTION 
  1090.     006 -- ERROR_INVALID_HANDLE 
  1091.     187 -- ERROR_SEM_NOT_FOUND 
  1092.     230 -- ERROR_BAD_PIPE 
  1093.     233 -- ERROR_PIPE_NOT_CONNECTED 
  1094.  
  1095.  See also 
  1096.  
  1097.  SemEventCreate, SemEventWait, PipeRead, PipeWrite. 
  1098.  
  1099.  Examples 
  1100.  
  1101.  To associate a shared event semaphore to a pipe: 
  1102.  
  1103.       call SemEventCreate 'event', 'Shared'
  1104.       if result \= 0 then signal SemCreateError
  1105.  
  1106.       call PipeSetSem pipe, event
  1107.       if result \= 0 then signal PipeSetSemError
  1108.       .
  1109.       .
  1110.       .
  1111.       call SemEventWait event
  1112.       if result \= 0 then signal SemWaitError
  1113.  
  1114.  
  1115. ΓòÉΓòÉΓòÉ 4.15. PipeTransact function ΓòÉΓòÉΓòÉ
  1116.  
  1117.  
  1118. Syntax 
  1119.  
  1120. rc = PipeTransact(pipeHandle, output, inputVar, [ inputLimit ]) 
  1121.  
  1122. Description 
  1123.  
  1124. PipeTransact combines the effect of PipeWrite and PipeRead. 
  1125.  
  1126. Arguments 
  1127.  
  1128.  pipeHandle     as obtained from PipeCreate or PipeOpen. 
  1129.  
  1130.  output         is the string expression to be sent on the pipe. 
  1131.  
  1132.  inputVar       is the name of the variable which will receive the response. 
  1133.  
  1134.  inputLimit     is the allowed size limit for the response.  If zero or 
  1135.                 omitted, a default limit of 4096 is used. 
  1136.  
  1137.  Returns 
  1138.  
  1139.  PipeTransact returns the code supplied by the DosTransactNPipe system 
  1140.  directive. 
  1141.  
  1142.  Expected: 
  1143.  
  1144.     000 -- NO_ERROR 
  1145.     011 -- ERROR_BAD_FORMAT 
  1146.     230 -- ERROR_BAD_PIPE 
  1147.     233 -- ERROR_PIPE_NOT_CONNECTED 
  1148.  
  1149.  Notes 
  1150.  
  1151.  The pipe must have been created in duplex mode with message format. 
  1152.  
  1153.  See also 
  1154.  
  1155.  PipeCall, PipeRead, PipeWrite. 
  1156.  
  1157.  Examples 
  1158.  
  1159.  To make a named pipe transaction: 
  1160.  
  1161.       call PipeTransact pipe, 'Hello?', 'answer'
  1162.       if result \= 0 then signal PipeTransactError
  1163.       say 'Pipe answer:' answer
  1164.  
  1165.  
  1166. ΓòÉΓòÉΓòÉ 4.16. PipeWait function ΓòÉΓòÉΓòÉ
  1167.  
  1168.  
  1169. Syntax 
  1170.  
  1171. rc = PipeWait(name, [ timeout ]) 
  1172.  
  1173. Description 
  1174.  
  1175. PipeWait performs a wait on a busy named pipe. 
  1176.  
  1177. Arguments 
  1178.  
  1179.  name           specifies the name for the pipe. It must have the form: 
  1180.  
  1181.                     [\\serverName ]\PIPE\pipeName 
  1182.  
  1183.                 where: 
  1184.  
  1185.           serverName              is the name of the server on which the pipe 
  1186.                                   has been created; 
  1187.  
  1188.           pipeName                is the actual name of the pipe. 
  1189.  
  1190.  timeout        is the wait timeout in milliseconds.  A value of -1 means an 
  1191.                 infinite wait; 0 or no value uses the value specified in the 
  1192.                 PipeCreate call. 
  1193.  
  1194.  Returns 
  1195.  
  1196.  PipeWait returns the code supplied by the DosWaitNPipe system directive. 
  1197.  
  1198.  Expected: 
  1199.  
  1200.     000 -- NO_ERROR 
  1201.     002 -- ERROR_FILE_NOT_FOUND 
  1202.     095 -- ERROR_INTERRUPT 
  1203.     231 -- ERROR_PIPE_BUSY 
  1204.  
  1205.  See also 
  1206.  
  1207.  PipeOpen. 
  1208.  
  1209.  Examples 
  1210.  
  1211.  To open a very busy named pipe: 
  1212.  
  1213.       do forever
  1214.           call PipeOpen 'pipe', '\PIPE\MY_PIPE'
  1215.           if result = 0 then leave
  1216.           if result \= 231 then signal PipeOpenError
  1217.           call PipeWait '\PIPE\MY_PIPE', -1
  1218.           if result \= 0 then signal PipeWaitError
  1219.       end
  1220.  
  1221.  
  1222. ΓòÉΓòÉΓòÉ 4.17. PipeWrite function ΓòÉΓòÉΓòÉ
  1223.  
  1224.  
  1225. Syntax 
  1226.  
  1227. rc = PipeWrite(pipeHandle, output) 
  1228.  
  1229. Description 
  1230.  
  1231. PipeWrite performs a blocking write operation on a named pipe. 
  1232.  
  1233. Arguments 
  1234.  
  1235.  pipeHandle     as obtained from PipeCreate or PipeOpen. 
  1236.  
  1237.  output         is the string expression to be sent on the pipe. 
  1238.  
  1239.  Returns 
  1240.  
  1241.  PipeWrite returns the code supplied by the DosWrite system directive. 
  1242.  
  1243.  Expected: 
  1244.  
  1245.     000 -- NO_ERROR 
  1246.     005 -- ERROR_ACCESS_DENIED 
  1247.     006 -- ERROR_INVALID_HANDLE 
  1248.     109 -- ERROR_BROKEN_PIPE 
  1249.  
  1250.  See also 
  1251.  
  1252.  PipeRead. 
  1253.  
  1254.  Examples 
  1255.  
  1256.  To write on a named pipe: 
  1257.  
  1258.       call PipeWrite pipe, 'Hello, Pipe!'
  1259.       if result \= 0 then signal PipeWriteError
  1260.  
  1261.  
  1262. ΓòÉΓòÉΓòÉ 4.18. PipeWriteAsync function ΓòÉΓòÉΓòÉ
  1263.  
  1264.  
  1265. Syntax 
  1266.  
  1267. rc = PipeWriteAsync(pipeHandle, ctxHandle, output) 
  1268.  
  1269. Description 
  1270.  
  1271. PipeWriteAsync starts a write operation on a named pipe. 
  1272.  
  1273. Arguments 
  1274.  
  1275.  pipeHandle     as obtained from PipeCreate or PipeOpen. 
  1276.  
  1277.  ctxHandle      as obtained from IPCContextCreate. 
  1278.  
  1279.  output         is the string expression to be sent on the pipe. 
  1280.  
  1281.  Returns 
  1282.  
  1283.  PipeWriteAsync returns the code supplied by the DosCreateThread system 
  1284.  directive. 
  1285.  
  1286.  Expected: 
  1287.  
  1288.     000 -- NO_ERROR 
  1289.     008 -- ERROR_NOT_ENOUGH_MEMORY 
  1290.     095 -- ERROR_INTERRUPT 
  1291.     164 -- ERROR_MAX_THRDS_REACHED 
  1292.  
  1293.  See also 
  1294.  
  1295.  IPCContextCreate, PipeReadAsync, PipeWrite. 
  1296.  
  1297.  Examples 
  1298.  
  1299.  To start a write operation on a named pipe: 
  1300.  
  1301.       call IPCContextCreate 'context'
  1302.       if result \= 0 then signal ContextCreateError
  1303.  
  1304.       call PipeWriteAsync pipe, context, 'Hello, Pipe!'
  1305.       if result \= 0 then signal PipeWriteAsyncError
  1306.  
  1307.  
  1308. ΓòÉΓòÉΓòÉ 5. Process Procedures and Functions ΓòÉΓòÉΓòÉ
  1309.  
  1310. The Proc prefix identifies process related functions. 
  1311.  
  1312. The "Control Program Guide and Reference" (Developer's Toolkit for OS/2) or 
  1313. "Client/Server Programming with OS/2" (Van Nostrand Reinhold) are valuable 
  1314. sources of information. 
  1315.  
  1316. Note:   The facilities provided by these functions are simple mapping to the 
  1317.         corresponding system services.  They should by used with caution, since 
  1318.         they are much more likely to affect other processes in the system than 
  1319.         the other function groups in this library. 
  1320.  
  1321.  
  1322. ΓòÉΓòÉΓòÉ 5.1. ProcCreateThread function ΓòÉΓòÉΓòÉ
  1323.  
  1324.  
  1325. Syntax 
  1326.  
  1327. rc = ProcCreateThread([ ctxHandle ], commandFile, [ ... ]) 
  1328.  
  1329. Description 
  1330.  
  1331. ProcCreateThread is used to create and start a Rexx thread. 
  1332.  
  1333. Arguments 
  1334.  
  1335.  ctxHandle      as obtained from IPCContextCreate.  This context is used to 
  1336.                 anchor the execution of the thread.  If this parameter is not 
  1337.                 supplied, a temporary context will be automatically generated 
  1338.                 before the thread is started and discarded after the thread has 
  1339.                 terminated. 
  1340.  
  1341.  commandFile    is the name of a Rexx command file to be executed by the Rexx 
  1342.                 interpreter in the thread. 
  1343.  
  1344.  ...            these parameters will be passed to the Rexx program. 
  1345.  
  1346.  Returns 
  1347.  
  1348.  ProcSendSignal returns the code supplied by the DosCreateThread system 
  1349.  directive. 
  1350.  
  1351.  Expected: 
  1352.  
  1353.     000 -- NO_ERROR 
  1354.     008 -- ERROR_NOT_ENOUGH_MEMORY 
  1355.     095 -- ERROR_INTERRUPT 
  1356.     164 -- ERROR_MAX_THRDS_REACHED 
  1357.  
  1358.  Notes 
  1359.  
  1360.  The use of an explicit context allows for a more controlled execution of the 
  1361.  started thread.  It is then possible to specify an event semaphore to 
  1362.  IPCContextCreate which will be posted when the thread terminates, to 
  1363.  periodically check the thread with IPCContextQuery, to wait for the thread to 
  1364.  terminate and get the return code with IPCContextWait, to get the result 
  1365.  string returned by the thread with IPCContextResult, and to terminate the 
  1366.  thread with IPCContextClose. 
  1367.  
  1368.  Thread synchronization and resource access control may be done with Semaphore 
  1369.  functions.  The Rexx Queue facility (RxQueue and LineIn functions; Push, Pull 
  1370.  and Queue keywords) may be used to support communication between threads. 
  1371.  
  1372.  Examples 
  1373.  
  1374.  To start and forget a thread: 
  1375.  
  1376.       call ProcCreateThread , 'thread.cmd'
  1377.       if result \= 0 then signal CreateThreadError
  1378.  
  1379.  To start a thread, do some processing, then wait and get the thread result: 
  1380.  
  1381.       call IPCContextCreate 'context'
  1382.       if result \= 0 then signal CreateContextError
  1383.  
  1384.       call ProcCreateThread context, 'thread.cmd', '1st', '2nd'
  1385.       if result \= 0 then signal CreateThreadError
  1386.  
  1387.       .
  1388.       .
  1389.       .
  1390.  
  1391.       call IPCContextWait context
  1392.       if result \= 0 then signal ThreadTerminatedOnError
  1393.  
  1394.       call IPCContextResult context
  1395.       say 'The thread returned: "'result'".'
  1396.  
  1397.  
  1398. ΓòÉΓòÉΓòÉ 5.2. ProcDropFuncs procedure ΓòÉΓòÉΓòÉ
  1399.  
  1400.  
  1401. Syntax 
  1402.  
  1403. call ProcDropFuncs 
  1404.  
  1405. Description 
  1406.  
  1407. ProcDropFuncs deregisters all the process procedures and functions. 
  1408.  
  1409. Arguments 
  1410.  
  1411. No arguments are required by ProcDropFuncs. 
  1412.  
  1413. Returns 
  1414.  
  1415. Nothing is returned by ProcDropFuncs. 
  1416.  
  1417. Notes 
  1418.  
  1419. Process procedures and functions may be deregistered individually. 
  1420. ProcDropFuncs is only a shortcut to have them all deregistered with one call. 
  1421.  
  1422. IPCDropFuncs will by itself call ProcDropFuncs and deregister it. 
  1423.  
  1424. See also 
  1425.  
  1426. IPCDropFuncs, ProcLoadFuncs. 
  1427.  
  1428.  
  1429. ΓòÉΓòÉΓòÉ 5.3. ProcGetThreadInfo function ΓòÉΓòÉΓòÉ
  1430.  
  1431.  
  1432. Syntax 
  1433.  
  1434. call ProcGetThreadInfo [ threadIdVar ], [ priorityClassVar ], [ priorityVar ], 
  1435. [ processIdVar ], [ parentProcessIdVar ] 
  1436.  
  1437. Description 
  1438.  
  1439. ProcGetThreadInfo is used to get informations on the current thread. 
  1440.  
  1441. Arguments 
  1442.  
  1443.  threadIdVar    is the name of the variable which, if present, will receive the 
  1444.                 system identification for the thread. 
  1445.  
  1446.  priorityClassVar is the name of the variable which will receive the priority 
  1447.                 class.  If present, it will get one of the following keywords: 
  1448.  
  1449.           Idle                    identifies the Idle (lowest) priority class; 
  1450.  
  1451.           Regular                 identifies the Regular (default) priority 
  1452.                                   class; 
  1453.  
  1454.           Server                  identifies the Server (high) priority class; 
  1455.  
  1456.           Critical                identifies the Critical (highest) priority 
  1457.                                   class. 
  1458.  
  1459.  priorityVar    is the name of the variable which, if present, will receive the 
  1460.                 priority within the current class. 
  1461.  
  1462.  processIdVar   is the name of the variable which, if present, will receive the 
  1463.                 system identification for the process. 
  1464.  
  1465.  parentProcessIdVar is the name of the variable which, if present, will receive 
  1466.                 the system identification for the parent process. 
  1467.  
  1468.  Returns 
  1469.  
  1470.  Nothing is returned by ProcGetThreadInfo. 
  1471.  
  1472.  
  1473. ΓòÉΓòÉΓòÉ 5.4. ProcLoadFuncs procedure ΓòÉΓòÉΓòÉ
  1474.  
  1475.  
  1476. Syntax 
  1477.  
  1478. call ProcLoadFuncs 
  1479.  
  1480. Description 
  1481.  
  1482. ProcLoadFuncs registers all the process procedures and functions. 
  1483.  
  1484. Arguments 
  1485.  
  1486. No arguments are required by ProcLoadFuncs. 
  1487.  
  1488. Returns 
  1489.  
  1490. Nothing is returned by ProcLoadFuncs. 
  1491.  
  1492. Notes 
  1493.  
  1494. Process procedures and functions must be registered before they can be used. 
  1495. They may be registered individually.  ProcLoadFuncs is only a shortcut to have 
  1496. them all registered with one call. 
  1497.  
  1498. IPCLoadFuncs will by itself register and call ProcLoadFuncs. 
  1499.  
  1500. See also 
  1501.  
  1502. IPCLoadFuncs, ProcDropFuncs. 
  1503.  
  1504.  
  1505. ΓòÉΓòÉΓòÉ 5.5. ProcSendSignal function ΓòÉΓòÉΓòÉ
  1506.  
  1507.  
  1508. Syntax 
  1509.  
  1510. rc = ProcSendSignal(processId, signal) 
  1511.  
  1512. Description 
  1513.  
  1514. ProcSendSignal is used to send a signal (Break, Interrupt or Kill) to a 
  1515. process. 
  1516.  
  1517. Arguments 
  1518.  
  1519.  processId      is the process identification for the target process. 
  1520.  
  1521.  signal         identifies the signal to send.  It must be one of the following 
  1522.                 keywords: 
  1523.  
  1524.           Break                   send a Break (Ctrl+Break) signal; 
  1525.  
  1526.           Interrupt               send an Interrupt (Ctrl+C) signal; 
  1527.  
  1528.           Kill                    send a Kill signal. 
  1529.  
  1530.                 The keywords are case insensitive and may be abbreviated. 
  1531.  
  1532.  Returns 
  1533.  
  1534.  ProcSendSignal returns the code supplied by the DosSendSignalException or 
  1535.  DosKillProcess system directive. 
  1536.  
  1537.  Expected: 
  1538.  
  1539.     000 -- NO_ERROR 
  1540.     156 -- ERROR_SIGNAL_REFUSED 
  1541.     205 -- ERROR_NO_SIGNAL_SENT 
  1542.     217 -- ERROR_ZOMBIE_PROCESS 
  1543.     303 -- ERROR_INVALID_PROCID 
  1544.     305 -- ERROR_NOT_DESCENDANT 
  1545.  
  1546.  Examples 
  1547.  
  1548.  To kill a process: 
  1549.  
  1550.       call ProcSendSignal processId, 'Kill'
  1551.       if result \= 0 then signal ProcessKillError
  1552.  
  1553.  
  1554. ΓòÉΓòÉΓòÉ 5.6. ProcSetPriority function ΓòÉΓòÉΓòÉ
  1555.  
  1556.  
  1557. Syntax 
  1558.  
  1559. rc = ProcSetPriority([ processId ], [ class ], [ delta ]) 
  1560.  
  1561. Description 
  1562.  
  1563. ProcSetPriority is used to modify the execution priority of a process. 
  1564.  
  1565. Arguments 
  1566.  
  1567.  processId      is the system identification for the target process.  Absence 
  1568.                 or 0 (zero) identifies the calling process. 
  1569.  
  1570.  class          is the new priority class.  If present, it must be one of the 
  1571.                 following keywords: 
  1572.  
  1573.           Idle                    identifies the Idle (lowest) priority class; 
  1574.  
  1575.           Regular                 identifies the Regular (default) priority 
  1576.                                   class; 
  1577.  
  1578.           Server                  identifies the Server (high) priority class; 
  1579.  
  1580.           Critical                identifies the Critical (highest) priority 
  1581.                                   class. 
  1582.  
  1583.                 The keywords are case insensitive and may be abbreviated. 
  1584.  
  1585.  delta          if the class is not specified, this is the priority variation 
  1586.                 within the current class and may range from -31 to +31;  if the 
  1587.                 class is specified, this is the absolute priority within that 
  1588.                 class and may range from 0 to +31. 
  1589.  
  1590.  Returns 
  1591.  
  1592.  ProcSetPriority returns the code supplied by the DosSetPriority system 
  1593.  directive. 
  1594.  
  1595.  Expected: 
  1596.  
  1597.     000 -- NO_ERROR 
  1598.     303 -- ERROR_INVALID_PROCID 
  1599.     304 -- ERROR_INVALID_PDELTA 
  1600.     305 -- ERROR_NOT_DESCENDANT 
  1601.  
  1602.  See also 
  1603.  
  1604.  ProcSetThreadPriority, ProcSetTreePriority. 
  1605.  
  1606.  Examples 
  1607.  
  1608.  To set the priority of the current process to 20 in the Idle class: 
  1609.  
  1610.       call ProcSetPriority 0, 'Idle', 20
  1611.       if result \= 0 then signal SetPriorityError
  1612.  
  1613.  
  1614. ΓòÉΓòÉΓòÉ 5.7. ProcSetThreadPriority function ΓòÉΓòÉΓòÉ
  1615.  
  1616.  
  1617. Syntax 
  1618.  
  1619. rc = ProcSetThreadPriority([ threadId ], [ class ], [ delta ]) 
  1620.  
  1621. Description 
  1622.  
  1623. ProcSetThreadPriority is used to modify the execution priority of a thread. 
  1624.  
  1625. Arguments 
  1626.  
  1627.  threadId       is the system identification for the target thread.  Absence or 
  1628.                 0 (zero) identifies the calling thread. 
  1629.  
  1630.  class          is the new priority class.  If present, it must be one of the 
  1631.                 following keywords: 
  1632.  
  1633.           Idle                    identifies the Idle (lowest) priority class; 
  1634.  
  1635.           Regular                 identifies the Regular (default) priority 
  1636.                                   class; 
  1637.  
  1638.           Server                  identifies the Server (high) priority class; 
  1639.  
  1640.           Critical                identifies the Critical (highest) priority 
  1641.                                   class. 
  1642.  
  1643.                 The keywords are case insensitive and may be abbreviated. 
  1644.  
  1645.  delta          if the class is not specified, this is the priority variation 
  1646.                 within the current class and may range from -31 to +31;  if the 
  1647.                 class is specified, this is the absolute priority within that 
  1648.                 class and may range from 0 to +31. 
  1649.  
  1650.  Returns 
  1651.  
  1652.  ProcSetThreadPriority returns the code supplied by the DosSetPriority system 
  1653.  directive. 
  1654.  
  1655.  Expected: 
  1656.  
  1657.     000 -- NO_ERROR 
  1658.     304 -- ERROR_INVALID_PDELTA 
  1659.     309 -- ERROR_INVALID_THREADID 
  1660.  
  1661.  See also 
  1662.  
  1663.  ProcSetPriority, ProcSetTreePriority. 
  1664.  
  1665.  Examples 
  1666.  
  1667.  To set the priority of the current thread to 20 in the Idle class: 
  1668.  
  1669.       call ProcSetThreadPriority 0, 'Idle', 20
  1670.       if result \= 0 then signal SetPriorityError
  1671.  
  1672.  
  1673. ΓòÉΓòÉΓòÉ 5.8. ProcSetTreePriority function ΓòÉΓòÉΓòÉ
  1674.  
  1675.  
  1676. Syntax 
  1677.  
  1678. rc = ProcSetTreePriority([ processId ], [ class ], [ delta ]) 
  1679.  
  1680. Description 
  1681.  
  1682. ProcSetPriority is used to modify the execution priority of a process tree. 
  1683.  
  1684. Arguments 
  1685.  
  1686.  processId      is the system identification for the parent process of the 
  1687.                 target process tree.  Absence or 0 (zero) identifies the 
  1688.                 calling process as the parent. 
  1689.  
  1690.  class          is the new priority class.  If present, it must be one of the 
  1691.                 following keywords: 
  1692.  
  1693.           Idle                    identifies the Idle (lowest) priority class; 
  1694.  
  1695.           Regular                 identifies the Regular (default) priority 
  1696.                                   class; 
  1697.  
  1698.           Server                  identifies the Server (high) priority class; 
  1699.  
  1700.           Critical                identifies the Critical (highest) priority 
  1701.                                   class. 
  1702.  
  1703.                 The keywords are case insensitive and may be abbreviated. 
  1704.  
  1705.  delta          if the class is not specified, this is the priority variation 
  1706.                 within the current class and may range from -31 to +31;  if the 
  1707.                 class is specified, this is the absolute priority within that 
  1708.                 class and may range from 0 to +31. 
  1709.  
  1710.  Returns 
  1711.  
  1712.  ProcSetPriority returns the code supplied by the DosSetPriority system 
  1713.  directive. 
  1714.  
  1715.  Expected: 
  1716.  
  1717.     000 -- NO_ERROR 
  1718.     303 -- ERROR_INVALID_PROCID 
  1719.     304 -- ERROR_INVALID_PDELTA 
  1720.     305 -- ERROR_NOT_DESCENDANT 
  1721.  
  1722.  See also 
  1723.  
  1724.  ProcSetPriority, ProcSetThreadPriority. 
  1725.  
  1726.  Examples 
  1727.  
  1728.  To set the priority of the current process tree to 20 in the Idle class: 
  1729.  
  1730.       call ProcSetTreePriority 0, 'Idle', 20
  1731.       if result \= 0 then signal SetPriorityError
  1732.  
  1733.  
  1734. ΓòÉΓòÉΓòÉ 6. Queue Procedures and Functions ΓòÉΓòÉΓòÉ
  1735.  
  1736. The Queue prefix identifies queue related functions. 
  1737.  
  1738. Some functions are most often used by the server side of an application (like 
  1739. QueueCreate, QueuePeek and QueueRead), while others are used by the client side 
  1740. (like QueueOpen and QueueWrite). 
  1741.  
  1742. The "Control Program Guide and Reference" (Developer's Toolkit for OS/2) or 
  1743. "Client/Server Programming with OS/2" (Van Nostrand Reinhold) are valuable 
  1744. sources of information. 
  1745.  
  1746. Note:   The queue handle mentionned in the individual Queue functions 
  1747.         description is the value of a pointer to an internal structure of the 
  1748.         RexxIPC library, converted to an unsigned decimal number character 
  1749.         string.  To simplify the use of OS/2 queues by Rexx programs, this 
  1750.         implementation handles the memory issues related with the management of 
  1751.         queue data;  for this, it needs to associate some informations to the 
  1752.         system provided queue handle. 
  1753.  
  1754.  
  1755. ΓòÉΓòÉΓòÉ 6.1. QueueClose function ΓòÉΓòÉΓòÉ
  1756.  
  1757.  
  1758. Syntax 
  1759.  
  1760. rc = QueueClose(queueHandle) 
  1761.  
  1762. Description 
  1763.  
  1764. QueueClose closes a queue.  It is called both for a created queue (server 
  1765. side), and for an opened queue (client side). 
  1766.  
  1767. Arguments 
  1768.  
  1769.  queueHandle    as obtained from QueueCreate or QueueOpen. 
  1770.  
  1771.  Returns 
  1772.  
  1773.  QueueClose returns the code supplied by the DosCloseQueue system directive. 
  1774.  
  1775.  Expected: 
  1776.  
  1777.     000 -- NO_ERROR 
  1778.     337 -- ERROR_QUE_INVALID_HANDLE 
  1779.  
  1780.  See also 
  1781.  
  1782.  QueueCreate, QueueOpen. 
  1783.  
  1784.  Examples 
  1785.  
  1786.  To close a queue: 
  1787.  
  1788.       call QueueClose queue
  1789.       if result \= 0 then signal QueueCloseError
  1790.  
  1791.  
  1792. ΓòÉΓòÉΓòÉ 6.2. QueueCreate function ΓòÉΓòÉΓòÉ
  1793.  
  1794.  
  1795. Syntax 
  1796.  
  1797. rc = QueueCreate(handleVar, name, [ algorithm ], [ semHandle ]) 
  1798.  
  1799. Description 
  1800.  
  1801. QueueCreate is used to create a queue. 
  1802.  
  1803. Arguments 
  1804.  
  1805.  handleVar      is the name of a variable which will receive the handle to the 
  1806.                 queue. 
  1807.  
  1808.  name           specifies the name for the queue. It must have the form: 
  1809.  
  1810.                     \QUEUES\queueName 
  1811.  
  1812.                 where: 
  1813.  
  1814.           queueName               is the actual name of the queue. 
  1815.  
  1816.  algorithm      is the queue access algorithm.  If present, it must be one of 
  1817.                 the following keywords: 
  1818.  
  1819.           FIFO                    for a FIFO queue (First In, First Out), this 
  1820.                                   is the default; 
  1821.  
  1822.           LIFO                    for a LIFO queue (Last In, First Out); 
  1823.  
  1824.           Priority                for a Priority queue. 
  1825.  
  1826.                 The keywords are case insensitive and may be abbreviated. 
  1827.  
  1828.  semHandle      is the handle to a shared event semaphore which will be used in 
  1829.                 QueuePeek and QueueRead calls when the wait parameter is set to 
  1830.                 NoWait. 
  1831.  
  1832.  Returns 
  1833.  
  1834.  QueueCreate returns the code supplied by the DosCreateQueue system directive. 
  1835.  
  1836.  Notes 
  1837.  
  1838.  If the return code is non-zero, handleVar is not created or modified. 
  1839.  
  1840.  Expected: 
  1841.  
  1842.     000 -- NO_ERROR 
  1843.     332 -- ERROR_QUE_DUPLICATE 
  1844.     334 -- ERROR_QUE_NO_MEMORY 
  1845.     335 -- ERROR_QUE_INVALID_NAME 
  1846.  
  1847.  See also 
  1848.  
  1849.  QueueOpen, QueueClose. 
  1850.  
  1851.  Examples 
  1852.  
  1853.  To create a queue: 
  1854.  
  1855.       call QueueCreate 'queue', '\QUEUES\MY_QUEUE'
  1856.       if result \= 0 then signal QueueCreateError
  1857.  
  1858.  
  1859. ΓòÉΓòÉΓòÉ 6.3. QueueDropFuncs procedure ΓòÉΓòÉΓòÉ
  1860.  
  1861.  
  1862. Syntax 
  1863.  
  1864. call QueueDropFuncs 
  1865.  
  1866. Description 
  1867.  
  1868. QueueDropFuncs deregisters all the Queue procedures and functions. 
  1869.  
  1870. Arguments 
  1871.  
  1872. No arguments are required by QueueDropFuncs. 
  1873.  
  1874. Returns 
  1875.  
  1876. Nothing is returned by QueueDropFuncs. 
  1877.  
  1878. Notes 
  1879.  
  1880. Queue procedures and functions may be deregistered individually. 
  1881. QueueDropFuncs is only a shortcut to have them all deregistered with one call. 
  1882.  
  1883. IPCDropFuncs will by itself call QueueDropFuncs and deregister it. 
  1884.  
  1885. See also 
  1886.  
  1887. IPCDropFuncs, QueueLoadFuncs. 
  1888.  
  1889.  
  1890. ΓòÉΓòÉΓòÉ 6.4. QueueLoadFuncs procedure ΓòÉΓòÉΓòÉ
  1891.  
  1892.  
  1893. Syntax 
  1894.  
  1895. call QueueLoadFuncs 
  1896.  
  1897. Description 
  1898.  
  1899. QueueLoadFuncs registers all the Queue procedures and functions. 
  1900.  
  1901. Arguments 
  1902.  
  1903. No arguments are required by QueueLoadFuncs. 
  1904.  
  1905. Returns 
  1906.  
  1907. Nothing is returned by QueueLoadFuncs. 
  1908.  
  1909. Notes 
  1910.  
  1911. Queue procedures and functions must be registered before they can be used. 
  1912. They may be registered individually.  QueueLoadFuncs is only a shortcut to have 
  1913. them all registered with one call. 
  1914.  
  1915. IPCLoadFuncs will by itself register and call QueueLoadFuncs. 
  1916.  
  1917. See also 
  1918.  
  1919. IPCLoadFuncs, QueueDropFuncs. 
  1920.  
  1921.  
  1922. ΓòÉΓòÉΓòÉ 6.5. QueueOpen function ΓòÉΓòÉΓòÉ
  1923.  
  1924.  
  1925. Syntax 
  1926.  
  1927. rc = QueueOpen(handleVar, name, [ serverVar ], [ semHandle ]) 
  1928.  
  1929. Description 
  1930.  
  1931. QueueOpen is used to open a queue. 
  1932.  
  1933. Arguments 
  1934.  
  1935.  handleVar      is the name of a variable which will receive the handle to the 
  1936.                 queue. 
  1937.  
  1938.  name           specifies the name for the queue. It must have the form: 
  1939.  
  1940.                     \QUEUES\queueName 
  1941.  
  1942.                 where: 
  1943.  
  1944.           queueName               is the actual name of the queue. 
  1945.  
  1946.  serverVar      is the name of a variable which will receive the process 
  1947.                 identification of the queue server. 
  1948.  
  1949.  semHandle      is the handle to a shared event semaphore which will be used in 
  1950.                 QueuePeek and QueueRead calls when the wait parameter is set to 
  1951.                 NoWait. 
  1952.  
  1953.  Returns 
  1954.  
  1955.  QueueOpen returns the code supplied by the DosOpenQueue system directive. 
  1956.  
  1957.  Expected: 
  1958.  
  1959.     000 -- NO_ERROR 
  1960.     334 -- ERROR_QUE_NO_MEMORY 
  1961.     341 -- ERROR_QUE_PROC_NO_ACCESS 
  1962.     343 -- ERROR_QUE_NAME_NOT_EXIST 
  1963.  
  1964.  Notes 
  1965.  
  1966.  If the return code is non-zero, handleVar is not created or modified. 
  1967.  
  1968.  See also 
  1969.  
  1970.  QueueCreate, QueueClose. 
  1971.  
  1972.  Examples 
  1973.  
  1974.  To open a queue: 
  1975.  
  1976.       call QueueOpen 'queue', '\QUEUES\MY_QUEUE'
  1977.       if result \= 0 then signal QueueOpenError
  1978.  
  1979.  
  1980. ΓòÉΓòÉΓòÉ 6.6. QueuePeek function ΓòÉΓòÉΓòÉ
  1981.  
  1982.  
  1983. Syntax 
  1984.  
  1985. rc = QueuePeek(queueHandle, [ dataVar ], [ requestVar ], [ priorityVar ], 
  1986. [ clientVar ], [ elementVar ], [ wait ]) 
  1987.  
  1988. Description 
  1989.  
  1990. QueuePeek performs a read operation on a queue.  The operation returns 
  1991. immediatly with the currently available data as well as with other requested 
  1992. informations. 
  1993.  
  1994. Arguments 
  1995.  
  1996.  queueHandle    as obtained from QueueCreate or QueueOpen. 
  1997.  
  1998.  dataVar        is the name of the variable which will receive the data. 
  1999.  
  2000.  requestVar     is the name of the variable which will receive the request 
  2001.                 information associated with the data. 
  2002.  
  2003.  priorityVar    is the name of the variable which will receive the priority 
  2004.                 associated with the data. 
  2005.  
  2006.  clientVar      is the name of the variable which will receive the process 
  2007.                 identification of the client from which the data originated. 
  2008.  
  2009.  elementVar     is the name of the variable which will receive the element 
  2010.                 position in the queue.  If present, initialized and non-zero, 
  2011.                 it must contain a value returned from a previous QueuePeek call 
  2012.                 on the same queue; otherwise, the first element according to 
  2013.                 the queue algorithm will be returned. 
  2014.  
  2015.  wait           is the wait option.  If present, it must be one of the 
  2016.                 following keywords: 
  2017.  
  2018.           Wait                    to wait until a queue element is available; 
  2019.  
  2020.           NoWait                  to return an error code (342) if the queue is 
  2021.                                   empty, this is the default; this will also 
  2022.                                   trigger the use of the shared event semaphore 
  2023.                                   if supplied in QueueCreate or QueueOpen. 
  2024.  
  2025.                 The keywords are case insensitive and may be abbreviated. 
  2026.  
  2027.  Returns 
  2028.  
  2029.  QueuePeek returns the code supplied by the DosPeekQueue system directive. 
  2030.  
  2031.  Expected: 
  2032.  
  2033.     000 -- NO_ERROR 
  2034.     330 -- ERROR_QUE_PROC_NOT_OWNED 
  2035.     333 -- ERROR_QUE_ELEMENT_NOT_EXIST 
  2036.     337 -- ERROR_QUE_INVALID_HANDLE 
  2037.     340 -- ERROR_QUE_PREV_AT_END 
  2038.     342 -- ERROR_QUE_EMPTY 
  2039.  
  2040.  See also 
  2041.  
  2042.  QueueRead. 
  2043.  
  2044.  Examples 
  2045.  
  2046.  To peek for the first element from a queue: 
  2047.  
  2048.       element = 0
  2049.       call QueuePeek queue, 'data', 'request', 'priority', 'client', 'element'
  2050.       if result \= 0 then signal QueuePeekError
  2051.       say 'Queue data:' data
  2052.       say 'Queue request:' request
  2053.       say 'Queue priority:' priority
  2054.       say 'Queue client:' client
  2055.       say 'Queue element:' element
  2056.  
  2057.  
  2058. ΓòÉΓòÉΓòÉ 6.7. QueuePurge function ΓòÉΓòÉΓòÉ
  2059.  
  2060.  
  2061. Syntax 
  2062.  
  2063. rc = QueuePurge(queueHandle) 
  2064.  
  2065. Description 
  2066.  
  2067. QueuePurge purges a queue.  It may be called only from the server side. 
  2068.  
  2069. Arguments 
  2070.  
  2071.  queueHandle    as obtained from QueueCreate or QueueOpen. 
  2072.  
  2073.  Returns 
  2074.  
  2075.  QueuePurge returns the code supplied by the DosPurgeQueue system directive. 
  2076.  
  2077.  Expected: 
  2078.  
  2079.     000 -- NO_ERROR 
  2080.     330 -- ERROR_QUE_PROC_NOT_OWNED 
  2081.     337 -- ERROR_QUE_INVALID_HANDLE 
  2082.  
  2083.  See also 
  2084.  
  2085.  QueueCreate, QueueClose. 
  2086.  
  2087.  Examples 
  2088.  
  2089.  To purge a queue: 
  2090.  
  2091.       call QueuePurge queue
  2092.       if result \= 0 then signal QueuePurgeError
  2093.  
  2094.  
  2095. ΓòÉΓòÉΓòÉ 6.8. QueueQuery function ΓòÉΓòÉΓòÉ
  2096.  
  2097.  
  2098. Syntax 
  2099.  
  2100. rc = QueueQuery(queueHandle, elementsVar) 
  2101.  
  2102. Description 
  2103.  
  2104. QueueQuery gets the number of entries in the queue. 
  2105.  
  2106. Arguments 
  2107.  
  2108.  queueHandle    as obtained from QueueCreate or QueueOpen. 
  2109.  
  2110.  elementsVar    is the number of elements currently in the queue. 
  2111.  
  2112.  Returns 
  2113.  
  2114.  QueueQuery returns the code supplied by the DosQueryQueue system directive. 
  2115.  
  2116.  Expected: 
  2117.  
  2118.     000 -- NO_ERROR 
  2119.     337 -- ERROR_QUE_INVALID_HANDLE 
  2120.  
  2121.  See also 
  2122.  
  2123.  QueuePeek. 
  2124.  
  2125.  Examples 
  2126.  
  2127.  To get the number of elements in a queue: 
  2128.  
  2129.       call QueueQuery queue, 'elements'
  2130.       if result \= 0 then signal QueueQueryError
  2131.       say 'Queue elements:' elements
  2132.  
  2133.  
  2134. ΓòÉΓòÉΓòÉ 6.9. QueueRead function ΓòÉΓòÉΓòÉ
  2135.  
  2136.  
  2137. Syntax 
  2138.  
  2139. rc = QueueRead(queueHandle, dataVar, [ requestVar ], [ priorityVar ], 
  2140. [ clientVar ], [ element ], [ wait ]) 
  2141.  
  2142. Description 
  2143.  
  2144. QueueRead performs a blocking read operation on a queue. 
  2145.  
  2146. Arguments 
  2147.  
  2148.  queueHandle    as obtained from QueueCreate or QueueOpen. 
  2149.  
  2150.  dataVar        is the name of the variable which will receive the data. 
  2151.  
  2152.  requestVar     is the name of the variable which will receive the request 
  2153.                 information associated with the data. 
  2154.  
  2155.  priorityVar    is the name of the variable which will receive the priority 
  2156.                 associated with the data. 
  2157.  
  2158.  clientVar      is the name of the variable which will receive the process 
  2159.                 identification of the client from which the data originated. 
  2160.  
  2161.  element        is the position of the requested element in the queue, as 
  2162.                 obtained from QueuePeek. 
  2163.  
  2164.  wait           is the wait option.  If present, it must be one of the 
  2165.                 following keywords: 
  2166.  
  2167.           Wait                    to wait until a queue element is available, 
  2168.                                   this is the default; 
  2169.  
  2170.           NoWait                  to return an error code (342) if the queue is 
  2171.                                   empty; this will also trigger the use of the 
  2172.                                   shared event semaphore if supplied in 
  2173.                                   QueueCreate or QueueOpen. 
  2174.  
  2175.                 The keywords are case insensitive and may be abbreviated. 
  2176.  
  2177.  Returns 
  2178.  
  2179.  QueueRead returns the code supplied by the DosReadQueue system directive. 
  2180.  
  2181.  Expected: 
  2182.  
  2183.     000 -- NO_ERROR 
  2184.     330 -- ERROR_QUE_PROC_NOT_OWNED 
  2185.     333 -- ERROR_QUE_ELEMENT_NOT_EXIST 
  2186.     337 -- ERROR_QUE_INVALID_HANDLE 
  2187.     342 -- ERROR_QUE_EMPTY 
  2188.  
  2189.  See also 
  2190.  
  2191.  QueueWrite, QueuePeek. 
  2192.  
  2193.  Examples 
  2194.  
  2195.  To read from a queue: 
  2196.  
  2197.       call QueueRead queue, 'data'
  2198.       if result \= 0 then signal QueueReadError
  2199.       say 'Queue data:' data
  2200.  
  2201.  
  2202. ΓòÉΓòÉΓòÉ 6.10. QueueWrite function ΓòÉΓòÉΓòÉ
  2203.  
  2204.  
  2205. Syntax 
  2206.  
  2207. rc = QueueWrite(queueHandle, data, [ request ], [ priority ]) 
  2208.  
  2209. Description 
  2210.  
  2211. QueueWrite performs a write operation on a queue. 
  2212.  
  2213. Arguments 
  2214.  
  2215.  queueHandle    as obtained from QueueCreate or QueueOpen. 
  2216.  
  2217.  data           is the data to be put on the queue. 
  2218.  
  2219.  request        is the request information (numeric value representing an 
  2220.                 unsigned long) to associate with the data. 
  2221.  
  2222.  priority       is the priority to associate with the data. 
  2223.  
  2224.  Returns 
  2225.  
  2226.  QueueWrite returns the code supplied by the DosWriteQueue system directive. 
  2227.  
  2228.  Expected: 
  2229.  
  2230.     000 -- NO_ERROR 
  2231.     334 -- ERROR_QUE_NO_MEMORY 
  2232.     337 -- ERROR_QUE_INVALID_HANDLE 
  2233.  
  2234.  See also 
  2235.  
  2236.  QueueRead. 
  2237.  
  2238.  Examples 
  2239.  
  2240.  To write on a queue: 
  2241.  
  2242.       call QueueWrite queue, 'Hello, Queue!'
  2243.       if result \= 0 then signal QueueWriteError
  2244.  
  2245.  
  2246. ΓòÉΓòÉΓòÉ 7. Semaphore Procedures and Functions ΓòÉΓòÉΓòÉ
  2247.  
  2248. The Sem prefix identifies semaphore related function.  Except for a few 
  2249. procedures (SemLoadFuncs and SemDropFuncs), the prefix is expressed as 
  2250. SemEvent, SemMutex or SemMuxwait, to specify to which type of semaphore the 
  2251. function applies. 
  2252.  
  2253. The "Control Program Guide and Reference" (Developer's Toolkit for OS/2) or 
  2254. "Client/Server Programming with OS/2" (Van Nostrand Reinhold) are valuable 
  2255. sources of information. 
  2256.  
  2257. Note:   The semaphore handle mentionned in the individual semaphore functions 
  2258.         description is the actual value used by the operating system, converted 
  2259.         to an unsigned decimal number character string.  It is not associated 
  2260.         with internal structures of the RexxIPC library and may be created/used 
  2261.         by other modules of the same process. 
  2262.  
  2263.  
  2264. ΓòÉΓòÉΓòÉ 7.1. SemDropFuncs procedure ΓòÉΓòÉΓòÉ
  2265.  
  2266.  
  2267. Syntax 
  2268.  
  2269. call SemDropFuncs 
  2270.  
  2271. Description 
  2272.  
  2273. SemDropFuncs deregisters all the semaphore procedures and functions. 
  2274.  
  2275. Arguments 
  2276.  
  2277. No arguments are required by SemDropFuncs. 
  2278.  
  2279. Returns 
  2280.  
  2281. Nothing is returned by SemDropFuncs. 
  2282.  
  2283. Notes 
  2284.  
  2285. Semaphore procedures and functions may be deregistered individually. 
  2286. SemDropFuncs is only a shortcut to have them all deregistered with one call. 
  2287.  
  2288. IPCDropFuncs will by itself call SemDropFuncs and deregister it. 
  2289.  
  2290. See also 
  2291.  
  2292. IPCLoadFuncs, IPCDropFuncs, SemLoadFuncs. 
  2293.  
  2294.  
  2295. ΓòÉΓòÉΓòÉ 7.2. SemEventClose function ΓòÉΓòÉΓòÉ
  2296.  
  2297.  
  2298. Syntax 
  2299.  
  2300. rc = SemEventClose(semHandle) 
  2301.  
  2302. Description 
  2303.  
  2304. SemEventClose closes an event semaphore. 
  2305.  
  2306. Arguments 
  2307.  
  2308.  semHandle      as obtained from SemEventCreate or SemEventOpen. 
  2309.  
  2310.  Returns 
  2311.  
  2312.  SemEventClose returns the code supplied by the DosCloseEventSem system 
  2313.  directive. 
  2314.  
  2315.  Expected: 
  2316.  
  2317.     000 -- NO_ERROR 
  2318.     006 -- ERROR_INVALID_HANDLE 
  2319.     301 -- ERROR_SEM_BUSY 
  2320.  
  2321.  See also 
  2322.  
  2323.  SemEventCreate, SemEventOpen. 
  2324.  
  2325.  Examples 
  2326.  
  2327.  To close an event semaphore: 
  2328.  
  2329.       call SemEventClose sem
  2330.       if result \= 0 then signal SemCloseError
  2331.  
  2332.  
  2333. ΓòÉΓòÉΓòÉ 7.3. SemEventCreate function ΓòÉΓòÉΓòÉ
  2334.  
  2335.  
  2336. Syntax 
  2337.  
  2338. rc = SemEventCreate(handleVar, [ name ], [ initial ]) 
  2339.  
  2340. Description 
  2341.  
  2342. SemEventCreate is used to create an event semaphore. 
  2343.  
  2344. Arguments 
  2345.  
  2346.  handleVar      is the name of a variable which will receive the handle to the 
  2347.                 event semaphore. 
  2348.  
  2349.  name           specifies the name for the semaphore. If present, it must have 
  2350.                 the form: 
  2351.  
  2352.                     \SEM32\semName 
  2353.  
  2354.                 where: 
  2355.  
  2356.           semName                 is the name of the semaphore. 
  2357.  
  2358.                 If a name is not specified, the keyword Shared (case 
  2359.                 insensitive and may be abbreviated) can be used to create a 
  2360.                 shared unnamed semaphore; otherwise a local semaphore is 
  2361.                 created. 
  2362.  
  2363.  initial        is the initial state of the event semaphore: posted (1) or 
  2364.                 reset (0).  The default is 0. 
  2365.  
  2366.  Returns 
  2367.  
  2368.  SemEventCreate returns the code supplied by the DosCreateEventSem system 
  2369.  directive. 
  2370.  
  2371.  Expected: 
  2372.  
  2373.     000 -- NO_ERROR 
  2374.     008 -- ERROR_NOT_ENOUGH_MEMORY 
  2375.     123 -- ERROR_INVALID_NAME 
  2376.     285 -- ERROR_DUPLICATE_NAME 
  2377.     290 -- ERROR_TOO_MANY_HANDLES 
  2378.  
  2379.  Notes 
  2380.  
  2381.  If the return code is non-zero, handleVar is not created or modified. 
  2382.  
  2383.  See also 
  2384.  
  2385.  SemEventOpen, SemEventClose. 
  2386.  
  2387.  Examples 
  2388.  
  2389.  To create an event semaphore or just open if it already exists: 
  2390.  
  2391.       semName = '\SEM32\MY_SEMAPHORE'
  2392.       call SemEventCreate 'sem', semName
  2393.       if result = 285 then call SemEventOpen 'sem', semName
  2394.       if result \= 0 then signal SemCreateError
  2395.  
  2396.  
  2397. ΓòÉΓòÉΓòÉ 7.4. SemEventOpen function ΓòÉΓòÉΓòÉ
  2398.  
  2399.  
  2400. Syntax 
  2401.  
  2402. rc = SemEventOpen(handleVar, name) 
  2403. rc = SemEventOpen(semHandle) 
  2404.  
  2405. Description 
  2406.  
  2407. SemEventOpen is used to open either a named event semaphore (first form), or a 
  2408. shared unnamed event semaphore (second form). 
  2409.  
  2410. Arguments 
  2411.  
  2412.  handleVar      is the name of a variable which will receive the handle to the 
  2413.                 event semaphore. 
  2414.  
  2415.  name           specifies the name for the semaphore. It must have the form: 
  2416.  
  2417.                     \SEM32\semName 
  2418.  
  2419.                 where: 
  2420.  
  2421.           semName                 is the name of the semaphore. 
  2422.  
  2423.  semHandle      is a handle to a shared unnamed event semaphore.  This handle 
  2424.                 has to be obtained from the process which created the 
  2425.                 semaphore. 
  2426.  
  2427.  Returns 
  2428.  
  2429.  SemEventOpen returns the code supplied by the DosOpenEventSem system 
  2430.  directive. 
  2431.  
  2432.  Expected: 
  2433.  
  2434.     000 -- NO_ERROR 
  2435.     006 -- ERROR_INVALID_HANDLE 
  2436.     008 -- ERROR_NOT_ENOUGH_MEMORY 
  2437.     123 -- ERROR_INVALID_NAME 
  2438.     187 -- ERROR_SEM_NOT_FOUND 
  2439.     291 -- ERROR_TOO_MANY_OPENS 
  2440.  
  2441.  Notes 
  2442.  
  2443.  If the return code is non-zero, handleVar is not created or modified. 
  2444.  
  2445.  See also 
  2446.  
  2447.  SemEventCreate, SemEventClose. 
  2448.  
  2449.  Examples 
  2450.  
  2451.  To open a named event semaphore: 
  2452.  
  2453.       call SemEventOpen 'sem', '\SEM32\A_NAMED_SEMAPHORE'
  2454.       if result \= 0 then signal SemOpenError
  2455.  
  2456.  
  2457. ΓòÉΓòÉΓòÉ 7.5. SemEventPost function ΓòÉΓòÉΓòÉ
  2458.  
  2459.  
  2460. Syntax 
  2461.  
  2462. rc = SemEventPost(semHandle) 
  2463.  
  2464. Description 
  2465.  
  2466. SemEventPost posts an event semaphore. 
  2467.  
  2468. Arguments 
  2469.  
  2470.  semHandle      as obtained from SemEventCreate or SemEventOpen. 
  2471.  
  2472.  Returns 
  2473.  
  2474.  SemEventPost returns the code supplied by the DosPostEventSem system 
  2475.  directive. 
  2476.  
  2477.  Expected: 
  2478.  
  2479.     000 -- NO_ERROR 
  2480.     006 -- ERROR_INVALID_HANDLE 
  2481.     298 -- ERROR_TOO_MANY_POSTS 
  2482.     299 -- ERROR_ALREADY_POSTED 
  2483.  
  2484.  Notes 
  2485.  
  2486.  OS/2 limits the number of posts without a reset to 65535. 
  2487.  
  2488.  See also 
  2489.  
  2490.  SemEventReset, SemEventQuery, SemEventWait. 
  2491.  
  2492.  Examples 
  2493.  
  2494.  To post an event: 
  2495.  
  2496.       call SemEventPost sem
  2497.       if result \= 0 then signal SemPostError
  2498.  
  2499.  
  2500. ΓòÉΓòÉΓòÉ 7.6. SemEventQuery function ΓòÉΓòÉΓòÉ
  2501.  
  2502.  
  2503. Syntax 
  2504.  
  2505. rc = SemEventQuery(semHandle, postCountVar) 
  2506.  
  2507. Description 
  2508.  
  2509. SemEventQuery queries informations from an event semaphore. 
  2510.  
  2511. Arguments 
  2512.  
  2513.  semHandle      as obtained from SemEventCreate or SemEventOpen 
  2514.  
  2515.  postCountVar   is the name of the variable which will receive the number of 
  2516.                 post actions since the last time the semaphore was in a reset 
  2517.                 state. 
  2518.  
  2519.  Returns 
  2520.  
  2521.  SemEventQuery returns the code supplied by the DosQueryEventSem system 
  2522.  directive. 
  2523.  
  2524.  Expected: 
  2525.  
  2526.     000 -- NO_ERROR 
  2527.     006 -- ERROR_INVALID_HANDLE 
  2528.  
  2529.  See also 
  2530.  
  2531.  SemEventReset, SemEventPost, SemEventWait. 
  2532.  
  2533.  Examples 
  2534.  
  2535.  To query an event semaphore: 
  2536.  
  2537.       call SemEventQuery sem, 'count'
  2538.       if result \= 0 then signal SemQueryError
  2539.       say 'Semaphore post count:' count
  2540.  
  2541.  
  2542. ΓòÉΓòÉΓòÉ 7.7. SemEventReset function ΓòÉΓòÉΓòÉ
  2543.  
  2544.  
  2545. Syntax 
  2546.  
  2547. rc = SemEventReset(semHandle, [ postCountVar ]) 
  2548.  
  2549. Description 
  2550.  
  2551. SemEventReset resets an event semaphore. 
  2552.  
  2553. Arguments 
  2554.  
  2555.  semHandle      as obtained from SemEventCreate or SemEventOpen. 
  2556.  
  2557.  postCountVar   if present, is the name of the variable which will receive the 
  2558.                 number of post actions since the last time the semaphore was in 
  2559.                 a reset state. 
  2560.  
  2561.  Returns 
  2562.  
  2563.  SemEventReset returns the code supplied by the DosResetEventSem system 
  2564.  directive. 
  2565.  
  2566.  Expected: 
  2567.  
  2568.     000 -- NO_ERROR 
  2569.     006 -- ERROR_INVALID_HANDLE 
  2570.     300 -- ERROR_ALREADY_RESET 
  2571.  
  2572.  See also 
  2573.  
  2574.  SemEventPost, SemEventQuery, SemEventWait. 
  2575.  
  2576.  Examples 
  2577.  
  2578.  To reset an event semaphore: 
  2579.  
  2580.       call SemEventReset sem
  2581.       if result \= 0 then signal SemResetError
  2582.  
  2583.  
  2584. ΓòÉΓòÉΓòÉ 7.8. SemEventWait function ΓòÉΓòÉΓòÉ
  2585.  
  2586.  
  2587. Syntax 
  2588.  
  2589. rc = SemEventWait(semHandle, [ timeout ]) 
  2590.  
  2591. Description 
  2592.  
  2593. SemEventWait waits for an event semaphore to be in a non reset state. 
  2594.  
  2595. Arguments 
  2596.  
  2597.  semHandle      as obtained from SemEventCreate or SemEventOpen. 
  2598.  
  2599.  timeout        is the wait timeout in milliseconds.  A value of -1 means an 
  2600.                 infinite wait;  this is the default. 
  2601.  
  2602.  Returns 
  2603.  
  2604.  SemEventWait returns the code supplied by the DosWaitEventSem system 
  2605.  directive. 
  2606.  
  2607.  Expected: 
  2608.  
  2609.     000 -- NO_ERROR 
  2610.     006 -- ERROR_INVALID_HANDLE 
  2611.     008 -- ERROR_NOT_ENOUGH_MEMORY 
  2612.     095 -- ERROR_INTERRUPT 
  2613.     640 -- ERROR_TIMEOUT 
  2614.  
  2615.  See also 
  2616.  
  2617.  SemEventPost, SemEventReset, SemEventQuery. 
  2618.  
  2619.  Examples 
  2620.  
  2621.  To wait for an event semaphore: 
  2622.  
  2623.       call SemEventWait sem
  2624.       if result \= 0 then signal SemWaitError
  2625.  
  2626.  
  2627. ΓòÉΓòÉΓòÉ 7.9. SemLoadFuncs procedure ΓòÉΓòÉΓòÉ
  2628.  
  2629.  
  2630. Syntax 
  2631.  
  2632. call SemLoadFuncs 
  2633.  
  2634. Description 
  2635.  
  2636. SemLoadFuncs registers all the semaphore procedures and functions. 
  2637.  
  2638. Arguments 
  2639.  
  2640. No arguments are required by SemLoadFuncs. 
  2641.  
  2642. Returns 
  2643.  
  2644. Nothing is returned by SemLoadFuncs. 
  2645.  
  2646. Notes 
  2647.  
  2648. Semaphore procedures and functions must be registered before they can be used. 
  2649. They may be registered individually.  SemLoadFuncs is only a shortcut to have 
  2650. them all registered with one call. 
  2651.  
  2652. IPCLoadFuncs will by itself register and call SemLoadFuncs. 
  2653.  
  2654. See also 
  2655.  
  2656. IPCLoadFuncs, SemDropFuncs. 
  2657.  
  2658.  
  2659. ΓòÉΓòÉΓòÉ 7.10. SemMutexClose function ΓòÉΓòÉΓòÉ
  2660.  
  2661.  
  2662. Syntax 
  2663.  
  2664. rc = SemMutexClose(semHandle) 
  2665.  
  2666. Description 
  2667.  
  2668. SemMutexClose closes a mutex semaphore. 
  2669.  
  2670. Arguments 
  2671.  
  2672.  semHandle      as obtained from SemMutexCreate or SemMutexOpen. 
  2673.  
  2674.  Returns 
  2675.  
  2676.  SemMutexClose returns the code supplied by the DosCloseMutexSem system 
  2677.  directive. 
  2678.  
  2679.  Expected: 
  2680.  
  2681.     000 -- NO_ERROR 
  2682.     006 -- ERROR_INVALID_HANDLE 
  2683.     301 -- ERROR_SEM_BUSY 
  2684.  
  2685.  See also 
  2686.  
  2687.  SemMutexCreate, SemMutexOpen. 
  2688.  
  2689.  Examples 
  2690.  
  2691.  To close a mutex semaphore: 
  2692.  
  2693.       call SemMutexClose sem
  2694.       if result \= 0 then signal SemCloseError
  2695.  
  2696.  
  2697. ΓòÉΓòÉΓòÉ 7.11. SemMutexCreate function ΓòÉΓòÉΓòÉ
  2698.  
  2699.  
  2700. Syntax 
  2701.  
  2702. rc = SemMutexCreate(handleVar, [ name ], [ initial ]) 
  2703.  
  2704. Description 
  2705.  
  2706. SemMutexCreate is used to create a mutex semaphore. 
  2707.  
  2708. Arguments 
  2709.  
  2710.  handleVar      is the name of a variable which will receive the handle to the 
  2711.                 mutex semaphore. 
  2712.  
  2713.  name           specifies the name for the semaphore. If present, it must have 
  2714.                 the form: 
  2715.  
  2716.                     \SEM32\semName 
  2717.  
  2718.                 where: 
  2719.  
  2720.           semName                 is the name of the semaphore. 
  2721.  
  2722.                 If a name is not specified, the keyword Shared (case 
  2723.                 insensitive and may be abbreviated) can be used to create a 
  2724.                 shared unnamed semaphore; otherwise a local semaphore is 
  2725.                 created. 
  2726.  
  2727.  initial        is the initial state of the mutex semaphore: held (1) or 
  2728.                 released (0).  The default is 0. 
  2729.  
  2730.  Returns 
  2731.  
  2732.  SemMutexCreate returns the code supplied by the DosCreateMutexSem system 
  2733.  directive. 
  2734.  
  2735.  Expected: 
  2736.  
  2737.     000 -- NO_ERROR 
  2738.     008 -- ERROR_NOT_ENOUGH_MEMORY 
  2739.     123 -- ERROR_INVALID_NAME 
  2740.     285 -- ERROR_DUPLICATE_NAME 
  2741.     290 -- ERROR_TOO_MANY_HANDLES 
  2742.  
  2743.  Notes 
  2744.  
  2745.  If the return code is non-zero, handleVar is not created or modified. 
  2746.  
  2747.  See also 
  2748.  
  2749.  SemMutexOpen, SemMutexClose. 
  2750.  
  2751.  Examples 
  2752.  
  2753.  To create a mutex semaphore: 
  2754.  
  2755.       call SemMutexCreate 'sem', '\SEM32\MY_SEMAPHORE'
  2756.       if result \= 0 then signal SemCreateError
  2757.  
  2758.  
  2759. ΓòÉΓòÉΓòÉ 7.12. SemMutexOpen function ΓòÉΓòÉΓòÉ
  2760.  
  2761.  
  2762. Syntax 
  2763.  
  2764. rc = SemMutexOpen(handleVar, name) 
  2765. rc = SemMutexOpen(semHandle) 
  2766.  
  2767. Description 
  2768.  
  2769. SemMutexOpen is used to open either a named mutex semaphore (first form), or a 
  2770. shared unnamed mutex semaphore (second form). 
  2771.  
  2772. Arguments 
  2773.  
  2774.  handleVar      is the name of a variable which will receive the handle to the 
  2775.                 mutex semaphore. 
  2776.  
  2777.  name           specifies the name for the semaphore. It must have the form: 
  2778.  
  2779.                     \SEM32\semName 
  2780.  
  2781.                 where: 
  2782.  
  2783.           semName                 is the name of the semaphore. 
  2784.  
  2785.  semHandle      is a handle to a shared unnamed mutex semaphore.  This handle 
  2786.                 has to be obtained from the process which created the 
  2787.                 semaphore. 
  2788.  
  2789.  Returns 
  2790.  
  2791.  SemMutexOpen returns the code supplied by the DosOpenMutexSem system 
  2792.  directive. 
  2793.  
  2794.  Expected: 
  2795.  
  2796.     000 -- NO_ERROR 
  2797.     006 -- ERROR_INVALID_HANDLE 
  2798.     008 -- ERROR_NOT_ENOUGH_MEMORY 
  2799.     105 -- ERROR_SEM_OWNER_DIED 
  2800.     123 -- ERROR_INVALID_NAME 
  2801.     187 -- ERROR_SEM_NOT_FOUND 
  2802.     291 -- ERROR_TOO_MANY_OPENS 
  2803.  
  2804.  Notes 
  2805.  
  2806.  If the return code is non-zero, handleVar is not created or modified. 
  2807.  
  2808.  See also 
  2809.  
  2810.  SemMutexCreate, SemMutexClose. 
  2811.  
  2812.  Examples 
  2813.  
  2814.  To open a named mutex semaphore: 
  2815.  
  2816.       call SemMutexOpen 'sem', '\SEM32\A_NAMED_SEMAPHORE'
  2817.       if result \= 0 then signal SemOpenError
  2818.  
  2819.  
  2820. ΓòÉΓòÉΓòÉ 7.13. SemMutexQuery function ΓòÉΓòÉΓòÉ
  2821.  
  2822.  
  2823. Syntax 
  2824.  
  2825. rc = SemMutexQuery(semHandle, [ processIdVar ], [ threadIdVar ], [ countVar ]) 
  2826.  
  2827. Description 
  2828.  
  2829. SemMutexQuery queries informations from a mutex semaphore. 
  2830.  
  2831. Arguments 
  2832.  
  2833.  semHandle      as obtained from SemMutexCreate or SemMutexOpen. 
  2834.  
  2835.  processIdVar   if present, is the name of the variable which will receive the 
  2836.                 id of the owner process. 
  2837.  
  2838.  threadIdVar    if present, is the name of the variable which will receive the 
  2839.                 id of the owner thread. 
  2840.  
  2841.  countVar       if present, is the name of the variable which will receive the 
  2842.                 request count from the owner process.  If the semaphore is 
  2843.                 unowned, the count is zero. 
  2844.  
  2845.  Returns 
  2846.  
  2847.  SemMutexQuery returns the code supplied by the DosQueryMutexSem system 
  2848.  directive. 
  2849.  
  2850.  Expected: 
  2851.  
  2852.     000 -- NO_ERROR 
  2853.     006 -- ERROR_INVALID_HANDLE 
  2854.     105 -- ERROR_SEM_OWNER_DIED 
  2855.  
  2856.  See also 
  2857.  
  2858.  SemMutexRequest, SemMutexRelease. 
  2859.  
  2860.  Examples 
  2861.  
  2862.  To query a mutex semaphore: 
  2863.  
  2864.       call SemMutexQuery sem, 'processId', 'threadId', 'count'
  2865.       if result \= 0 then signal SemQueryError
  2866.       say 'Semaphore post count:' count
  2867.       if count \= 0 then
  2868.       do
  2869.           say 'Semaphore owner process:' processId
  2870.           say 'Semaphore owner thread:' threadId
  2871.       end
  2872.  
  2873.  
  2874. ΓòÉΓòÉΓòÉ 7.14. SemMutexRelease function ΓòÉΓòÉΓòÉ
  2875.  
  2876.  
  2877. Syntax 
  2878.  
  2879. rc = SemMutexRelease(semHandle) 
  2880.  
  2881. Description 
  2882.  
  2883. SemMutexRelease releases a mutex semaphore. 
  2884.  
  2885. Arguments 
  2886.  
  2887.  semHandle      as obtained from SemMutexCreate or SemMutexOpen. 
  2888.  
  2889.  Returns 
  2890.  
  2891.  SemMutexRelease returns the code supplied by the DosReleaseMutexSem system 
  2892.  directive. 
  2893.  
  2894.  Expected: 
  2895.  
  2896.     000 -- NO_ERROR 
  2897.     006 -- ERROR_INVALID_HANDLE 
  2898.     288 -- ERROR_NOT_OWNER 
  2899.  
  2900.  See also 
  2901.  
  2902.  SemMutexRequest, SemMutexQuery. 
  2903.  
  2904.  Examples 
  2905.  
  2906.  To release a mutex semaphore: 
  2907.  
  2908.       call SemMutexRelease sem
  2909.       if result \= 0 then signal SemReleaseError
  2910.  
  2911.  
  2912. ΓòÉΓòÉΓòÉ 7.15. SemMutexRequest function ΓòÉΓòÉΓòÉ
  2913.  
  2914.  
  2915. Syntax 
  2916.  
  2917. rc = SemMutexRequest(semHandle, [ timeout ]) 
  2918.  
  2919. Description 
  2920.  
  2921. SemMutexRequest requests to be the owner of a mutex semaphore. 
  2922.  
  2923. Arguments 
  2924.  
  2925.  semHandle      as obtained from SemMutexCreate or SemMutexOpen. 
  2926.  
  2927.  timeout        is the wait timeout in milliseconds.  A value of -1 means an 
  2928.                 infinite wait;  this is the default. 
  2929.  
  2930.  Returns 
  2931.  
  2932.  SemMutexRequest returns the code supplied by the DosRequestMutexSem system 
  2933.  directive. 
  2934.  
  2935.  Expected: 
  2936.  
  2937.     000 -- NO_ERROR 
  2938.     006 -- ERROR_INVALID_HANDLE 
  2939.     095 -- ERROR_INTERRUPT 
  2940.     103 -- ERROR_TOO_MANY_SEM_REQUESTS 
  2941.     105 -- ERROR_SEM_OWNER_DIED 
  2942.     640 -- ERROR_TIMEOUT 
  2943.  
  2944.  See also 
  2945.  
  2946.  SemMutexCreate, SemMutexRelease, SemMutexQuery. 
  2947.  
  2948.  Examples 
  2949.  
  2950.  To request a mutex semaphore: 
  2951.  
  2952.       call SemMutexRequest sem
  2953.       if result \= 0 then signal SemRequestError
  2954.  
  2955.  
  2956. ΓòÉΓòÉΓòÉ 7.16. SemMuxwaitAdd function ΓòÉΓòÉΓòÉ
  2957.  
  2958.  
  2959. Syntax 
  2960.  
  2961. rc = SemMuxwaitAdd(semHandle, otherSemHandle, [ userValue ]) 
  2962.  
  2963. Description 
  2964.  
  2965. SemMuxwaitAdd adds a semaphore to the associated semaphores list. 
  2966.  
  2967. Arguments 
  2968.  
  2969.  semHandle      as obtained from SemMuxwaitCreate or SemMuxwaitOpen. 
  2970.  
  2971.  otherSemHandle as obtained from SemEventCreate, SemEventOpen, SemMutexCreate, 
  2972.                 or SemMutexOpen. 
  2973.  
  2974.  userValue      a numeric value to be returned by SemMuxwaitWait. 
  2975.  
  2976.  Returns 
  2977.  
  2978.  SemMuxwaitAdd returns the code supplied by the DosAddMuxWaitSem system 
  2979.  directive. 
  2980.  
  2981.  Expected: 
  2982.  
  2983.     000 -- NO_ERROR 
  2984.     006 -- ERROR_INVALID_HANDLE 
  2985.     008 -- ERROR_NOT_ENOUGH_MEMORY 
  2986.     100 -- ERROR_TOO_MANY_SEMAPHORES 
  2987.     105 -- ERROR_SEM_OWNER_DIED 
  2988.     284 -- ERROR_DUPLICATE_HANDLE 
  2989.     292 -- ERROR_WRONG_TYPE 
  2990.  
  2991.  See also 
  2992.  
  2993.  SemMuxwaitCreate, SemMuxwaitOpen, SemMuxwaitRemove, SemEventCreate, 
  2994.  SemEventOpen, SemMutexCreate, SemMutexOpen. 
  2995.  
  2996.  Examples 
  2997.  
  2998.  To add an event semaphore to a muxwait semaphore: 
  2999.  
  3000.       call SemEventCreate 'eventSem'
  3001.       if result \= 0 then signal SemCreateError
  3002.       call SemMuxwaitAdd muxSem, eventSem, 1
  3003.       if result \= 0 then signal SemAddError
  3004.  
  3005.  
  3006. ΓòÉΓòÉΓòÉ 7.17. SemMuxwaitClose function ΓòÉΓòÉΓòÉ
  3007.  
  3008.  
  3009. Syntax 
  3010.  
  3011. rc = SemMuxwaitClose(semHandle) 
  3012.  
  3013. Description 
  3014.  
  3015. SemMuxwaitClose closes a muxwait semaphore. 
  3016.  
  3017. Arguments 
  3018.  
  3019.  semHandle      as obtained from SemMuxwaitCreate or SemMuxwaitOpen. 
  3020.  
  3021.  Returns 
  3022.  
  3023.  SemMuxwaitClose returns the code supplied by the DosCloseMuxWaitSem system 
  3024.  directive. 
  3025.  
  3026.  Expected: 
  3027.  
  3028.     000 -- NO_ERROR 
  3029.     006 -- ERROR_INVALID_HANDLE 
  3030.     301 -- ERROR_SEM_BUSY 
  3031.  
  3032.  See also 
  3033.  
  3034.  SemMuxwaitCreate, SemMuxwaitOpen. 
  3035.  
  3036.  Examples 
  3037.  
  3038.  To close a muxwait semaphore: 
  3039.  
  3040.       call SemMuxwaitClose sem
  3041.       if result \= 0 then signal SemCloseError
  3042.  
  3043.  
  3044. ΓòÉΓòÉΓòÉ 7.18. SemMuxwaitCreate function ΓòÉΓòÉΓòÉ
  3045.  
  3046.  
  3047. Syntax 
  3048.  
  3049. rc = SemMuxwaitCreate(handleVar, [ name ], mode) 
  3050.  
  3051. Description 
  3052.  
  3053. SemMuxwaitCreate is used to create a muxwait semaphore. 
  3054.  
  3055. Arguments 
  3056.  
  3057.  handleVar      is the name of a variable which will receive the handle to the 
  3058.                 muxwait semaphore. 
  3059.  
  3060.  name           specifies the name for the semaphore. If present, it must have 
  3061.                 the form: 
  3062.  
  3063.                     \SEM32\semName 
  3064.  
  3065.                 where: 
  3066.  
  3067.           semName                 is the name of the semaphore. 
  3068.  
  3069.                 If a name is not specified, the keyword Shared (case 
  3070.                 insensitive and may be abbreviated) can be used to create a 
  3071.                 shared unnamed semaphore; otherwise a local semaphore is 
  3072.                 created. 
  3073.  
  3074.  mode           is the muxwait semaphore wait mode.  It must be one of the 
  3075.                 following keywords: 
  3076.  
  3077.           And                     wait for all associated semaphores; 
  3078.  
  3079.           Or                      wait for any associated semaphore. 
  3080.  
  3081.                 The keywords are case insensitive and may be abbreviated. 
  3082.  
  3083.  Returns 
  3084.  
  3085.  SemMuxwaitCreate returns the code supplied by the DosCreateMuxWaitSem system 
  3086.  directive. 
  3087.  
  3088.  Expected: 
  3089.  
  3090.     000 -- NO_ERROR 
  3091.     008 -- ERROR_NOT_ENOUGH_MEMORY 
  3092.     123 -- ERROR_INVALID_NAME 
  3093.     285 -- ERROR_DUPLICATE_NAME 
  3094.     290 -- ERROR_TOO_MANY_HANDLES 
  3095.  
  3096.  Notes 
  3097.  
  3098.  If the return code is non-zero, handleVar is not created or modified. 
  3099.  
  3100.  See also 
  3101.  
  3102.  SemMuxwaitAdd, SemMuxwaitClose, SemMuxwaitOpen, SemMuxwaitWait. 
  3103.  
  3104.  Examples 
  3105.  
  3106.  To create a muxwait semaphore: 
  3107.  
  3108.       call SemMuxwaitCreate 'sem', '\SEM32\MY_MUXWAIT_SEM', 'Or'
  3109.       if result \= 0 then signal SemCreateError
  3110.  
  3111.  
  3112. ΓòÉΓòÉΓòÉ 7.19. SemMuxwaitOpen function ΓòÉΓòÉΓòÉ
  3113.  
  3114.  
  3115. Syntax 
  3116.  
  3117. rc = SemMuxwaitOpen(handleVar, name) 
  3118. rc = SemMuxwaitOpen(semHandle) 
  3119.  
  3120. Description 
  3121.  
  3122. SemMuxwaitOpen is used to open either a named muxwait semaphore (first form), 
  3123. or a shared unnamed muxwait semaphore (second form). 
  3124.  
  3125. Arguments 
  3126.  
  3127.  handleVar      is the name of a variable which will receive the handle to the 
  3128.                 muxwait semaphore. 
  3129.  
  3130.  name           specifies the name for the semaphore. It must have the form: 
  3131.  
  3132.                     \SEM32\semName 
  3133.  
  3134.                 where: 
  3135.  
  3136.           semName                 is the name of the semaphore. 
  3137.  
  3138.  semHandle      is a handle to a shared unnamed muxwait semaphore.  This handle 
  3139.                 has to be obtained from the process which created the 
  3140.                 semaphore. 
  3141.  
  3142.  Returns 
  3143.  
  3144.  SemMuxwaitOpen returns the code supplied by the DosOpenMuxWaitSem system 
  3145.  directive. 
  3146.  
  3147.  Expected: 
  3148.  
  3149.     000 -- NO_ERROR 
  3150.     006 -- ERROR_INVALID_HANDLE 
  3151.     008 -- ERROR_NOT_ENOUGH_MEMORY 
  3152.     105 -- ERROR_SEM_OWNER_DIED 
  3153.     123 -- ERROR_INVALID_NAME 
  3154.     187 -- ERROR_SEM_NOT_FOUND 
  3155.     291 -- ERROR_TOO_MANY_OPENS 
  3156.  
  3157.  Notes 
  3158.  
  3159.  If the return code is non-zero, handleVar is not created or modified. 
  3160.  
  3161.  See also 
  3162.  
  3163.  SemMuxwaitCreate, SemMuxwaitClose. 
  3164.  
  3165.  Examples 
  3166.  
  3167.  To open a named muxwait semaphore: 
  3168.  
  3169.       call SemMuxwaitOpen 'sem', '\SEM32\A_NAMED_MUXWAIT_SEM'
  3170.       if result \= 0 then signal SemOpenError
  3171.  
  3172.  
  3173. ΓòÉΓòÉΓòÉ 7.20. SemMuxwaitRemove function ΓòÉΓòÉΓòÉ
  3174.  
  3175.  
  3176. Syntax 
  3177.  
  3178. rc = SemMuxwaitRemove(semHandle, otherSemHandle) 
  3179.  
  3180. Description 
  3181.  
  3182. SemMuxwaitRemove removes a semaphore from the associated semaphores list. 
  3183.  
  3184. Arguments 
  3185.  
  3186.  semHandle      as obtained from SemMuxwaitCreate or SemMuxwaitOpen. 
  3187.  
  3188.  otherSemHandle as obtained from SemEventCreate, SemEventOpen, SemMutexCreate, 
  3189.                 or SemMutexOpen. 
  3190.  
  3191.  Returns 
  3192.  
  3193.  SemMuxwaitRemove returns the code supplied by the DosDeleteMuxWaitSem system 
  3194.  directive. 
  3195.  
  3196.  Expected: 
  3197.  
  3198.     000 -- NO_ERROR 
  3199.     006 -- ERROR_INVALID_HANDLE 
  3200.     286 -- ERROR_EMPTY_MUXWAIT 
  3201.  
  3202.  See also 
  3203.  
  3204.  SemMuxwaitAdd. 
  3205.  
  3206.  Examples 
  3207.  
  3208.  To remove an event semaphore from a muxwait semaphore: 
  3209.  
  3210.       call SemMuxwaitRemove muxSem, eventSem
  3211.       if result \= 0 then signal SemRemoveError
  3212.  
  3213.  
  3214. ΓòÉΓòÉΓòÉ 7.21. SemMuxwaitWait function ΓòÉΓòÉΓòÉ
  3215.  
  3216.  
  3217. Syntax 
  3218.  
  3219. rc = SemMuxwaitWait(semHandle, [ timeout ], [ userVar ]) 
  3220.  
  3221. Description 
  3222.  
  3223. SemMuxwaitWait waits for a muxwait semaphore. 
  3224.  
  3225. Arguments 
  3226.  
  3227.  semHandle      as obtained from SemMuxwaitCreate or SemMuxwaitOpen. 
  3228.  
  3229.  timeout        is the wait timeout in milliseconds.  A value of -1 means an 
  3230.                 infinite wait;  this is the default. 
  3231.  
  3232.  userVar        is the name of a variable which will receive the optional value 
  3233.                 specified with the SemMuxwaitAdd function. 
  3234.  
  3235.  Returns 
  3236.  
  3237.  SemMuxwaitWait returns the code supplied by the DosWaitMuxWaitSem system 
  3238.  directive. 
  3239.  
  3240.  Expected: 
  3241.  
  3242.     000 -- NO_ERROR 
  3243.     006 -- ERROR_INVALID_HANDLE 
  3244.     008 -- ERROR_NOT_ENOUGH_MEMORY 
  3245.     095 -- ERROR_INTERRUPT 
  3246.     105 -- ERROR_SEM_OWNER_DIED 
  3247.     286 -- ERROR_EMPTY_MUXWAIT 
  3248.     287 -- ERROR_MUTEX_OWNED 
  3249.     640 -- ERROR_TIMEOUT 
  3250.  
  3251.  See also 
  3252.  
  3253.  SemMuxwaitAdd. 
  3254.  
  3255.  Examples 
  3256.  
  3257.  To wait for a muxwait semaphore: 
  3258.  
  3259.       call SemMuxwaitWait sem
  3260.       if result \= 0 then signal SemWaitError
  3261.  
  3262.  
  3263. ΓòÉΓòÉΓòÉ 7.22. SemStartTimer function ΓòÉΓòÉΓòÉ
  3264.  
  3265.  
  3266. Syntax 
  3267.  
  3268. rc = SemStartTimer([ handleVar ], interval, semHandle, [ type ]) 
  3269.  
  3270. Description 
  3271.  
  3272. SemStartTimer is used to create and start a timer which will post a shared 
  3273. event semaphore. 
  3274.  
  3275. Arguments 
  3276.  
  3277.  handleVar      is the name of a variable which will receive the handle to the 
  3278.                 timer. 
  3279.  
  3280.  interval       is the time interval in milliseconds. 
  3281.  
  3282.  semHandle      is a shared event semaphore handle as obtained from 
  3283.                 SemEventCreate or SemEventOpen. 
  3284.  
  3285.  type           is the timer type.  It must be one of the following keywords: 
  3286.  
  3287.           Repeat                  the timer will repeat; 
  3288.  
  3289.           Single                  the timer will execute only once; this is the 
  3290.                                   default. 
  3291.  
  3292.                 The keywords are case insensitive and may be abbreviated. 
  3293.  
  3294.  Returns 
  3295.  
  3296.  SemStartTimer returns the code supplied by the DosAsyncTimer or DosStartTimer 
  3297.  system directive. 
  3298.  
  3299.  Expected: 
  3300.  
  3301.     000 -- NO_ERROR 
  3302.     323 -- ERROR_TS_SEMHANDLE 
  3303.     324 -- ERROR_TS_NOTIMER 
  3304.  
  3305.  Notes 
  3306.  
  3307.  If the return code is non-zero, handleVar is not created or modified. 
  3308.  
  3309.  See also 
  3310.  
  3311.  SemStopTimer, SemEventCreate, SemEventWait. 
  3312.  
  3313.  Examples 
  3314.  
  3315.  To start a timer and wait until it fires (60 seconds): 
  3316.  
  3317.       call SemEventCreate 'timerSem', 'Shared'
  3318.       if result \= 0 then signal SemCreateError
  3319.  
  3320.       call SemStartTimer , 60 * 1000, timerSem
  3321.       if result \= 0 then signal TimerStartError
  3322.  
  3323.       call SemEventWait timerSem
  3324.       if result \= 0 then signal SemWaitError
  3325.  
  3326.  
  3327. ΓòÉΓòÉΓòÉ 7.23. SemStopTimer function ΓòÉΓòÉΓòÉ
  3328.  
  3329.  
  3330. Syntax 
  3331.  
  3332. rc = SemStopTimer(timerHandle) 
  3333.  
  3334. Description 
  3335.  
  3336. SemStopTimer is used to stop a timer started with SemStartTimer. 
  3337.  
  3338. Arguments 
  3339.  
  3340.  timerHandle    is the handle created by SemStartTimer. 
  3341.  
  3342.  Returns 
  3343.  
  3344.  SemStopTimer returns the code supplied by the DosStopTimer system directive. 
  3345.  
  3346.  Expected: 
  3347.  
  3348.     000 -- NO_ERROR 
  3349.     326 -- ERROR_TS_HANDLE 
  3350.  
  3351.  See also 
  3352.  
  3353.  SemStartTimer.