home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / RXNETB.ZIP / TESTS.CMD < prev   
OS/2 REXX Batch file  |  1992-10-03  |  4KB  |  80 lines

  1. /*                                                               */
  2. /*      REXX/NETBIOS Sample Client Pgm                           */
  3. /*                                                               */
  4. /*                                                               */
  5. /*      Tell REXX there is a new function available              */
  6. /*                                                               */
  7.  
  8. call rxfuncadd 'netbios', 'rexxnetb', 'netbiossrv'
  9.  
  10.  
  11. /*                                                               */
  12. /*      Client station name, must be 16 bytes                    */
  13. /*                                                               */
  14.  
  15. Myname=left('Test',16,' ')
  16. RemoteName =left('Sample',16,' ')
  17.  
  18. /*                                                               */
  19. /*      call netbios and get resources from the global pool      */
  20. /*      defined in PROTOCOL.INI                                  */
  21. /*                                                               */
  22.  
  23. rc=netbios('Reset',0,1,1,1)
  24.  
  25. /*                                                               */
  26. /* if resources available                                        */
  27. /*                                                               */
  28.  
  29. if rc=0 then do
  30.  
  31. /*                                                               */
  32. /* add our name to the network, and get the name number          */
  33. /*                                                               */
  34.   parse value netbios('AddName',0,MyName) with rc name_num .
  35.  
  36. /*                                                               */
  37. /* If we are on the network now, call our partner                */
  38. /*                                                               */
  39.  
  40.   parse value netbios('Call',0,MyName,RemoteName,0,0) with rc lsn .
  41.  
  42. /*                                                               */
  43. /* If call succeeded send a message                              */
  44. /*                                                               */
  45.   if rc=0 then do
  46.     rc=netbios('Send',0,lsn,'test data')
  47. /*                                                               */
  48. /* If send succeeded wait for a response                         */
  49. /*                                                               */
  50.     if rc=0 then do
  51. /*                                                               */
  52. /* If receive succeeded report the received message              */
  53. /*                                                               */
  54.       rc=netbios('Receive',0,lsn,1000,'data.')
  55.       if rc=0 then do
  56.         say
  57.         say 'We received the following message from "' || strip(RemoteName) || '"'
  58.         say data.0
  59.       end
  60.       else say 'Receive failed rc=' || rc
  61.     end
  62.     else say 'Send failed rc=' || rc
  63. /*                                                               */
  64. /* end session now as we are done                                */
  65. /*                                                               */
  66.     call netbios 'Hangup',0,lsn
  67.   end
  68.  
  69. /*                                                               */
  70. /* return our netbios resources to the global pool               */
  71. /*                                                               */
  72.   call netbios 'Close',0
  73.  
  74. end
  75. /*                                                               */
  76. /* oops, either no Netbios resources are available or            */
  77. /*       Netbios is not installed                                */
  78. /*                                                               */
  79. else say 'Netbios resources not available rc='rc
  80.