home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_BAS / PRO98SRC.ZIP / CHAT.BAS < prev    next >
BASIC Source File  |  1994-01-08  |  8KB  |  243 lines

  1. SUB CHAT(Id$)
  2. $IF NOT %NOCHAT
  3. SHARED ChatFile$
  4. PROZOPRINT CrLf$+CrLf$+"You are now in CHAT mode.  Type /? for help."+CrLf$+CrLf$
  5. 'HEY: Chat file name needs to be in CONFIG
  6. ChatFile%=FREEFILE
  7. OPEN ChatFile$ FOR RANDOM SHARED AS #ChatFile% LEN=LEN(Comment)
  8. 'HEY: make chat file in config
  9. IF LOF(ChatFile%)=0 THEN GOSUB MakeChatFile
  10. ' find a free chat line
  11. FOR TEMP=1 to 7
  12. GET #ChatFile%, TEMP, Comment
  13. IF left$(Comment.ComUser,4) = "NONE" THEN User% = TEMP : Exit For
  14. Next TEMP
  15. if TEMP=7 THEN CLOSE #ChatFile%: PROZOPRINT CrLf$+"Too many CHATs in session..."+CrLf$:Exit SUB
  16. LET Comment.ComUser = Id$
  17. Let Comment.ComDate = Date$
  18. Let Comment.ComTime = Time$
  19. Let Comment.Line1 = Id$+" has entered CHAT"
  20. Comment.Line2 = "."
  21. Comment.Line3 = "."
  22. Comment.Line4 = "."
  23. Comment.Line5 = "."
  24. Comment.Line6 = "."
  25. Comment.Line7 = "."
  26. Comment.Line8 = "."
  27. Comment.Line9 = "."
  28. Let Comment.TaxID = "123456"
  29. LET User$ = mid$(Str$(User%),2)
  30.         LET TaxID$=Comment.TaxID '.............mask out your own intro
  31.         REPLACE User$ WITH " " IN TaxID$
  32.         Let Comment.TaxID = TaxID$
  33. Put #ChatFile%, User%, Comment
  34. GOSUB BFLUSH
  35. PROZOPRINT CrLf$+"You are in chat slot #"+mid$(str$(user%),2)+CrLf$
  36.  
  37. For TEMP=1 TO 6 '........................... mask out unread comments
  38.     GET #ChatFile%, TEMP, Comment
  39.         LET TaxID$=Comment.TaxID
  40.         REPLACE User$ WITH " " IN TaxID$
  41.         Let Comment.TaxID = TaxID$
  42.     PUT #ChatFile%, TEMP, Comment
  43. Next TEMP
  44. GOSUB BFLUSH
  45. ''' ON TIMER(2) GOSUB Check
  46. ''' TIMER ON
  47. timestart:
  48. ts#=TIMER+2
  49. idle:
  50. CALL DVPAUSE
  51. $IF NOT %NOTASKS
  52. CALL TASKMAN
  53. $ENDIF
  54. REM FORK WENT HERE
  55. IF TIMER > TS# THEN GOSUB Check:GETOLM:GOTO TimeStart
  56. IF WaitStat% THEN
  57.     ''' TIMER STOP
  58.         Ln%=0
  59.         for i%=1 to 9:c$(i%)=".":next i%
  60.         fin%=0
  61.         DO
  62.         Incr Ln%
  63.                 PROZOPRINT " --> "
  64.             Value$ = ""
  65.             DO
  66.               DO
  67.                 CALL DVPAUSE
  68.                 A$=INKEY$
  69.                 IF Comline THEN IF ComChars% THEN A$ = COMINKEY$
  70.                 IF LEN(A$) THEN CharType% = 1:_
  71.                 CharCode% = ASCII(A$) else CharType%=0:CharCode%=0
  72. $IF NOT %NOTASKS
  73. CALL TASKMAN
  74. $ENDIF
  75. REM FORK WENT HERE
  76.               LOOP WHILE CharType% = 0
  77.             IF CharCode% = 13 THEN LET fin%=1
  78.             IF CharCode% = 32 AND LEN(Value$) > 65 THEN_
  79.              LET CharCode% = 13
  80.  
  81.             SELECT CASE CharCode%
  82.                 CASE 9
  83.                                         IF LEN(Value$) < LEN(OldValue$) THEN A$ = MID$(OldValue$, LEN(Value$) + 1, 1): Value$ = Value$ + A$: PROZOPRINT A$
  84.                 CASE 13
  85.                                         PROZOPRINT CrLf$: EXIT DO
  86.                 CASE 8
  87.                                         IF LEN(Value$) THEN Value$ = LEFT$(Value$, LEN(Value$) - 1): PROZOPRINT CHR$(8) + CHR$(32) + CHR$(8)
  88.                 CASE 3
  89.                                         FOR backs = 1 TO LEN(Value$): PROZOPRINT CHR$(8) + "!" + CHR$(8): NEXT backs: Value$ = ""
  90.                 EXIT DO
  91.                     CASE 27, 21
  92.                                         FOR backs = 1 TO LEN(Value$): PROZOPRINT CHR$(8) + CHR$(32) + CHR$(8): NEXT backs: Value$ = ""
  93.  
  94.                 CASE 7
  95.                                         PROZOPRINT "*Page!*" + STRING$(7,8):EFFECT "PAGE"
  96.  
  97.                 CASE ELSE
  98.                         IF CharCode% > 31 THEN Value$ = Value$ + A$: PROZOPRINT A$
  99.             END SELECT
  100.  
  101.         IF INSTR(Value$, "++") THEN Die%=1:Goto ExitChat
  102.  
  103.         LOOP
  104.         IF CharCode% = 3 THEN Die%=1:Goto ExitChat
  105.         IF CharCode% = 27 THEN Goto ExitChat
  106.         IF LEN(Value$) > 3 THEN OldValue$ = Value$
  107.  
  108.                 IF Left$(Value$,1)="/" and Len(Value$)>1 THEN
  109.             P$=MID$(Value$,2)
  110.             Select Case Mid$(UCASE$(Value$),2,1)
  111.                                 CASE "H", "?"
  112.                                  PROZOPRINT "Slash (/) commands:"+CrLf$
  113.                                  PROZOPRINT "/? or /H = Help"+CrLf$
  114.                                  PROZOPRINT "      /Q = Quit Chat"+CrLf$
  115.                                  PROZOPRINT "      /W = Who's online"+CrLf$
  116.                                  PROZOPRINT "      /N = Nothing"+CrLf$
  117.                                 CASE "W"
  118.                                 For i%=1 to 6
  119.                                         GET #ChatFile%, i%, Comment
  120. PROZOPRINT "^B^" + MID$("rgywcm",i%,1) + Str$(i%)+":"+Comment.ComUser+CrLf$
  121.                                 Next i%
  122.  
  123.                                 CASE "K"
  124.                 GOSUB MakeChatFile
  125.                 CASE "Q"
  126.                                 LET Comment.ComUser = Global$(1)
  127.                                 Let Comment.ComDate = Date$
  128.                                 Let Comment.ComTime = Time$
  129.                                 Let Comment.Line1 = global$(1)+" has exited CHAT"
  130.                                 Comment.Line2 = "."
  131.                                 Comment.Line3 = "."
  132.                                 Comment.Line4 = "."
  133.                                 Comment.Line5 = "."
  134.                                 Comment.Line6 = "."
  135.                                 Comment.Line7 = "."
  136.                                 Comment.Line8 = "."
  137.                                 Comment.Line9 = "."
  138.                                 Let Comment.TaxID = "123456"
  139.                                 LET User$ = mid$(Str$(User%),2)
  140.                                 LET TaxID$=Comment.TaxID '.............mask out your own intro
  141.                                 REPLACE User$ WITH " " IN TaxID$
  142.                                 Let Comment.TaxID = TaxID$
  143.                                 Put #ChatFile%, User%, Comment
  144.                                 GOSUB BFLUSH
  145.  
  146.                                 ExF%=1
  147.                 CASE ELSE
  148.             END SELECT
  149.  
  150.         EXIT DO
  151.         END IF
  152.  
  153.         C$(Ln%) = Value$
  154.  
  155.         IF fin% or Ln% = 9 THEN EXIT DO
  156.         LOOP
  157.         fin%=0
  158.         IF Left$(Value$,1)<>"/" THEN
  159.  
  160.             Comment.Line1 = c$(1)
  161.             Comment.Line2 = c$(2)
  162.             Comment.Line3 = c$(3)
  163.             Comment.Line4 = c$(4)
  164.             Comment.Line5 = c$(5)
  165.             Comment.Line6 = c$(6)
  166.             Comment.Line7 = c$(7)
  167.             Comment.Line8 = c$(8)
  168.             Comment.Line9 = c$(9)
  169.              Let Comment.ComUser=Id$
  170.              Let Comment.ComTime=Time$
  171.              Let Comment.ComDate=Date$
  172.              Let Comment.TaxID="123456"
  173.                         LET TaxID$=Comment.TaxID
  174.                         REPLACE User$ WITH " " IN TaxID$
  175.                         Let Comment.TaxID = TaxID$
  176.              PUT #ChatFile%, User%, Comment
  177.              GOSUB BFLUSH
  178.         END IF
  179.  
  180.     ''' TIMER ON
  181.  
  182. END IF
  183.   IF TIMER > UserTime# THEN PROZOPRINT CHR$(7): CALL TIMEOUT
  184.   IF ExF%=1 THEN GOTO ExitChat
  185.  
  186. goto Idle
  187.  
  188.  
  189. Check:
  190. GOSUB BFLUSH
  191. For TEMP=1 to 6
  192.     Get #ChatFile%, TEMP, Comment
  193.     IF Mid$(Comment.TaxID,User%,1)=User$ THEN
  194.         C$(1) = Comment.Line1
  195.         C$(2) = Comment.Line2
  196.         C$(3) = Comment.Line3
  197.         C$(4) = Comment.Line4
  198.         C$(5) = Comment.Line5
  199.         C$(6) = Comment.Line6
  200.         C$(7) = Comment.Line7
  201.         C$(8) = Comment.Line8
  202.         C$(9) = Comment.Line9
  203.         TaxID$=Comment.TaxID
  204.         REPLACE User$ WITH " " IN TaxID$
  205.         Let Comment.TaxID = TaxID$
  206.         Put #ChatFile%, TEMP, Comment
  207.         GOSUB BFLUSH
  208.         FOR i%= 1 TO 9
  209.         IF Len(rtrim$(C$(i%))) > 1 THEN_
  210.                    PROZOPRINT "^B^" + MID$("rgywcm",TEMP,1) + Comment.ComUser+"->"+rtrim$(C$(i%))+"^0"+ CrLf$
  211.         NEXT i%
  212.     END IF
  213. Next TEMP
  214. RETURN
  215.  
  216. ExitChat:
  217.     ''' TIMER OFF
  218.     LET Comment.ComUser="NONE"
  219.     PUT #ChatFile%, User%, Comment
  220.     close #ChatFile%
  221.     IF Die%=1 THEN ERROR 1
  222.     EXIT SUB
  223.  
  224. MakeChatFile:
  225.         PROZOPRINT "Making Chat file..."+CrLf$
  226.     FOR TEMP=1 TO 7
  227.     LET Comment.ComUser="NONE"
  228.     PUT #ChatFile%, TEMP, Comment
  229.     Next TEMP
  230.     CLOSE #ChatFile%
  231.         PROZOPRINT "Done..."+CrLf$
  232.     OPEN ChatFile$ FOR RANDOM SHARED_
  233.                 AS #ChatFile% LEN=LEN(Comment)
  234.         RETURN
  235.  
  236. BFLUSH:
  237.     CLOSE #ChatFile%
  238.     OPEN ChatFile$ FOR RANDOM SHARED_
  239.                 AS #ChatFile% LEN=LEN(Comment)
  240.     RETURN
  241. $ENDIF
  242. END SUB
  243.