home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / CDOR0811.ZIP / CDORMRGS.ZIP / ANSIED.MRG next >
Encoding:
Text File  |  1993-08-11  |  52.3 KB  |  1,356 lines

  1. * ------------[ BLED merge (c) Ken Goosens ]-------------
  2. * Merge this against ANSIED.BAS to produce ANSIED.NEW
  3. * ANSIED.BAS:  Date 2-16-91  Size 43992 bytes
  4. * ------------[ Created 08-11-1993 19:37:32 ]------------
  5. * REPLACING old line(s) by new
  6. * ------[ first line different ]------
  7. ' $segment
  8. ' $linesize:132
  9. ' $title: 'ANSIED.BAS'
  10. '*
  11. '*  ANSIED v2.44a  by Tom Collins 
  12. '*---------------------------------------------------------------------------
  13. '*  Full Screen Text Editor for RBBS-PC
  14. '*  QuickBASIC v4.5 Version
  15. '*  02-16-91
  16. '*
  17. '*  v2.1xx ... made it work with RBBS v17
  18. '*  v2.2 ..... fixed some inconsistincies in the code as to # of lines in msg.
  19. '*             Some of the code thought 99 was length, some thought 100.
  20. '*  v2.3 ..... let it work with quoted reply.  No more REDIM of ZOutTxt$
  21. '*  v2.4 ..... removed tabs, margins code to be smaller
  22. '*  v2.41..... fixed bug with loss of bold attribute occasionally
  23. '*  v2.42..... made it work as a v17.3 subroutine.  Added block delete.
  24. '*  v2.43..... Added to: and from:.  Made cursor keys work locally.
  25. '*  v2.43a.... Stupid little bugs fixed
  26. '*  v2.44..... Fixed bugs, added ^T, Import, Subject, ASM functions
  27. '*  v2.44a.... Wordwrap/reflow bug fixed.  Arrows work in del.  Lines renum.
  28. '*
  29. '*  Returns:
  30. '*  ZSubParm  =  1 - Save Message
  31. '*            =  2 - Abort Message
  32. '*            = -1 - Dropped Carrier
  33. '*            = -2 - Sleep Disconnect
  34. '*
  35. '* Compile with:
  36. '*   BC C:\RBBSARCS\ANSIED.BAS /O/T/C:512;
  37. '*
  38. '* Modifications to 2.44a by: Steve Stevens
  39. '* If you Like 'em let me know!
  40. '*       FIDONET 1:376/102                      RBBSNet 8:927/2
  41.  
  42. DECLARE SUB Ansied (T$, S$, L%)
  43. DECLARE SUB BackspChar ()
  44. DECLARE SUB CarrRetKey ()
  45. DECLARE SUB ChangeSubject ()
  46. DECLARE SUB ClearScreen ()
  47. DECLARE SUB DeleteCurrentLine (Index%)
  48. DECLARE SUB DisplayKeys ()
  49. DECLARE SUB DisplayMainMenu ()
  50. DECLARE SUB DoneWithMsg (YY$)
  51. DECLARE SUB EraseToEOL (LineNumber%, ColNumber%)
  52. DECLARE SUB MenuCommand (YY$)
  53. DECLARE SUB FindEndOfMsg (EndOfMsg%)
  54. DECLARE SUB FindWord (YY$, I%, NewCol%)
  55. DECLARE SUB FindWrap (YY$, WhereToWrap%)
  56. DECLARE SUB GetChar (YY$)
  57. DECLARE SUB GetString (Prompt$, YY$)
  58. DECLARE SUB HelpMe ()
  59. DECLARE SUB ImportFile ()
  60. DECLARE SUB LastParaLine (I%, LastLine%, Result%)
  61. DECLARE SUB MoveCurStr (CurrentRow%, CurrentCol%, NewRow%, NewCol%, YY$, YLen%)
  62. DECLARE SUB MoveCursor (NewRow%, NewCol%)
  63. DECLARE SUB NormalChar (YY$)
  64. DECLARE SUB PutScreen (YY$, Colour%, Bold%)
  65. DECLARE SUB ReformText (Justify%)
  66. DECLARE SUB SaveCursor (Row%, Col%)
  67. DECLARE SUB UnString (YY$, BadString$)
  68. DECLARE SUB UnGetChar (X%)
  69. DECLARE SUB UpdateScreen ()
  70. DECLARE SUB UpdateStatusLine (How%)
  71.  
  72. DECLARE SUB BufFile (FileName$, Z%)
  73. DECLARE SUB Carrier ()
  74. DECLARE SUB CheckTime (LogoffTime!, Remain!, Z%)
  75. DECLARE SUB ColorPrompt (YY$)
  76. DECLARE SUB EofComm (Char%)
  77. DECLARE SUB FindFKey ()
  78. DECLARE SUB GetCom (YY$)
  79. DECLARE SUB Line25 ()
  80. DECLARE SUB NameCaps (YY$)
  81. DECLARE SUB QuickTput (YY$, NumReturns%)
  82. DECLARE SUB Tput ()
  83. DECLARE SUB TrimTrail (YY$, XX$)
  84. DECLARE SUB UpdtCalr (YY$, Z%)
  85.  
  86. ' $INCLUDE: 'RBBS-VAR.MOD'
  87.  
  88. * REPLACING old line(s) by new
  89. 110   CONST ESCKey = 27
  90.       CONST BackspKey = 8
  91.       CONST OtherBackspKey = 127
  92.       CONST CarrRet = 13
  93.       CONST WordLeftKey = 1          ' Ctrl-A
  94.       CONST ReformTextKey = 2        ' Ctrl-B
  95.       CONST PageDownKey = 3          ' Ctrl-C
  96.       CONST ColRightKey = 4          ' Ctrl-D
  97.       CONST LineUpKey = 5            ' Ctrl-E
  98.       CONST WordRightKey = 6         ' Ctrl-F
  99.       CONST CharDeleteKey = 7        ' Ctrl-G
  100. * ------[ first line different ]------
  101.       CONST TabKey = 9               ' Ctrl-I <- Tab Key Support
  102.       CONST HelpExpertKey = 10       ' Ctrl-J <- Turn Help Screen OFF 'Mpl021702
  103.       CONST EndSessionKey = 11       ' Ctrl-K
  104.       CONST HelpKey = 14             ' Ctrl-N
  105.       CONST ReflowTextKey = 15       ' Ctrl-O
  106.       CONST RepaintKey = 16          ' Ctrl-P
  107.       CONST PageUpKey = 18           ' Ctrl-R
  108.       CONST ColLeftKey = 19          ' Ctrl-S
  109.       CONST DeleteWordRightKey = 20  ' Ctrl-T
  110.       CONST ToggleINSKey = 22        ' Ctrl-V
  111.       CONST HomeKey = 23             ' Ctrl-W
  112.       CONST LineDownKey = 24         ' Ctrl-X
  113.       CONST LineDeleteKey = 25       ' Ctrl-Y
  114.       CONST EndKey = 26              ' Ctrl-Z
  115.  
  116.       CONST BlankLine$ = ""
  117. * REPLACING old line(s) by new
  118. 120   COMMON SHARED /Ansied/ CurrentRow, CurrentCol, TopLine
  119.       COMMON SHARED /Ansied/ OldColour, IsBold, InsertMode
  120.       COMMON SHARED /Ansied/ SoftSpace$
  121.       COMMON SHARED /Ansied/ BlockDelActive, MsgLockLines
  122.       COMMON SHARED /Ansied/ BlockLine1, BlockLine2
  123.       COMMON SHARED /Ansied/ MsgTo$, MsgSubj$
  124.  
  125. '*  AnsiEd
  126. '*----------------------------------------------------------------------------
  127. '*  Main full-screen editor routine
  128. '*
  129. '*
  130.       SUB Ansied (T$, S$, L%)
  131. * ------[ first line different ]------
  132.       '*
  133.       '* Remote caller's page length can't be longer than the
  134.       '* local page length or errors will occur when the editor
  135.       '* tries to put the cursor off the screen.  This only needs
  136.       '* to be done when snoop is on.
  137.       '*
  138.       SavePageLength = ZPageLength                                   ' DD021903/VGA
  139.       IF ZSnoop THEN                                                 ' DD021903/VGA
  140.          IF ZPageLength > ZLocalPageLength THEN                      ' DD021903/VGA
  141.             ZPageLength = ZLocalPageLength - 2                       ' DD021903/VGA
  142.          END IF                                                      ' DD021903/VGA
  143.       END IF                                                         ' DD021903/VGA
  144.       IF ZWasGR = 4 THEN                                             ' DD062002
  145.          CALL BufFile (ZWelcomeFileDrvPath$ + "RIPWINM",WasX)        ' DD062002
  146.       END IF                                                         ' DD062002
  147.       '*
  148.       '* ZworkAra$() holds what's currently on the user's screen.
  149.       '* 24 Lines: ZWorkAra$(1) = Menu, Bottom Line = "Line 25"
  150.       '*
  151. * REPLACING old line(s) by new
  152. * ------[ first line different ]------
  153. 500   REDIM ZWorkAra$(ZPageLength + 2)                               ' DD021903/VGA
  154.       '*
  155.       '* TopLine is the index into the ZOutTxt$() array that
  156.       '* corresponds to the top of the displayed image, i.e.
  157.       '* what's on line 3 of the user's screen.
  158.       '*
  159.       '*   1,12,23,34,45,56,78
  160.       '*
  161.       SaveExpertUser = ZExpertUser                                   ' DD021702
  162.       TopLine = 1
  163.       SoftSpace$ = CHR$(250)
  164.       InsertMode = ZTrue
  165.       ZLineFeed$ = CHR$(10)
  166.       BlockDelActive = ZFalse
  167.       HiLiteSave = ZHiLiteOff
  168.       ZHiLiteOff = ZFalse
  169.       UseTputSave = ZUseTput
  170.       ZUseTput = ZFalse
  171.       MsgLockLines = L%
  172.       MsgTo$ = T$
  173.       CALL NameCaps(MsgTo$)
  174.  
  175.       MsgSubj$ = S$
  176.       YY$ = ""
  177.       IF LEFT$(MsgSubj$, 3) = "(R)" THEN
  178.          YY$ = "(R)"
  179.          MsgSubj$ = MID$(MsgSubj$, 4)
  180.       END IF
  181.       CALL NameCaps(MsgSubj$)
  182.       MsgSubj$ = YY$ + MsgSubj$
  183.  
  184.       '*
  185.       '* Initialize the screen
  186.       '*
  187. * REPLACING old line(s) by new
  188. 510   CALL ClearScreen
  189.       CALL UpdateStatusLine(1)
  190. * ------[ first line different ]------
  191.       CALL DisplayKeys
  192.       CALL MoveCursor(3, 1)
  193.       '*
  194.       '* Remove ANSI sequences from the quoted lines
  195.       '*
  196.       IF ZLinesInMsg > (ZMsgDim - 11) THEN                           ' DD021702
  197.          ZLinesInMsg = (ZMsgDim - 11)                                ' DD021702
  198.       END IF
  199.       IF ZMaxMsgLines > (ZMsgDim - 1) THEN                           ' DD021702
  200.          ZMaxMsgLines = (ZMsgDim - 1)                                ' DD021702
  201.       END IF
  202.       IF ZLinesInMsg > ZMaxMsgLines THEN
  203.          ZLinesInMsg = ZMaxMsgLines
  204.       END IF
  205.       FOR I = ZLinesInMsg + 1 TO ZMaxMsgLines                        ' DD021702
  206.          ZOutTxt$(I) = BlankLine$
  207.       NEXT
  208.       IF ZLinesInMsg <> 0 THEN
  209.          FOR I = 1 TO ZLinesInMsg
  210.             CALL UnString(ZOutTxt$(I), CHR$(27) + CHR$(91))          ' DD021301
  211.          NEXT
  212.          J = ZLinesInMsg \ 11
  213.          IF ZLinesInMsg MOD 11 = 0 THEN
  214.            J = J - 1
  215.          END IF
  216.          TopLine = J * 11 + 1
  217.          J = ZLinesInMsg - TopLine
  218.          CALL MoveCursor(J + 5, 1)
  219.       END IF
  220.       CALL UpdateScreen
  221.       '*
  222.       '* Run the Editor
  223.       '*
  224. * REPLACING old line(s) by new
  225. 525      IF KeyPressed = ESCKey THEN            ' v2.44a
  226.             CALL GetChar(B$): GOSUB 740
  227. * ------[ first line different ]------
  228.             IF B$ = CHR$(91) THEN                    ' ANSI sequence ' DD021301
  229.                CALL GetChar(B$): GOSUB 740
  230.                IF B$ = CHR$(67) THEN                            'C   ' DD021301
  231.                   KeyPressed = ColRightKey
  232.                ELSEIF B$ = CHR$(68) THEN                        'D   ' DD021301
  233.                   KeyPressed = ColLeftKey
  234.                ELSEIF B$ = CHR$(65) THEN                        'A   ' DD021301
  235.                   KeyPressed = LineUpKey
  236.                ELSEIF B$ = CHR$(66) THEN                        'B   ' DD021301
  237.                   KeyPressed = LineDownKey
  238.                END IF
  239.             END IF
  240.          END IF
  241.  
  242.          Index = CurrentRow + TopLine - 3
  243.  
  244.          IF BlockDelActive OR Index <= MsgLockLines OR Index > ZMaxMsgLines THEN
  245. * REPLACING old line(s) by new
  246. 530         SELECT CASE KeyPressed
  247.                CASE CarrRet
  248.                   IF BlockDelActive THEN
  249.                      BlockDelActive = ZFalse
  250.                      BlockLine2 = Index
  251.                      IF BlockLine2 < BlockLine1 THEN
  252.                         SWAP BlockLine1, BlockLine2
  253.                      END IF
  254.                      IF BlockLine1 <= MsgLockLines THEN
  255.                         BlockLine1 = MsgLockLines + 1
  256.                      END IF
  257.                      IF BlockLine2 > ZMaxMsgLines THEN
  258.                         BlockLine2 = ZMaxMsgLines
  259.                      END IF
  260.                      K = 0
  261. * ------[ first line different ]------
  262.                      FOR I = BlockLine2 + 1 TO ZMsgDim               ' DD021702
  263.                         ZOutTxt$(BlockLine1 + K) = ZOutTxt$(I)
  264.                         K = K + 1
  265.                      NEXT I
  266.                      WHILE BlockLine1 + K <= ZMsgDim                 ' DD021702
  267.                         ZOutTxt$(BlockLine1 + K) = BlankLine$
  268.                         K = K + 1
  269.                      WEND
  270.                      CALL UpdateScreen
  271.                      CALL UpdateStatusLine(2)
  272.                      CALL MoveCursor(BlockRow, BlockCol)
  273.                   END IF
  274.                   KeyPressed = 255
  275.  
  276. * REPLACING old line(s) by new
  277. 540            CASE ESCKey
  278.                   IF BlockDelActive THEN
  279.                      BlockDelActive = ZFalse
  280. * ------[ first line different ]------
  281.                      CALL ClearScreen        ' <-- Added when user cancells  'Mpl021701
  282.                      CALL UpdateScreen       ' Block Delete the "highlighted"'Mpl021701
  283.                      CALL UpdateStatusLine(1)                        'Mpl021701
  284. '                    CALL UpdateStatusLine(2)                        'Mpl021701
  285.                      CALL DisplayKeys                                ' DD021702
  286.                      CALL MoveCursor(BlockRow, BlockCol)
  287.                      KeyPressed = 255
  288.                   END IF
  289.  
  290.                CASE LineUpKey                                        ' DD021702
  291.                   CALL SaveCursor(SaveRow, SaveCol)                  ' DD021702
  292.                   CALL MoveCursor(CurrentRow,1)                      ' DD021702
  293.                   IF CurrentRow > 3 THEN                             ' DD021301
  294.                      CALL Putscreen(ZOutTxt$(Index), ZUserTextColor,ZTrue)' DD032301
  295.                   END IF                                             ' DD021301
  296.                   CALL MoveCursor(SaveRow, SaveCol)                  ' DD021702
  297.  
  298.                CASE LineDownKey                                      ' DD021702
  299.                   CALL SaveCursor(SaveRow, SaveCol)                  ' DD021702
  300.                   CALL MoveCursor(CurrentRow,1)                      ' DD021702
  301.                   CALL Putscreen(ZOutTxt$(Index), ZUserTextColor,ZFalse) ' DD032301
  302.                   IF ZExpertUser THEN PE = ZPageLength _             ' DD021901
  303.                      Else PE = ZPageLength - 4                       ' DD021901
  304.                   IF CurrentRow + 1 < PE THEN
  305.                      CALL MoveCursor(CurrentRow+1,1)
  306.                      CALL Putscreen(ZOutTxt$(Index+1), ZUserTextColor,ZFalse) ' DD032301
  307.                   END IF
  308.                   CALL MoveCursor(SaveRow, SaveCol)                  ' DD021702
  309.  
  310.                CASE PageDownKey, PageUpKey                           ' DD021301
  311.                   '*
  312.                   '* Up and Down get passed on
  313.                   '*
  314.                CASE ELSE
  315.                   '*
  316.                   '* Ignore the key
  317.                   '*
  318.                   KeyPressed = 255
  319.  
  320.             END SELECT
  321.          END IF
  322.  
  323. * REPLACING old line(s) by new
  324. 560      SELECT CASE KeyPressed
  325. * ------[ first line different ]------
  326.             CASE ESCKey, EndSessionKey                               'Pe 03/17/92
  327.                '*
  328.                '* User wants to see main menu
  329.                '*
  330.                CALL DisplayMainMenu
  331.                CALL MoveCursor(RowSave, ColSave)
  332.                CALL GetChar(B$): GOSUB 740
  333.                CALL AllCaps(B$)                                      'RT062992
  334.                IF B$ = CHR$(68) THEN                            'D   ' DD021301
  335.                   BlockDelActive = ZTrue
  336.                   BlockLine1 = RowSave + TopLine - 3
  337.                   BlockCol = ColSave
  338.                   BlockRow = RowSave
  339.                   CALL EraseToEOL(1, 1)                  ' v2.44a
  340.                   CALL PutScreen("Delete Block: Press ENTER on Last Line to Delete, or ESC Twice to Quit", DefaultColor, DefaultBold)
  341.                   BlockLine2 = 0
  342.                   CALL MoveCursor(RowSave, 1)                        'SM070501
  343.                   Index = (RowSave) + (Topline - 3)                  'Mpl021701
  344.                   CALL Putscreen(ZOutTxt$(Index),ZUserTextColor,ZFalse) ' DD032301
  345.                ELSE
  346.                   CALL MenuCommand(B$): GOSUB 740
  347.                END IF
  348.                CALL MoveCursor(RowSave, ColSave)
  349.  
  350. * REPLACING old line(s) by new
  351. 570         CASE LineUpKey
  352.                '*
  353.                '* Move the current cursor position up one line
  354.                '*
  355.                IF CurrentRow > 3 THEN
  356.                   CALL MoveCursor(CurrentRow - 1, CurrentCol)
  357.                ELSE
  358.                   IF TopLine <> 1 THEN
  359.                      TopLine = TopLine - 11
  360. * ------[ first line different ]------
  361.                      IF TopLine < 1 THEN                             ' DD021702
  362.                         TopLine = 1                                  ' DD021702
  363.                      ENDIF                                           ' DD021702
  364.                      CALL MoveCursor(CurrentRow + 10, CurrentCol)
  365.                      CALL UpdateScreen
  366.                   END IF
  367.                END IF
  368.  
  369. * REPLACING old line(s) by new
  370. 580         CASE LineDownKey
  371.                '*
  372.                '* Move the current cursor position down one line
  373.                '*
  374. * ------[ first line different ]------
  375.                IF ZExpertUser THEN PE = ZPageLength _                ' DD021901
  376.                   Else PE = ZPageLength - 4                          ' DD021901
  377.                IF CurrentRow < PE THEN                               'Mpl021701
  378.                   IF (CurrentRow + (TopLine - 3)) < ZMaxMsgLines THEN
  379.                      CALL MoveCursor(CurrentRow + 1, CurrentCol)
  380.                   END IF
  381.                ELSEIF BlockDelActive THEN                            'Mpl021701
  382.                   CALL PutCom (ZBellRinger$)                         ' DD070402
  383.                   CALL MoveCursor(CurrentRow,1)                      ' DD021702
  384.                ELSE
  385.                   IF TopLine < ZMaxMsgLines - 10 THEN
  386.                      TopLine = TopLine + 11
  387.                      CALL MoveCursor(CurrentRow - 10, CurrentCol)
  388.                      CALL UpdateScreen
  389.                   END IF
  390.                END IF
  391.  
  392. * INSERTING new line(s)
  393. 595         CASE TabKey    ' <- Tab Key Support here..
  394.                '*
  395.                '* Tab 8 Spaces
  396.                '*
  397.                IF CurrentCol < 72 THEN
  398.                 CALL MoveCursor(CurrentRow, CurrentCol + 8)
  399.                END IF
  400.  
  401. * REPLACING old line(s) by new
  402. 620         CASE DeleteWordRightKey
  403.                '*
  404.                '* Delete the current word
  405.                '*
  406.                I = CurrentCol
  407.                L = LEN(ZOutTxt$(Index))
  408.                CALL FindWord(ZOutTxt$(Index), 1, I)
  409.                IF I > CurrentCol THEN
  410.                   YY$ = MID$(ZOutTxt$(Index), I)
  411.                   MID$(ZOutTxt$(Index), CurrentCol) = YY$
  412.                   ZOutTxt$(Index) = LEFT$(ZOutTxt$(Index), L - (I - CurrentCol))
  413. * ------[ first line different ]------
  414.                   CALL PutScreen(YY$, ZUserTextColor, ZTrue)         ' DD032301
  415.                   CALL EraseToEOL(RowSave, CurrentCol)
  416.                   CALL MoveCursor(RowSave, ColSave)
  417.                END IF
  418.  
  419. * REPLACING old line(s) by new
  420. 650         CASE PageDownKey
  421.                '*
  422.                '* Move the display one page down
  423.                '*
  424. * ------[ first line different ]------
  425.                TopLine = TopLine + (ZPageLength - 1)                 ' DD021903/VGA
  426.                IF TopLine > ZMaxMsgLines - 15 THEN                   ' DD021702
  427.                   TopLine = ZMaxMsgLines - 15                        ' DD021702
  428.                END IF
  429.                IF TopLine < 1 THEN                                   ' DD031007
  430.                   TopLine = 1                                        ' DD031007
  431.                END IF                                                ' DD031007
  432.                CALL UpdateScreen                                     ' DD031007
  433.  
  434. * REPLACING old line(s) by new
  435. 660         CASE PageUpKey
  436.                '*
  437.                '* Move the display one page up
  438.                '*
  439. * ------[ first line different ]------
  440.                TopLine = TopLine - (ZPageLength - 1)                 ' DD021903/VGA
  441.                IF TopLine < 1 THEN
  442.                   TopLine = 1
  443.                END IF
  444.                CALL UpdateScreen
  445.  
  446. * REPLACING old line(s) by new
  447. * ------[ first line different ]------
  448. 710         CASE HelpKey,HelpExpertKey,ReformTextKey, ReflowTextKey, ToggleINSKey, RepaintKey 'Mpl021701
  449.                '*
  450.                '* Execute a main menu command
  451.                '*
  452.                '*          1234567890123456789012
  453.  
  454.  
  455.                IF KeyPressed = HelpExpertKey THEN
  456.                   ZExpertUser = ZTrue
  457.                END IF
  458.                IF KeyPressed = HelpKey THEN
  459.                   ZExpertUser = ZFalse
  460.                END IF
  461.  
  462.  
  463.                YY$ = MID$(" J       N   HRP     I", KeyPressed, 1)
  464.                CALL MenuCommand(YY$): GOSUB 740
  465.                CALL MoveCursor(RowSave, ColSave)
  466.  
  467.             CASE IS > 127, IS < 32
  468.                '*
  469.                '* Ignore characters above 127 or below 32
  470.                '*
  471. * REPLACING old line(s) by new
  472. * ------[ first line different ]------
  473. 730   REDIM ZWorkAra$(ZMsgDim)
  474.       REDIM Places(1)                                                ' DD021702
  475.       ZHiLiteOff = HiLiteSave
  476.       ZUseTput = UseTputSave
  477.       S$ = MsgSubj$                                                  'RT062992
  478.       CALL AllCaps(S$)                                               'RT062992
  479.       ZExpertUser = SaveExpertUser                                   ' DD021702
  480.       ZPageLength = SavePageLength                                   ' DD021903/VGA
  481.       EXIT SUB
  482.  
  483.       '*
  484.       '* Test ZSubParm and Exit ANSIED if the carrier dropped
  485.       '*
  486. * REPLACING old line(s) by new
  487. 1210  IF CurrentCol > 1 THEN
  488.          ZOutTxt$(Index) = LEFT$(ZOutTxt$(Index), CurrentCol - 2) + MID$(ZOutTxt$(Index), CurrentCol)
  489.          CALL EraseToEOL(CurrentRow, CurrentCol - 1)
  490.          IF NOT AtEndOfLine THEN
  491.             YY$ = MID$(ZOutTxt$(Index), ColSave - 1)
  492.             CALL MoveCursor(RowSave, ColSave - 1)
  493. * ------[ first line different ]------
  494.             CALL PutScreen(YY$, ZUserTextColor, ZTrue)               ' DD032301
  495.          END IF
  496.          CALL MoveCursor(RowSave, ColSave - 1)
  497.          ZWorkAra$(CurrentRow) = ZOutTxt$(Index)
  498.       ELSEIF LEN(ZOutTxt$(Index - 1)) >= ZRightMargin THEN
  499.          '*
  500.          '* Do nothing
  501.          '*
  502. * REPLACING old line(s) by new
  503. 1300  Index = CurrentRow + TopLine - 3
  504. * ------[ first line different ]------
  505.       IF Index >= ZMaxMsgLines THEN
  506.          EXIT SUB
  507.       END IF
  508.       IF InsertMode THEN         ' Insert a new line
  509.          FOR I = (ZMaxMsgLines - 1) TO Index + 1 STEP -1             ' DD021702
  510.             ZOutTxt$(I + 1) = ZOutTxt$(I)
  511.          NEXT I
  512.          IF LEN(ZOutTxt$(Index)) >= CurrentCol THEN
  513.             ZOutTxt$(Index + 1) = MID$(ZOutTxt$(Index), CurrentCol)
  514.             ZOutTxt$(Index) = LEFT$(ZOutTxt$(Index), CurrentCol - 1)
  515.          ELSE
  516.             ZOutTxt$(Index + 1) = BlankLine$
  517.          END IF
  518.          CALL UpdateScreen
  519.       END IF
  520.       IF ZExpertUser THEN PE = ZPageLength _                         ' DD021901
  521.          Else PE = ZPageLength - 4                                   ' DD021901
  522.       IF CurrentRow < PE THEN                                        'Mpl021701
  523.          CALL MoveCursor(CurrentRow + 1, 1)
  524.       ELSE
  525.          CALL MoveCursor(CurrentRow, 1)
  526.          CALL UnGetChar(LineDownKey)
  527.       END IF
  528.       END SUB
  529.  
  530. '*  ChangeSubject()
  531. '*----------------------------------------------------------------------------
  532. '*  Routine to allow user to change the message subject
  533. '*
  534. '*
  535.       SUB ChangeSubject
  536.       CALL GetString("Change Subject From '" + MsgSubj$ + "' To? ", NewSubj$)
  537.       IF NewSubj$ <> "" THEN
  538.          MsgSubj$ = LEFT$(NewSubj$, 25)
  539.          CALL NameCaps(MsgSubj$)
  540.       END IF
  541.       END SUB
  542.  
  543. '*  ClearScreen()
  544. '*----------------------------------------------------------------------------
  545. '*  This routine clears the screen and moves the cursor to row 2, col 1
  546. '*
  547. '*
  548.       SUB ClearScreen
  549. * REPLACING old line(s) by new
  550. * ------[ first line different ]------
  551. 1500  IF ZExpertUser THEN PE = ZPageLength _                         ' DD021901
  552.          Else PE = ZPageLength - 4                                   ' DD021901
  553.       FOR I = 1 TO PE                                                'Mpl021701
  554.          ZWorkAra$(I) = BlankLine$
  555.       NEXT I
  556.       CALL QuickTput(CHR$(27) + "[2J" + CHR$(27) + "[0m", 0)         ' DD021301
  557.       ZSubParm = 2
  558.       CALL Line25
  559.       ZSubParm = 0
  560.       CALL QuickTput(CHR$(27) + "[0m" + CHR$(27) + "[3;1H" + ZEmphasizeOff$, 0) ' DD021301
  561.       CurrentCol = 1
  562.       CurrentRow = 3
  563.       IsBold = DefaultBold
  564.       OldColour = DefaultColor
  565.       END SUB
  566.  
  567. '*  DeleteCurrentLine()
  568. '*----------------------------------------------------------------------------
  569. '*  This routine deletes the current line on the screen and in the array
  570. '*  ZOutTxt$, and moves the next lower line up one  It then repaints the
  571. '*  affected portion of the screen (from the deleted line down)
  572. '*
  573. '*
  574.       SUB DeleteCurrentLine (Index%)
  575. * REPLACING old line(s) by new
  576. * ------[ first line different ]------
  577. 1600  FOR I = Index% TO (ZMsgDim - 1)                                ' DD021702
  578.          ZOutTxt$(I) = ZOutTxt$(I + 1)
  579.       NEXT I
  580.       ZOutTxt$(ZMsgDim) = BlankLine$                                 ' DD021702
  581.       CALL UpdateScreen
  582.       END SUB
  583.  
  584. '*  DisplayMainMenu()
  585. '*----------------------------------------------------------------------------
  586. '*  This routine displays the main menu on the top line
  587. '*
  588. '*
  589.       SUB DisplayMainMenu
  590. * REPLACING old line(s) by new
  591. 1700  CALL MoveCursor(1, 1)
  592.       YY$ = "A)bort H)elp D)elete I)ns/ovw J)ustify "
  593.       IF ZLocalUser OR ZSysop THEN
  594.          YY$ = YY$ + "O)import R)eflow P)aint S)ave U)subject "
  595.       ELSE
  596. * ------[ first line different ]------
  597.          YY$ = YY$ + "R)eflow P)aint S)ave U)subject" + SPACE$(10)   ' DD021702
  598.       END IF
  599.       CALL ColorPrompt(YY$)
  600.       CALL PutScreen(YY$, DefaultColor, DefaultBold)
  601.       END SUB
  602.  
  603. '*  DoneWithMsg()
  604. '*----------------------------------------------------------------------------
  605. '*  This routine is called to save or abort the message
  606. '*
  607. '*
  608.       SUB DoneWithMsg (YY$)
  609. * REPLACING old line(s) by new
  610. 1810  SELECT CASE YY$
  611. * ------[ first line different ]------
  612.          CASE CHR$(83)        ' Save Message                    'S   ' DD021301
  613.             '*
  614.             '* Remove trailing blank lines from the message
  615.             '*
  616.             CALL FindEndOfMsg(EndOfMsg)
  617.             FOR I = 1 TO EndOfMsg
  618.                J = INSTR(ZOutTxt$(I), SoftSpace$)
  619.                WHILE J <> 0
  620.                   MID$(ZOutTxt$(I), J, 1) = SPACE$(1)                ' DD021301
  621.                   J = INSTR(ZOutTxt$(I), SoftSpace$)
  622.                WEND
  623.                CALL TrimTrail(ZOutTxt$(I), SPACE$(1))                ' DD021301
  624.             NEXT I
  625.             CALL FindEndOfMsg(ZLinesInMsg)
  626.             CALL EraseToEOL(1, 1)                                    'Mpl021701
  627.             CALL MoveCursor(1, 1)                                    'Mpl021701
  628.             CALL PutScreen(SPACE$(1), DefaultColor, DefaultBold)     ' DD021301
  629.             CALL ClearScreen
  630.             ZSubParm = 1
  631.  
  632. * REPLACING old line(s) by new
  633. * ------[ first line different ]------
  634. 1820     CASE CHR$(65)                                          'A   ' DD021301
  635.             CALL EraseToEOL(1, 1)
  636.             YY$ = "Abort: Are You Sure (Y)es,[N]o)? "
  637.             CALL ColorPrompt(YY$)
  638.             CALL PutScreen(YY$, DefaultColor, DefaultBold)
  639.             CALL GetChar(B$)
  640.             IF ZSubParm <> 0 THEN
  641.                B$ = CHR$(89)                                    'Y   ' DD021301
  642.             END IF
  643.             CALL AllCaps(B$)                                         'RT062992
  644.             IF B$ = CHR$(89) THEN                               'Y   ' DD021301
  645.                CALL ClearScreen
  646.                ZSubParm = 2
  647.             END IF
  648.       END SELECT
  649.       END SUB
  650.  
  651. '*  EraseToEOL()
  652. '*----------------------------------------------------------------------------
  653. '*  This routine clears from a position to to the end of that line
  654. '*
  655. '*
  656.       SUB EraseToEOL (LineNumber, ColNumber)
  657. * REPLACING old line(s) by new
  658. 1900  CALL MoveCursor(LineNumber, ColNumber)
  659. * ------[ first line different ]------
  660.       CALL QuickTput(CHR$(27) + "[K", 0)                             ' DD021301
  661.       END SUB
  662.  
  663. '*  FindEndOfMsg()
  664. '*----------------------------------------------------------------------------
  665. '*  Finds the last active line in the message
  666. '*
  667. '*
  668.       SUB FindEndOfMsg (EndOfMsg)
  669.       EndOfMsg = 1
  670.       FOR I = ZMaxMsgLines TO 1 STEP -1
  671.          IF ZOutTxt$(I) <> BlankLine$ OR I <= MsgLockLines THEN
  672.             EndOfMsg = I
  673.             EXIT FOR
  674.          END IF
  675.       NEXT I
  676.       END SUB
  677.  
  678. '*  FindWrap()
  679. '*----------------------------------------------------------------------------
  680. '*  This routine finds a place in the string yy$ that could be used as a
  681. '*  place to wrap the line WhereToWrap should be the last position that
  682. '*  remains in the line, ie
  683. '*    set   currentline$ = left$(yy$,wheretowrap)
  684. '*          nextline$    = mid$ (yy$,wheretowrap+1)
  685. '*
  686. '*
  687.       SUB FindWrap (YY$, WhereToWrap)
  688. * REPLACING old line(s) by new
  689. 2200  ZAutoLogoff! = TIMER + ZWaitBeforeDisconnect
  690.       CALL Carrier
  691.       YY$ = ""
  692.       WHILE ZSubParm <> -1 AND ZSubParm <> -2 AND YY$ = ""
  693.          ZSubParm = 0
  694.          IF LEN(ZCommportStack$) > 0 THEN
  695.             YY$ = LEFT$(ZCommportStack$, 1)
  696.             ZCommportStack$ = MID$(ZCommportStack$, 2)
  697.          ELSE
  698.             IF ZLocalUser THEN
  699.                YY$ = INKEY$
  700.                IF LEN(YY$) = 2 THEN
  701.                   KeyPressed = ASC(RIGHT$(YY$, 1))
  702.                   YY$ = ""
  703.                   SELECT CASE KeyPressed
  704.                      CASE 82                  ' Insert
  705.                         KeyPressed = ToggleINSKey
  706.                      CASE 83                  ' Delete
  707.                         KeyPressed = CharDeleteKey
  708.                      CASE 71                  ' Home
  709.                         KeyPressed = HomeKey
  710.                      CASE 73                  ' PgUp
  711.                         KeyPressed = PageUpKey
  712.                      CASE 72                  ' Up Arrow
  713.                         KeyPressed = LineUpKey
  714.                      CASE 80                  ' Down Arrow
  715.                         KeyPressed = LineDownKey
  716.                      CASE 81                  ' PgDn
  717.                         KeyPressed = PageDownKey
  718.                      CASE 75                  ' Left Arrow
  719.                         KeyPressed = ColLeftKey
  720.                      CASE 77                  ' Right Arrow
  721.                         KeyPressed = ColRightKey
  722.                      CASE 115                 ' Ctrl-Left Arrow
  723.                         KeyPressed = WordLeftKey
  724.                      CASE 116                 ' Ctrl-Right Arrow
  725.                         KeyPressed = WordRightKey
  726.                      CASE 79                  ' End
  727.                         KeyPressed = EndKey
  728. * ------[ first line different ]------
  729.                      CASE 9
  730.                         KeyPressed = TabKey
  731.                      CASE ELSE
  732.                         KeyPressed = 0
  733.                   END SELECT
  734.                   IF KeyPressed <> 0 THEN
  735.                      YY$ = CHR$(KeyPressed)
  736.                   END IF
  737.                END IF
  738.             ELSE
  739.                CALL FindFKey
  740.                IF ZSubParm >= 0 THEN
  741.                   YY$ = ZKeyPressed$
  742.                   IF YY$ = "" THEN
  743.                      CALL EofComm(Char%)
  744.                      IF Char% = -1 THEN
  745.                         CALL CheckTime(ZAutoLogoff!, Remain!, 1)
  746.                         IF Remain! < 0 THEN
  747.                            CALL UpdtCalr("Sleep disconnect", 1)
  748.                            ZSubParm = -2
  749.                            ZNo = ZTrue
  750.                            ZSleepDisconnect = ZTrue
  751.                         END IF
  752.                      ELSE
  753.                         CALL Carrier
  754.                         IF ZSubParm <> -1 THEN
  755.                            ZSubParm = 0
  756.                            CALL GetCom(YY$)
  757.                         END IF
  758.                      END IF
  759.                   END IF
  760.                END IF
  761.             END IF
  762.          END IF
  763.       WEND
  764.       END SUB
  765.  
  766. '*  GetString()
  767. '*----------------------------------------------------------------------------
  768. '*  Gets a string from the user
  769. '*
  770. '*
  771.       SUB GetString (Prompt$, YY$)
  772.       YY$ = ""
  773.       CALL EraseToEOL(1, 1)
  774.       CALL PutScreen(Prompt$, DefaultColor, DefaultBold)
  775.       NewCol = CurrentCol
  776.       InitCol = NewCol
  777.       DO
  778.          CALL MoveCursor(CurrentRow, NewCol)
  779.          CALL GetChar(B$)
  780.          IF ZSubParm <> 0 THEN
  781.             B$ = CHR$(ESCKey)
  782.          END IF
  783.          KeyPressed = ASC(B$)
  784.          SELECT CASE KeyPressed
  785.             CASE BackspKey, OtherBackspKey
  786.                IF NewCol <> InitCol THEN
  787.                   CALL MoveCursor(CurrentRow, NewCol - 1)
  788.                   CALL PutScreen(SPACE$(1), DefaultColor, DefaultBold) ' DD021301
  789.                   NewCol = NewCol - 1
  790.                   YY$ = LEFT$(YY$, LEN(YY$) - 1)
  791.                END IF
  792.             CASE CarrRet
  793.                EXIT DO
  794.             CASE ESCKey
  795.                YY$ = ""
  796.                EXIT DO
  797.             CASE ELSE
  798.                YY$ = YY$ + B$
  799.                CALL PutScreen(B$, DefaultColor, DefaultBold)
  800.                NewCol = NewCol + 1
  801.          END SELECT
  802.       LOOP WHILE 1
  803.       END SUB
  804.  
  805. '*  HelpMe()
  806. '*----------------------------------------------------------------------------
  807. '*  This routine provides on-line help for the user
  808. '*
  809. '*
  810.       SUB HelpMe
  811. * REPLACING old line(s) by new
  812. 2300  CALL SaveCursor(RowSave, ColSave)
  813. * ------[ first line different ]------
  814.       ZExpertUser = ZFalse                                           'Mpl021701
  815.       CALL ClearScreen
  816.       ZLinesPrinted = 0                                              ' DD031003
  817.       ZNonStop = ZTrue                                               ' DD031003
  818.       CALL BufFile(ZHelpPath$ + "ANSIED" + ZHelpExtension$, X)
  819.       ZNonStop = ZFalse                                              ' DD031003
  820.       CALL AskMore ("",ZTrue,ZFalse,WasX,ZTrue)                      ' DD031003
  821.       CALL ClearScreen
  822.       CALL UpdateScreen
  823.       CALL MoveCursor(RowSave, ColSave)
  824.       END SUB
  825.  
  826. '*  ImportFile()
  827. '*----------------------------------------------------------------------------
  828. '*  Imports an ASCII text file in the message
  829. '*
  830. '*
  831.       SUB ImportFile
  832.       IF ZLocalUser OR ZSysop THEN
  833.          CALL GetString("Import What File? ", FileName$)
  834.          IF FileName$ <> "" THEN
  835.             CALL FindIt(FileName$)
  836.             IF ZOK THEN
  837.                ZUserIn$(1) = FileName$
  838.                ZAnsIndex = 0
  839.                ZLastIndex = 1
  840.                CALL FindEndOfMsg(EndOfMsg)
  841.                CALL MsgImport(ZMaxMsgLines, ZRightMargin, EndOfMsg, ZOutTxt$())
  842. '              J = EndOfMsg \ 11                                     'Mpl021701
  843. '              IF EndOfMsg MOD 11 = 0 THEN                           'Mpl021701
  844. '                 J = J - 1                                          'Mpl021701
  845. '              END IF                                                'Mpl021701
  846. '              TopLine = J * 11 + 1                                  'Mpl021701
  847. '              J = EndOfMsg - TopLine                                'Mpl021701
  848. '              CALL MoveCursor(J + 5, 1)                             'Mpl021701
  849.                CALL UpdateScreen
  850.             END IF
  851.          END IF
  852.       END IF
  853.       END SUB
  854.  
  855. '*  LastParaLine()
  856. '*----------------------------------------------------------------------------
  857. '*  This routine returns ZTrue if ZOutTxt$(I) is the last line
  858. '*  in a paragraph
  859. '*
  860. '*
  861.       SUB LastParaLine (I, LastLine, Result)
  862. * REPLACING old line(s) by new
  863. 2400  Result = ZFalse
  864.       IF I = LastLine OR I >= ZMaxMsgLines THEN
  865.          Result = ZTrue
  866.       ELSE
  867.          YY$ = ZOutTxt$(I)
  868. * ------[ first line different ]------
  869.          J = INSTR(YY$, CHR$(62))                                    ' DD021301
  870.          IF J = 0 THEN
  871.             J = 6
  872.          END IF
  873.          IF J < 5 THEN
  874.             Result = ZTrue
  875.          ELSEIF YY$ = BlankLine$ THEN
  876.             Result = ZTrue
  877.          ELSE
  878.             IF ZOutTxt$(I + 1) = BlankLine$ THEN
  879.                Result = ZTrue
  880.             ELSEIF LEFT$(ZOutTxt$(I + 1), 1) = SPACE$(1) THEN        ' DD021301
  881.                Result = ZTrue
  882.             ELSE
  883.                K = INSTR(ZOutTxt$(I + 1), CHR$(62))                  ' DD021301
  884.                IF K <> 0 AND K < 5 THEN
  885.                   Result = ZTrue
  886.                END IF
  887.             END IF
  888.          END IF
  889.       END IF
  890.       END SUB
  891.  
  892. '*  MenuCommand()
  893. '*----------------------------------------------------------------------------
  894. '* This routine executes the passed main menu command
  895. '*
  896. '*
  897.       SUB MenuCommand (YY$)
  898. * REPLACING old line(s) by new
  899. 2450  ZSubParm = 0              ' v2.44a
  900.       SELECT CASE YY$
  901. * ------[ first line different ]------
  902.          CASE CHR$(72)                                          'H   ' DD021301
  903.             CALL HelpMe
  904.             CALL DisPlayKeys                                         'Pe 03/17/92
  905.          CASE CHR$(78)                                          'N   ' DD021301
  906.             CALL ClearScreen                                         'Mpl021701
  907.             CALL UpdateScreen                                        'Mpl021701
  908.          CASE CHR$(83), CHR$(65)                                'S'A ' DD021301
  909.             CALL DoneWithMsg(YY$)
  910.          CASE CHR$(80)                                          'P   ' DD021301
  911.             CALL ClearScreen
  912.             CALL DisplayKeys
  913.             CALL UpdateScreen
  914.          CASE CHR$(73)                                          'I   ' DD021301
  915.             InsertMode = NOT InsertMode
  916.          CASE CHR$(82)                                          'R   ' DD021301
  917.             CALL ReformText(ZFalse)
  918.          CASE CHR$(74)                                          'J   ' DD021301
  919.             CALL ReformText(ZTrue)
  920.          CASE CHR$(79)                                          'O   ' DD021301
  921.             CALL ImportFile
  922.          CASE CHR$(85)                                          'U   ' DD021301
  923.             CALL ChangeSubject
  924.       END SELECT
  925.       IF ZSubParm = 0 THEN
  926.          CALL EraseToEOL(1, 1)
  927.          CALL UpdateStatusLine(1)
  928.       END IF
  929.       END SUB
  930.  
  931. '*  MoveCursor()
  932. '*----------------------------------------------------------------------------
  933. '*  This routine moves the cursor to the position spec'd by newcol and
  934. '*  newrow and tries to do it with the minimum number of Ansi characters
  935. '*
  936. '*
  937.       SUB MoveCursor (NewRow, NewCol)
  938. * REPLACING old line(s) by new
  939. * ------[ first line different ]------
  940. 2500  YY$ = SPACE$(8)                                                ' DD021301
  941.       CALL MoveCurStr(CurrentRow, CurrentCol, NewRow, NewCol, YY$, YLen)
  942.       IF YLen <> 0 THEN
  943.          YY$ = LEFT$(YY$, YLen)
  944.          CALL QuickTput(YY$, 0)
  945.       END IF
  946.       ZSubParm = 0
  947.       END SUB
  948.  
  949. '*  NormalChar()
  950. '*----------------------------------------------------------------------------
  951. '*  This routine handles 'normal' characters entered into the message
  952. '*
  953. '*
  954.       SUB NormalChar (YY$)
  955.  
  956. * REPLACING old line(s) by new
  957. 2610  IF (CurrentCol <= ZRightMargin AND AtEndOfLine) OR (CurrentCol <= ZRightMargin AND NOT InsertMode) THEN
  958.          '*
  959.          '* Single character changed
  960.          '*
  961.          MID$(ZOutTxt$(Index), CurrentCol, 1) = YY$
  962.          MID$(ZWorkAra$(CurrentRow), CurrentCol, 1) = YY$
  963. * ------[ first line different ]------
  964.          CALL PutScreen(YY$, ZUserTextColor, ZTrue)                  ' DD032301
  965.                                                                                     ' v2.44a
  966. * REPLACING old line(s) by new
  967. 2620  ELSEIF (NOT AtEndOfLine AND InsertMode AND CurrentCol <= ZRightMargin AND LML < ZRightMargin) THEN
  968.          '*
  969.          '* Have to rewrite the screen from the current pos forward
  970.          '*
  971.          ZOutTxt$(Index) = LEFT$(ZOutTxt$(Index), CurrentCol - 1) + YY$ + MID$(ZOutTxt$(Index), CurrentCol)
  972.  
  973.          ZWorkAra$(CurrentRow) = ZOutTxt$(Index)
  974.  
  975.          CALL EraseToEOL(CurrentRow, CurrentCol)
  976.          ZZ$ = MID$(ZWorkAra$(CurrentRow), CurrentCol)
  977. * ------[ first line different ]------
  978.          CALL PutScreen(ZZ$, ZUserTextColor, ZTrue)                  ' DD032301
  979.          CALL MoveCursor(RowSave, ColSave + 1)
  980.  
  981. * REPLACING old line(s) by new
  982. 2630  ELSE
  983.          '*
  984.          '* Wrap the end of the line
  985.          '*
  986.          IF NOT AtEndOfLine THEN
  987.             ZOutTxt$(Index) = LEFT$(ZOutTxt$(Index), CurrentCol - 1) + YY$ + MID$(ZOutTxt$(Index), CurrentCol)
  988.             LML = LML + 1
  989.          ELSE
  990.             MID$(ZOutTxt$(Index), CurrentCol, 1) = YY$
  991.          END IF
  992.  
  993.          CALL FindWrap(ZOutTxt$(Index), I)
  994.          IF I <= 1 THEN
  995.             I = ZRightMargin
  996.          END IF
  997.  
  998.          ZZ$ = MID$(ZOutTxt$(Index), (I + 1))
  999.          CALL TrimTrail(ZZ$, SoftSpace$)
  1000.          ZOutTxt$(Index) = LEFT$(ZOutTxt$(Index), I)
  1001.          '*
  1002.          '* Add to the beginning of a new line
  1003.          '*
  1004. * ------[ first line different ]------
  1005.          IF Index <= (ZMaxMsgLines - 1) THEN
  1006.             Index = Index + 1
  1007.          END IF
  1008.  
  1009.          Z = INSTR(ZOutTxt$(Index), CHR$(62))                        ' DD021301                          ' v2.44a
  1010.          IF ZOutTxt$(Index) <> BlankLine$ AND (Z <= 0 OR Z > 6) AND LEN(ZOutTxt$(Index)) + LEN(ZZ$) < ZRightMargin THEN
  1011.             ZOutTxt$(Index) = ZZ$ + ZOutTxt$(Index)
  1012.          ELSE
  1013.             FOR J = (ZMaxMsgLines - 1) TO Index STEP -1
  1014.                ZOutTxt$(J + 1) = ZOutTxt$(J)
  1015.             NEXT J
  1016.             ZOutTxt$(Index) = ZZ$
  1017.          END IF
  1018.  
  1019.          CALL EraseToEOL(CurrentRow, I + 1)        ' do the "easy" line
  1020.          ZWorkAra$(CurrentRow) = ZOutTxt$(Index)
  1021.  
  1022.          CALL UpdateScreen
  1023.          IF (ColSave > I) THEN
  1024.             NewCol = ColSave - I + 1
  1025.             IF ZExpertUser THEN PE = ZPageLength _                   ' DD021901
  1026.                Else PE = ZPageLength - 4                             ' DD021901
  1027.             IF RowSave <> PE THEN                                    'Mpl021701
  1028.                CALL MoveCursor(RowSave + 1, NewCol)
  1029.             ELSE
  1030.                CALL MoveCursor(RowSave, NewCol)
  1031.                CALL UnGetChar(LineDownKey)
  1032.             END IF
  1033.          ELSE
  1034.             CALL MoveCursor(RowSave, ColSave + 1)
  1035.          END IF
  1036.       END IF
  1037.       END SUB
  1038.  
  1039. '*  PutScreen()
  1040. '*----------------------------------------------------------------------------
  1041. '* This routine writes YY$ to the user in the color and
  1042. '* intensity specified
  1043. '*
  1044. '*
  1045.       SUB PutScreen (YY$, Colour, Bold)
  1046. * REPLACING old line(s) by new
  1047. 2800  ZZ$ = ""
  1048.       IF Colour <> 99 THEN
  1049.          IF (Colour <> OldColour) OR (Bold <> IsBold) THEN
  1050. * ------[ first line different ]------
  1051.             ZZ$ = CHR$(27) + CHR$(91)                                ' DD021301
  1052.             IF Bold <> IsBold THEN
  1053.                IF Bold THEN
  1054.                   ZZ$ = ZZ$ + CHR$(49) + CHR$(59)               '1;  ' DD021301
  1055.                ELSE
  1056.                   ZZ$ = ZZ$ + CHR$(48) + CHR$(59)               '0;  ' DD021301
  1057.                END IF
  1058.             END IF
  1059.             ZZ$ = ZZ$ + MID$(STR$(Colour), 2) + CHR$(109)       'm   ' DD021301
  1060.          END IF
  1061.       ELSE
  1062.          ZZ$ = ZEmphasizeOff$
  1063.       END IF
  1064.       ZOutTxt$ = ZZ$ + YY$
  1065.       IF ZLocalUser THEN
  1066.          CALL QuickTput(ZOutTxt$, 0)
  1067.       ELSE
  1068.          ZSubParm = 4
  1069.          CALL Tput
  1070.       END IF
  1071.       ZSubParm = 0
  1072.       IF INSTR(YY$, CHR$(27) + CHR$(91)) = 0 THEN                    ' DD021301
  1073.          CurrentCol = CurrentCol + LEN(YY$)
  1074.          IF CurrentCol > 80 THEN
  1075.             CurrentCol = 0
  1076.             CurrentRow = 0
  1077.          END IF
  1078.       ELSE
  1079.          CurrentRow = 0
  1080.          CurrentCol = 0
  1081.       END IF
  1082.       OldColour = Colour
  1083.       IsBold = Bold
  1084.       END SUB
  1085.  
  1086. '*  ReformText()
  1087. '*----------------------------------------------------------------------------
  1088. '*  This routine reflows the text to the current margins.  Optionally,
  1089. '*  it right justifies all lines by adding "soft spaces"
  1090. '*
  1091. '*
  1092.       SUB ReformText (Justify%)
  1093.  
  1094. * REPLACING old line(s) by new
  1095. 2900  DIM Places(80)
  1096.  
  1097.       CALL EraseToEOL(1, 1)
  1098.       CALL PutScreen("Reformatting... Please Wait.", WhiteFore, ZTrue)
  1099.  
  1100.       CALL FindEndOfMsg(EndOfMsg)
  1101.  
  1102.       I = MsgLockLines + 1   ' Read index
  1103.       J = MsgLockLines + 1   ' Write index
  1104.  
  1105.       '*
  1106.       '* Reflow the text to the maximum on a line
  1107.       '*
  1108.       DO WHILE I <= EndOfMsg
  1109.          '*
  1110.          '* Loop until we get a long line or an end of paragraph
  1111.          '*
  1112.          ZOutTxt$ = ""
  1113.          DO WHILE 1
  1114.             YY$ = ZOutTxt$(I)
  1115.             CALL UnString(YY$, SoftSpace$)
  1116. * ------[ first line different ]------
  1117.             IF ZOutTxt$ <> "" AND RIGHT$(ZOutTxt$, 1) <> SPACE$(1) THEN ' DD021301
  1118.                ZOutTxt$ = ZOutTxt$ + SPACE$(1)                       ' DD021301
  1119.             END IF
  1120.             ZOutTxt$ = ZOutTxt$ + YY$
  1121.             CALL LastParaLine(I, EndOfMsg, EndOfPara)
  1122.             I = I + 1
  1123.             IF LEN(ZOutTxt$) > ZRightMargin THEN
  1124.                '*
  1125.                '* Wrap the long line
  1126.                '*
  1127.                CALL FindWrap(LEFT$(ZOutTxt$, ZRightMargin + 1), K)
  1128.                IF K <= 1 THEN
  1129.                   K = ZRightMargin
  1130.                END IF
  1131.                ZOutTxt$(J) = LEFT$(ZOutTxt$, K)
  1132.                IF EndOfPara THEN
  1133.                   '*
  1134.                   '* Go to the next paragraph
  1135.                   '*
  1136.                   J = J + 1
  1137.                   ZOutTxt$(J) = MID$(ZOutTxt$, K + 1)
  1138.                ELSE
  1139.                   '*
  1140.                   '* Keep the remaining part of the line and process
  1141.                   '* it on the next pass
  1142.                   '*
  1143.                   I = I - 1
  1144.                   ZOutTxt$(I) = MID$(ZOutTxt$, K + 1)
  1145.                END IF
  1146.                J = J + 1
  1147.                EXIT DO
  1148.             ELSEIF EndOfPara THEN
  1149.                ZOutTxt$(J) = ZOutTxt$
  1150.                J = J + 1
  1151.                EXIT DO
  1152.             END IF
  1153.          LOOP
  1154.       LOOP
  1155.  
  1156.       FOR I = J TO ZMsgDim                                           ' DD021702
  1157.          ZOutTxt$(I) = BlankLine$
  1158.       NEXT
  1159.  
  1160.       EndOfMsg = J - 1
  1161.  
  1162.       '*
  1163.       '* Space out the text on each line
  1164.       '*
  1165.       IF Justify% THEN
  1166.          FOR I = MsgLockLines + 1 TO EndOfMsg
  1167.             CALL LastParaLine(I, EndOfMsg, EndOfPara)
  1168.             IF NOT EndOfPara THEN
  1169.                '*
  1170.                '* Space out the line
  1171.                '*
  1172.                ZOutTxt$ = ZOutTxt$(I)
  1173.                CALL TrimTrail(ZOutTxt$, SPACE$(1))                   ' DD021301
  1174.                TxtLen = LEN(ZOutTxt$)
  1175.                SpacesToAdd = ZRightMargin - TxtLen
  1176.                IF SpacesToAdd > 0 THEN
  1177.                   '*
  1178.                   '* Skip leading spaces on the line
  1179.                   '*
  1180.                   Place = 1
  1181.                   IF LEFT$(ZOutTxt$, 1) = SPACE$(1) THEN             ' DD021301
  1182.                      CALL FindWord(ZOutTxt$, 1, Place)
  1183.                   END IF
  1184.                   '*
  1185.                   '* Find all of the possible places to space out the line
  1186.                   '*
  1187.                   NumPlaces = 0
  1188.                   DO WHILE 1
  1189.                      CALL FindWord(ZOutTxt$, 1, Place)
  1190.                      IF Place < TxtLen THEN
  1191.                         NumPlaces = NumPlaces + 1
  1192.                         Places(NumPlaces) = Place
  1193.                      ELSE
  1194.                         EXIT DO
  1195.                      END IF
  1196.                   LOOP
  1197.                   '*
  1198.                   '* Fill in available places with soft spaces
  1199.                   '*
  1200.                   IF NumPlaces <> 0 THEN
  1201.                      ExtraPlaces = (SpacesToAdd MOD NumPlaces)
  1202.                      LeftExtra = ExtraPlaces \ 2
  1203.                      RightExtra = ExtraPlaces - LeftExtra
  1204.                      FOR J = NumPlaces TO 1 STEP -1
  1205.                         SpacesThisPlace = SpacesToAdd \ NumPlaces
  1206.                         IF J <= LeftExtra OR J > NumPlaces - RightExtra THEN
  1207.                            SpacesThisPlace = SpacesThisPlace + 1
  1208.                         END IF
  1209.                         IF SpacesThisPlace <> 0 THEN
  1210.                            ZOutTxt$ = LEFT$(ZOutTxt$, Places(J) - 1) + STRING$(SpacesThisPlace, SoftSpace$) + MID$(ZOutTxt$, Places(J))
  1211.                         END IF
  1212.                      NEXT J
  1213.                   END IF
  1214.                END IF
  1215.                ZOutTxt$(I) = ZOutTxt$
  1216.             END IF
  1217.          NEXT I
  1218.       END IF
  1219.  
  1220.       CALL UpdateScreen
  1221.  
  1222.       END SUB
  1223.  
  1224. '*  SaveCursor()
  1225. '*----------------------------------------------------------------------------
  1226. '*  This routine saves the current cursor position
  1227. '*
  1228. '*
  1229.       SUB SaveCursor (Row%, Col%)
  1230.       Row% = CurrentRow
  1231.       Col% = CurrentCol
  1232.       END SUB
  1233.  
  1234. '*  UnGetChar()
  1235. '*----------------------------------------------------------------------------
  1236. '*   Puts a key in the beginning of the keyboard buffer
  1237. '*
  1238. '*
  1239.       SUB UnGetChar (X)
  1240.       ZCommportStack$ = CHR$(X) + ZCommportStack$
  1241.       END SUB
  1242.  
  1243. '*  UnString()
  1244. '*----------------------------------------------------------------------------
  1245. '*  Removes one string from another
  1246. '*
  1247. '*
  1248.       SUB UnString (YY$, BadString$)
  1249.       I = INSTR(YY$, BadString$)
  1250.       WHILE I <> 0
  1251.          YY$ = LEFT$(YY$, I - 1) + MID$(YY$, I + LEN(BadString$))
  1252.          I = INSTR(YY$, BadString$)
  1253.       WEND
  1254.       END SUB
  1255.  
  1256. '*  UpdateScreen()
  1257. '*----------------------------------------------------------------------------
  1258. '*  This is one of the most important routines  It compares the arrays
  1259. '*  ZOutTxt$ and ZWorkAra$ and only sends the user the DIFFERENCE between the
  1260. '*  two within the viewing area  In this way all processing can be done on
  1261. '*  ZOutTxt$ and then the screen is updated to reflect the changes. After the
  1262. '*  users screen is updated, ZWorkAra$ is changed to reflect what should be
  1263. '*  on the users' screen The cursor is restored to its original position
  1264. '*
  1265. '*
  1266.       SUB UpdateScreen
  1267. * REPLACING old line(s) by new
  1268. 3100  CALL SaveCursor(RowSave, ColSave)
  1269. * ------[ first line different ]------
  1270.       IF ZExpertUser THEN PE = ZPageLength _                         ' DD021901
  1271.          Else PE = ZPageLength - 4                                   ' DD021901
  1272.       FOR I = 3 TO PE AND Index < ZMsgDim                            ' DD021702
  1273.          Index = I + TopLine - 3
  1274.          ScreenLine$ = ZWorkAra$(I)
  1275.          IF Index >= ZMsgDim THEN
  1276.             MessageLine$ = ZOutTxt$(ZMsgDim)
  1277.          ELSE
  1278.             MessageLine$ = ZOutTxt$(Index)
  1279.          ENDIF
  1280.          LML = LEN(MessageLine$)
  1281.          IF Index = ZMaxMsgLines + 1 THEN
  1282.             CALL EraseToEOL(I, 1)
  1283.             CALL PutScreen("[* End of Message *]", CyanFore, ZTrue)  ' DD021702
  1284.             ZWorkAra$(I) = CHR$(EndKey)
  1285.          ELSEIF Index > ZMaxMsgLines + 1 THEN
  1286.             IF ScreenLine$ <> BlankLine$ THEN
  1287.                CALL EraseToEOL(I, 1)
  1288.                ZWorkAra$(I) = BlankLine$
  1289.             END IF
  1290.          ELSEIF MessageLine$ = ScreenLine$ THEN
  1291.             '*
  1292.             '* Screen = What's in message buffer
  1293.             '*
  1294.          ELSEIF MessageLine$ = BlankLine$ OR MessageLine$ = SPACE$(LML) THEN
  1295.             CALL EraseToEOL(I, 1)
  1296.             ZWorkAra$(I) = MessageLine$
  1297.          ELSE
  1298.             CALL MoveCursor(I, 1)
  1299.             YY$ = MessageLine$
  1300.             IF BlockDelActive AND CurrentRow <= RowSave THEN         ' DD021702
  1301.                CALL PutScreen(YY$, ZUserTextColor,ZFalse)            ' DD021702
  1302.             ELSE                                                     ' DD021702
  1303.                CALL PutScreen(YY$, ZUserTextColor, ZTrue)            ' DD032301
  1304.             END IF                                                   ' DD021702
  1305.             CALL EraseToEOL(CurrentRow, CurrentCol)
  1306.             ZWorkAra$(I) = ZOutTxt$(Index)
  1307.          END IF
  1308.       NEXT I
  1309.       CALL MoveCursor(RowSave, ColSave)
  1310.       END SUB
  1311.  
  1312. '*  UpdateStatusLine()
  1313. '*-----------------------------------------------------------------------------
  1314. '*  Rewrites the status line on screen line(s) 1 and 2
  1315. '*
  1316. '*    Input:  How% = 1   - Rewrite both lines
  1317. '*            How% = 2   - Just rewrite top line
  1318. '*
  1319.       SUB UpdateStatusLine (How%)
  1320. * REPLACING old line(s) by new
  1321. * ------[ first line different ]------
  1322. 3200  YY$ = "ANSIED" + SPACE$(1) + Version$ + SPACE$(1) + "by Tom Collins" + SPACE$(23) + "* Press ESC Twice for Menu *"
  1323.       YY$ = YY$ + SPACE$(79 - LEN(YY$))
  1324.       CALL MoveCursor(1, 1)
  1325.       CALL PutScreen(YY$, BlueFore, ZTrue)
  1326. * REPLACING old line(s) by new
  1327. 3210  IF How% = 1 THEN
  1328. * ------[ first line different ]------
  1329.          YY$ = CHR$(205) + " TO: " + MsgTo$ + SPACE$(1) + CHR$(205) + " RE: " + MsgSubj$ + SPACE$(1) + CHR$(205) ' DD021702
  1330.          YY$ = YY$ + STRING$(79 - LEN(YY$), CHR$(205))
  1331.          IF InsertMode THEN
  1332.             MID$(YY$, 74) = " INS "
  1333.          ELSE
  1334.             MID$(YY$, 74) = " OVW "
  1335.          END IF
  1336.          I = 1
  1337.          CALL MoveCursor(2, I)
  1338.          CALL PutScreen(YY$, RedFore, ZTrue)
  1339.       END IF
  1340.       END SUB
  1341.  
  1342. * INSERTING new line(s)
  1343. 3220 SUB DisplayKeys                                                 'Mpl021701
  1344.      IF ZExpertUser THEN EXIT SUB                                    'Mpl021701
  1345.      CALL MoveCursor(ZPageLength - 3,1)
  1346.      YY$ = STRING$(79,CHR$(205))
  1347.      MID$ (YY$,30) = " Quick-reference Help "                        ' CS050901
  1348.      CALL PutScreen(YY$,RedFore,ZTrue)                               ' DD021702
  1349.      CALL MoveCursor(ZPageLength - 2,1)
  1350.      CALL PutScreen (" ^ = [CTRL] │^W:Home│^E:Up    │^R:PageUp │^T:Del.Word│^Y:Del.Line │^K:Edit Menu",YellowFore, ZTrue) ' CS050901
  1351.      CALL MoveCursor(ZPageLength - 1,1)
  1352.      CALL PutScreen ("^A:Word Left│^S:Left│^D:Right │^F:Word Rt│^G:Delete  │^H:Backspace│^O:Re-flow",YellowFore, ZTrue) ' CS050901
  1353.      CALL MoveCursor(ZPageLength,1)
  1354.      CALL PutScreen ("^Z:End      │^X:Down│^C:PageDn│^V:Ins/Ovw│^B:Justify │^N:Help     │^P:Re-paint",YellowFore, ZTrue) ' CS050901
  1355.      END SUB
  1356.