home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / new / comm / bbs / 4d-bbsdemo / arexx / 4dmultichat.rexx < prev    next >
OS/2 REXX Batch file  |  1993-12-28  |  5KB  |  268 lines

  1. /*   Program         :   4DMultiChat.rexx
  2.  *   Copyright       :   © Copyright 1993 Robert T. Davis and CornerStone Software
  3.  *   Author          :   Dale E. Reed Jr. and Robert T. Davis 
  4.  *   Creation Date   :   September 5, 1993
  5.  *   Current version :   1.1d
  6.  *   Translator      :   AREXX/4D-BBS
  7.  *
  8.  *
  9.  *   This Program lets multiple users "chat" with each other in a public
  10.  *   on-line forum.
  11.  *
  12.  *   REVISION HISTORY
  13.  *
  14.  *    Date           Version        Comment
  15.  *    ---------      -------        ------------------------------------------
  16.  *    24-AUG-93      0.90a          4D-BBS Internode conference, Created
  17.  *
  18.  *    05-Sep-93      1.1d           Polished up several problems. Got it working!
  19.  *
  20.  */
  21.  
  22. options results
  23. signal on syntax
  24. signal on error
  25.  
  26. ARG port stdio
  27.  
  28. logfile='Text:Logs/ConfError.Log'
  29.  
  30. IF length(port)=0 THEN
  31.     port = '4D-BBS'
  32.  
  33. MAXLINES    = 10                            /* optimize to your # of lines */
  34. basename    = port                        /* for strippage later ;)      */
  35. thisline    = port                        /* Name of this port           */
  36. users        = 0                            /* for user command whos here  */
  37. running    = 1                            /* flag set if we are running  */
  38.  
  39.  
  40. if datatype( right(basename,1)) = 'NUM' then
  41.     do
  42.     num        = right(basename,1)        /* our port number sendmessage */
  43.     basename=left(basename, (length(basename)-1))
  44.     end
  45.  
  46. else if datatype( right(basename,2)) = 'NUM' then
  47.     do
  48.     num        = right(basename,2)        /* our port number sendmessage */
  49.     basename=left(basename, (length(basename)-2))
  50.     end
  51.     
  52.  
  53.  
  54. address value(thisline)
  55.  
  56. 'userinfo' 'A'
  57. localname=RESULT
  58.  
  59. call sas(' SR%SR%6 4D-BBS 4Multiuser Chat        6Enter /Q to quit or /? for Help')
  60. call sas('3---------------------------------------------------------------')
  61. call sas('0SR%SR%')
  62.  
  63. /*
  64.     call sendmessage('Just Entered The Public Chat Forum')
  65. */
  66.  
  67. do FOREVER
  68.  
  69.     address value(thisline)        /* Just in case !!! */
  70.     'systemstatus' 80
  71.  
  72.     mqprompt num||">>" /* this will display messages until a key is pressed */
  73.     memo = RESULT
  74.  
  75.     if left(memo,1) = '/' then
  76.         call user_command( left(memo,2) )
  77.  
  78.     else if memo ~= '' then
  79.         call sendmessage(memo)
  80.  
  81.     if ~running then BREAK
  82.  
  83. end    /* FOREVER LOOP */
  84.  
  85.  
  86. /**********************/
  87. /* cleanup and go    */
  88. /********************/
  89.  
  90. leave:
  91.  
  92.     address value(thisline)        /* Just in case !!! */
  93.     'systemstatus' 17
  94.  
  95.     call sendmessage('Just Exited The Public Chat Forum')
  96.     call sendmessage(' ')
  97.  
  98.     shutdown
  99.     exit
  100.  
  101.  
  102.  
  103. /***********************************************************************/
  104. /* sendmessage:  Handles sending of strings to other copies of 4D-BBS  */  
  105. /***********************************************************************/
  106.  
  107.  
  108. sendmessage:
  109.  
  110. parse arg str
  111.  
  112. do numb = 0 to MAXLINES
  113.     
  114.     portname=basename||numb
  115.  
  116.     if show(p, portname) then
  117.         do
  118.  
  119.         address value(portname)
  120.  
  121.         'systemstatus' 0
  122.         st=RESULT
  123.  
  124.         /* send message to this system */
  125.  
  126.         bigstr = '('||num||') '||localname||': '||str
  127.  
  128.         if st = 80 then
  129.             messqueue bigstr
  130.  
  131.         end
  132.     end
  133.  
  134. return
  135.  
  136.  
  137. /***********************************************************************/
  138. /* user_command: Handles users commands while in conference mode       */  
  139. /***********************************************************************/
  140.  
  141. user_command:
  142.  
  143. parse arg CMD
  144.  
  145.     select
  146.  
  147.         when CMD = '/w' then do
  148.  
  149.             do numb=0 to MAXLINES
  150.     
  151.                 portname=basename||numb
  152.  
  153.                 if show(p, portname) then do
  154.  
  155.                     address value(portname)
  156.  
  157.                     first = ' '
  158.  
  159.                     'systemstatus' 0
  160.                     st=RESULT
  161.  
  162.                     if st = 80 then do
  163.             
  164.                         'userinfo' 'A'
  165.                         name=RESULT
  166.     
  167.                         'baud' '0'
  168.                         ubaud=RESULT
  169.  
  170.                         if ubaud = 0 then
  171.                             ubaud='LOCAL'
  172.  
  173.                         /* display users in conference */
  174.  
  175.                         bigstr = left(portname, 9, ' ') || first || left(name, 21, ' ') || left(ubaud, 8, ' ')
  176.  
  177.                         address value(thisline) /* switch back to local port */
  178.  
  179.                         call sas(bigstr)
  180.  
  181.                     end
  182.                 end
  183.             end
  184.             call sas('SR%')
  185.         end
  186.     
  187.         when CMD = '/q' then
  188.             running = 0
  189.  
  190.         when CMD = '/m' then
  191.             do
  192.             prompt 'Enter Line Number to Send to: '
  193.             sline=RESULT
  194.             
  195.             sportname=basename||sline
  196.             if show(p, sportname) then
  197.                 do
  198.                 address value(sportname)
  199.                 
  200.                 prompt 'Enter Message: '
  201.                 smess=RESULT
  202.                 smess=localname||' ('||num||'):'||smess
  203.                 messqueue smess 
  204.                 end
  205.             end
  206.  
  207.         when CMD = '/?' then
  208.             do
  209.             address value(thisline)
  210.             transmit 'SR%  /w - whos in chat mode'
  211.             transmit 'SR%  /m - send a message to someone'
  212.             transmit ' /q - quit chat mode'
  213.             end
  214.  
  215.         OTHERWISE transmit 'SR%3***0 Unknown command 3***0SR%'
  216. end
  217.  
  218. return
  219.  
  220.  
  221.  
  222. /*****************************************************************/
  223. /* this routine will handle printing to either the arexx port or */
  224. /* to this local stdio if the port name was "STDIO"              */
  225.  
  226.  
  227. sas:
  228.  
  229.     parse arg op
  230.  
  231.     if stdio ~= '' then
  232.         say op
  233.     else
  234.         do
  235.         address value(thisline)
  236.         transmit op
  237.         end
  238.  
  239. return
  240.  
  241.  
  242.  
  243. /*************************************************************
  244.  *                       ERROR HANDLING                      *
  245.  *************************************************************/
  246.  
  247. syntax:
  248.     parse source . . . me .
  249.  
  250.     if open(log, logfile, 'Append') = 1 then do
  251.         writeln(log, 'rc 'in line' sigl 'of' me')
  252.         close(log)
  253.         shutdown
  254.     end
  255. exit
  256.  
  257. error:
  258.     parse source . . . me .
  259.  
  260.     if rc < 1000 then do
  261.         if open(log, logfile, 'Append') = 1 then do
  262.             writeln(log, 'rc 'in line' sigl 'of' me')
  263.             close(log)
  264.             shutdown
  265.         end
  266.     end
  267. exit
  268.