home *** CD-ROM | disk | FTP | other *** search
/ Boston 2 / boston-2.iso / DOS / HILFEN / MODEM / EZBBSC / EZBBSC.PRG < prev    next >
Text File  |  1993-12-01  |  58KB  |  2,261 lines

  1. *****************************************************************************
  2. **
  3. ** Program Name: EZBBSC.PRG
  4. **         Author: John P. Halovanic
  5. **      Copyright (c) 1992, SilverWare Inc.
  6. **  Last modified: Jan 30, 1992 - 15:10
  7. **
  8. **
  9. ** DISCLAIMER
  10. ** 
  11. ** SilverWare Inc. MAKES NO WARRANTIES, express or implied concerning
  12. ** this software including, BUT NOT LIMITED TO, implied warranties of
  13. ** MERCHANTABILITY and/or FITNESS for a particular purpose.  SilverWare
  14. ** Inc. Will NOT BE LIABLE for any damages, CONTINGENT or CONSEQUENTIAL,
  15. ** from the use of the product material presented by  SilverWare Inc..
  16. ** REGISTERED USERS OF SilverClip may use ANY or ALL source code from this 
  17. ** program for your own development purposes.  This program is written in 
  18. ** Clipper 5, utilizing the SilverClip SPCS Library.
  19. **
  20. **
  21. ** Description:    EZBBSC.PRG is an example of a simple bulletin board system
  22. **        for Clipper 5 using the SilverClip SPCS communications
  23. **        library.  To run the EZBBSC.PRG copy the following files
  24. **        to your default directory:
  25. **
  26. **                EZBBSC.PRG
  27. **                CLOSE.ANS
  28. **                OPEN.ANS
  29. **                BBSFILES.DBF
  30. **                BBSPARMS.DBF
  31. **                BBSUSERS.DBF
  32. **
  33. **        Compile EZBBSC.PRG with the following command:
  34. **
  35. **                CLIPPER EZBBSC /W/N
  36. **
  37. **        Create EZBBSC.EXE with the following command:
  38. **
  39. **            RTLINK fi ezbbs lib clipper,extend,terminal,slvrclip
  40. **
  41. **
  42. ** ANSI Files:    CLOSE.ANS
  43. **        OPEN.ANS
  44. **
  45. **        NOTE: The ANSI Files (CLOSE.ANS and OPEN.ANS) were created
  46. **        with the THEDRAW program available from the SilverBullet
  47. **        bulletin board program.  NOTE: THEDRAW is not a SilverWare
  48. **        product.
  49. **
  50. ** Databases:
  51. **
  52. **        BBSFILES.DBF
  53. **
  54. **         Database that contains a list of the files in the upload/
  55. **         download directory.  One record for each file in the file
  56. **         list.  NOTE: The download directory is the CURRENT directory.
  57. **
  58. **         1  FFILE       Character     12    -- Filename
  59. **         2  FDESC       Character     60    -- Description of file
  60. **         3  FSECURITY   Numeric        1    -- Security Level
  61. **         4  FSIZE       Numeric       10    -- Size of File
  62. **
  63. **        BBSPARMS.DBF
  64. **
  65. **         Stores the default parameters for the EZ-BBS System.  One
  66. **         record.
  67. **
  68. **         1  FPORT       Numeric        1    -- Port Number to use
  69. **                                (Default COM1:)
  70. **         2  FBAUD       Numeric        6    -- Maximum baud rate
  71. **                                (Default: 2400 Baud)
  72. **         3  FMODEM      Character     50    -- Modem Setup String
  73. **                                (Default:
  74. **                                AT Z &C1 &D2 SO=1)
  75. **         4  FCALLS      Numeric        9    -- Number of Calls
  76. **         5  FSYSNAME    Character     40    -- System Name
  77. **                               (Default:
  78. **                     Welcome to EZ-BBS, by SilverWare Inc.)
  79. **         6  FDEFLEVEL   Numeric        1    -- Default Security Level
  80. **                                (Default: 1)
  81. **         7  FDIRECT     Logical        1    -- Direct Connect or Modem
  82. **                                Connection
  83. **                               (Default: F (MODEM))
  84. **
  85. **        BBSUSERS.DBF
  86. **
  87. **         Stores information about users that have logged into the
  88. **         EZ-BBS System.  One record per caller.
  89. **
  90. **         1  FFIRST      Character     10    -- First Name of user
  91. **         2  FLAST       Character     15    -- Last Name of user
  92. **         3  FPASSWORD   Character     10    -- Users password
  93. **         4  FUSERCALL   Numeric        8    -- Number of calls
  94. **         5  FUSERLEVEL  Numeric        1    -- Users Security Level
  95. **
  96. *****************************************************************************
  97.  
  98. **********************************************************************
  99. **
  100. **  Procs & Fncts: MAIN()
  101. **               : SWINITCOM()
  102. **               : SWRESETMODEM()
  103. **               : SWSHUTDOWN()
  104. **               : SWWAITFORCALL()
  105. **               : AUTOBAUD()
  106. **               : BASED
  107. **               : SWLOGIN()
  108. **               : SWOPENFILES()
  109. **               : SWPRESSKEY()
  110. **               : SWMAINMENU()
  111. **               : SWLISTFILES()
  112. **               : SWLISTUSERS()
  113. **               : SWTRANSMENU()
  114. **               : SWTRANSFER()
  115. **               : SWSTATUS()
  116. **               : SWBACKDROP()
  117. **               : SWFILESIZE()
  118. **               : SWSKIPLINE()
  119. **               : SWASAY()
  120. **               : SWAPOSCUR()
  121. **               : SWACOLOR()
  122. **               : SWACLEAR()
  123. **               : SWAGET()
  124. **               : SWACURUP()
  125. **               : SWACURDWN()
  126. **               : SWACURRIGHT()
  127. **               : SWACURLEFT()
  128. **               : SWAERSEOL()
  129. **               : SWAERSBOL()
  130. **               : SWAERSLINE()
  131. **               : SWAERSEOS()
  132. **               : SWAERSBOS()
  133. **               : SWABOX()
  134. **               : SWAPROMPT()
  135. **
  136. **          Calls: MAIN()
  137. **
  138. ***********************************************************************
  139.  
  140. #include "slvrclip.ch"
  141.  
  142. ******************************************************************************
  143. * Define all EZ-BBS constants
  144. ******************************************************************************
  145.  
  146. ** Foreground Colors
  147.  
  148. #define        SWAFBLACK    30
  149. #define        SWAFRED        31
  150. #define        SWAFGREEN    32
  151. #define        SWAFYELLOW    33
  152. #define        SWAFBLUE    34
  153. #define        SWAFMAGENTA    35
  154. #define        SWAFCYAN    36
  155. #define        SWAFWHITE    37
  156.  
  157. ** Background Colors
  158.  
  159. #define        SWABBLACK    40
  160. #define        SWABRED        41
  161. #define        SWABGREEN    42
  162. #define        SWABYELLOW    43
  163. #define        SWABBLUE    44
  164. #define        SWABMAGENTA    45
  165. #define        SWABCYAN    46
  166. #define        SWABWHITE    47
  167.  
  168. ** Special Colors
  169.  
  170. #define        SWABLINK    5
  171. #define        SWAREVERSE    7
  172. #define        SWABOLD        1
  173. #define        SWAUNDERLINE    4
  174. #define        SWANORMAL    0
  175.  
  176. #define        EZBBSVER    "1.00 [Jan 30, 1992]"
  177.  
  178. ******************************************************************************
  179. * Define all EZ-BBS STATICS
  180. ******************************************************************************
  181.  
  182. STATIC nPort, nBaud, cFirst, cLast, cPassword, nUserCall, nDefLevel, nUserLevel, cFr, lDirect, nMaxRows, nMaxCols
  183.  
  184.  
  185. ******************************************************************************
  186. * Define all EZ-BBS FIELDS
  187. ******************************************************************************
  188.  
  189. FIELD FPORT, FBAUD, FMODEM, FCALLS, FSYSNAME, FDEFLEVEL, FDIRECT
  190.  
  191. FIELD FFIRST, FLAST, FPASSWORD, FUSERCALL, FUSERLEVEL
  192.  
  193. FIELD FFILE, FDESC, FSECURITY, FSIZE
  194.  
  195.  
  196. ***********************************************************************
  197. **
  198. **       Function: MAIN()
  199. **
  200. **      Called by: BBS.PRG                           
  201. **
  202. **          Calls: SWSETTRANS()
  203. **               : SWOPENFILES()
  204. **               : SWBITOR()
  205. **               : SWBLDATRIB()
  206. **               : SWBACKDROP()
  207. **               : SWINITCOM()
  208. **               : SWRESETMODEM()
  209. **               : SWWAITFORCALL()
  210. **               : SWLOGIN()
  211. **               : SWACLEAR()
  212. **               : SWACOLOR()
  213. **               : SWABOX()
  214. **               : SWASAY()
  215. **               : SWAPOSCUR()
  216. **               : SWPRESSKEY()
  217. **               : SWMAINMENU()
  218. **               : SWSTATUS()
  219. **               : SWTXASCII()
  220. **               : SWSHUTDOWN()
  221. **
  222. ***********************************************************************
  223.  
  224. FUNCTION MAIN()
  225.  
  226. ******************************************************************************
  227. * Define all variables
  228. ******************************************************************************
  229.  
  230. LOCAL getlist        && Stop Warning Message
  231.  
  232. LOCAL nRet,cModemString,nKey,nMaxVal,nFHighLight,nBHighLight,nMessageRow,nMesageCol,cTemp
  233. MEMVAR cRed,cBlue
  234.  
  235. SET SCOREBOARD OFF
  236.  
  237. cFr      := (CHR(201)+CHR(205)+CHR(187)+CHR(186)+;
  238.              CHR(188)+CHR(205)+CHR(200)+CHR(186)+chr(32))
  239. nMaxRows := 22
  240. nMaxCols := 79
  241.  
  242.  
  243. ****************************************
  244. * Define File Transfer Box Coordinates *
  245. ****************************************
  246.  
  247. nRet     := SWSetTrans(7,6)
  248. nRet     := SWSetTrans(8,20)
  249.  
  250.  
  251. *********************************
  252. * Open All .DBF and Index Files *
  253. *********************************
  254.  
  255. nRet := SWOpenFiles(SWTRUE)
  256.  
  257.  
  258. *******************************
  259. * Define Local Color Settings *
  260. *******************************
  261.  
  262. if iscolor()
  263.    cRed  := "w+/r+,w+/rb+,n"
  264.    cBlue := "w+/b,gr+/rb+,n"
  265.    
  266.    nRet  := SWSetTrans(4,SWBitOr(SWBldAtrib(SWWHITE,SWBLUE),SWINTENSE))
  267.    nRet  := SWSetTrans(5,SWBitOr(SWBldAtrib(SWWHITE,SWBLUE),SWINTENSE))
  268.    nRet  := SWSetTrans(6,SWBldAtrib(SWBLUE,SWCYAN))
  269.    
  270. else
  271.    cRed  := "w/n,n/w,n"
  272.    cBlue := "w+/n,n/w+,n"
  273.    
  274. endif
  275.  
  276.  
  277. ****************
  278. * Setup Screen *
  279. ****************
  280.  
  281. clear
  282.  
  283. select BBSPARMS
  284. go 1
  285.  
  286. set color to &cBlue
  287. clear
  288. @0,0 to 7,79 double
  289. set color to &cRed
  290. @0,2 say " Configuration Information "
  291. set color to &cBlue
  292. nPort := FPORT+1
  293. cTemp := "Y"
  294.  
  295. @2,2 say "COM Port (1234)     : " get nPort
  296. @3,2 say "Max Baud Rate       : " get FBAUD
  297. @4,2 say "Modem String        : " get FMODEM
  298. @5,2 say "Modem CONNECT (Y/N) : " get cTemp
  299. read
  300.  
  301. if upper(cTemp) == "Y"
  302.    replace FDIRECT with SWFALSE
  303. else
  304.    replace FDIRECT with SWTRUE
  305. endif
  306.  
  307. replace FPORT with nPort-1
  308.  
  309. clear
  310.  
  311. *******************************
  312. * Initialize Params Variables *
  313. *******************************
  314.  
  315. select BBSPARMS
  316.  
  317. nPort        := FPORT
  318. nBaud        := FBAUD
  319. cModemString    := FMODEM
  320. nDefLevel     := FDEFLEVEL
  321. lDirect        := FDIRECT
  322.  
  323.  
  324. *************************
  325. * Local Backdrop Screen *
  326. *************************
  327.  
  328. nRet := SWBackDrop()
  329.  
  330.  
  331. *****************
  332. * Open COM Port *
  333. *****************
  334.  
  335. nRet := SWInitCom(nPort,nBaud)
  336.  
  337. if nRet != SWCSUCCESSFUL
  338.    nRet := SWStatus("Unable To Open COM Port, Error: "+SWErrToTxt(nRet,0))
  339.    nRet := inkey(3)
  340.    @17,0 say ""
  341.    quit
  342.  
  343. endif
  344.  
  345.  
  346. *********************
  347. * Main Body Of Loop *
  348. *********************
  349.  
  350. do while lastkey() != 27
  351.    
  352.    nKey := inkey()
  353.    
  354.    nRet := SWResetModem(nPort,cModemString)     && Reset Modem
  355.    nRet := SWWaitForCall(nPort)                 && Wait For A Call 
  356.    
  357.    if nRet != -1
  358.       nRet := SWLogIn(nPort)                    && Get User Login
  359.       
  360.    endif
  361.    
  362.    if nRet > 0
  363.       
  364.       nUserCall  := FUSERCALL
  365.       nUserLevel := FUSERLEVEL
  366.  
  367.  
  368.       **********************************
  369.       * Display Local User Information *
  370.       **********************************
  371.       
  372.       @1,14 say trim(cFirst)+" "+trim(cLast)
  373.       @2,14 say trim(cPassword)
  374.       @3,14 say alltrim(str(nUserCall,8,0))
  375.       @4,14 say str(nUserLevel,1,0)
  376.  
  377.  
  378.       *************************
  379.       * Send Out User Welcome *
  380.       *************************
  381.  
  382.       nRet := SWStatus("Sending Welcome Message...")
  383.       
  384.       select BBSPARMS
  385.       replace FCALLS with FCALLS+1
  386.       
  387.       @4,69 say alltrim(str(FCALLS,9,0))
  388.       
  389.       nRet := SWAClear(nPort)
  390.       
  391.       nRet := SWAColor(nPort,SWAFWHITE,SWABBLUE)
  392.       nRet := SWABox(nPort, 3, 2, 17, 65, cFr)
  393.       
  394.       nRet := SWASay(nPort,nMaxRows-2,1,replicate(chr(205),nMaxCols))
  395.       nRet := SWASay(nPort,nMaxRows,1,replicate(chr(205),nMaxCols))
  396.       
  397.       nRet := SWAColor(nPort,SWAFWHITE,SWABRED)
  398.       nRet := SWASay(nPort,3,4," "+trim(FSYSNAME)+" ")
  399.       
  400.       nRet := SWAColor(nPort,SWAFWHITE,SWABBLUE)
  401.       nRet := SWASay(nPort,5,4,"Welcome "+trim(cFirst)+" "+cLast)
  402.       
  403.       nRet := SWASay(nPort,6,4,"You Are Caller Number "+alltrim(str(FCALLS,8,0)))
  404.       nRet := SWASay(nPort,7,4,"You Have Called "+alltrim(str(nUserCall,8,0))+" Times...")
  405.       nRet := SWASay(nPort,8,4,"You Security Level Is ("+str(nUserLevele,1,0)+")")
  406.  
  407.       nRet := SWASay(nPort,10,4,"EZ-BBS Version "+EZBBSVER)
  408.       nRet := SWASay(nPort,11,4,SWAsyncVer(1))
  409.       nRet := SWASay(nPort,12,4,version())
  410.       nRet := SWASay(nPort,13,4,"EZ-BBS in written in Clipper 5 and SilverClip (SPCS)")
  411.       nRet := SWASay(nPort,14,4,"To receive more information on SilverClip (SPCS)")
  412.       nRet := SWASay(nPort,15,4,"Call SilverWare Inc. at (214) 247-0131 ")
  413.       
  414.       nRet := SWAPosCur(nPort,nMaxRows-2,1)
  415.       nRet := SWPressKey(nPort)
  416.       
  417.  
  418.       **********************
  419.       * Main Menu Function *
  420.       **********************
  421.       
  422.       nRet := SWMainMenu(nPort)
  423.  
  424.       
  425.       ****************************
  426.       * Send Out Closing Screen *
  427.       ****************************
  428.  
  429.       if nRet == 5
  430.          
  431.          if file("CLOSE.ANS")
  432.             nRet := SWStatus("Sending Closing Screen")
  433.             nRet := SWTXASCII(nPort,"CLOSE.ANS",SWFALSE)
  434.             nRet := SWPressKey(nPort)
  435.             
  436.          else
  437.             nRet := SWStatus("File CLOSE.ANS Does Not Exist...")
  438.             nRet := inkey(1)
  439.             
  440.          endif
  441.          
  442.       endif
  443.  
  444.    endif
  445.    
  446. enddo
  447.  
  448.  
  449. ****************************************
  450. * Close Down COM Ports And Exit To DOS *
  451. ****************************************
  452.  
  453. nRet := SWShutDown(nPort)
  454. @17,0 say ""
  455.  
  456. RETURN(0)
  457.  
  458.  
  459.  
  460. ***********************************************************************
  461. **
  462. **       Function: SWINITCOM()
  463. **
  464. **      Called by: MAIN()
  465. **
  466. **          Calls: SWSTATUS()
  467. **               : SWOPENCOM()
  468. **               : SWSETUART()
  469. **
  470. **
  471. **  This function opens the COM port and set the initial baud rate.
  472. **
  473. **  nPort = COM port to open.
  474. **  nBaud = Initial baud rate to set.
  475. **
  476. **
  477. ***********************************************************************
  478.  
  479. FUNCTION SWInitCom(nPort,nBaud)
  480. LOCAL nRet
  481.  
  482. nRet := 0
  483. nRet := SWStatus("Opening COM Port: "+str(nPort+1,1,0))
  484.  
  485. if !SWIsMCA() .and. nPort > 1
  486.    nRet := SWSetComm(0,nPort,iif(nPort==2,1000,744))
  487.    nRet := SWSetComm(1,nPort,iif(nPort==2,IRQ4,IRQ3))
  488.  
  489. endif
  490.  
  491. nRet := SWOpenCom(nPort, 4000, 4000, 0)
  492.  
  493. if nRet == SWCSUCCESSFUL
  494.    nRet := SWSetUart(nPort,nBaud,0,8,1)
  495.    
  496. endif
  497.  
  498. RETURN(nRet)
  499.  
  500.  
  501.  
  502. ***********************************************************************
  503. **
  504. **       Function: SWRESETMODEM()
  505. **
  506. **      Called by: MAIN()
  507. **
  508. **          Calls: SWSTATUS()
  509. **               : SWSETUART()
  510. **               : SWMESCAPE()
  511. **               : SWMHOOK()
  512. **               : SWMTXCMD()
  513. **
  514. **  This function will reset the modem to a known state on start-up
  515. **  and after every call.
  516. **
  517. **  nPort        = COM port to use.
  518. **  cModemString = Mode setup string in BBSPARMS.DBF.
  519. **
  520. ***********************************************************************
  521.  
  522. FUNCTION SWResetModem(nPort,cModemString)
  523. LOCAL nRet
  524.  
  525. select BBSPARMS
  526. go top
  527. nBaud := FBAUD
  528.  
  529. nRet := 0
  530. nRet := SWStatus("Re-setting Modem...")
  531. nRet := SWMEscape(nPort)
  532. nRet := SWWait(18)
  533. nRet := SWMHook(nPort,"0")
  534. nRet := SWWait(18)
  535. nRet := SWSetUart(nPort,nBaud,0,8,1)
  536. nRet := SWMTXCmd(nPort,trim(cModemString))
  537. @3,69 say alltrim(str(nBaud,6,0))
  538.  
  539.  
  540. RETURN(0)
  541.  
  542.  
  543.  
  544. ***********************************************************************
  545. **
  546. **       Function: SWSHUTDOWN()
  547. **
  548. **      Called by: MAIN()
  549. **
  550. **          Calls: SWSTATUS()
  551. **               : SWMESCAPE()
  552. **               : SWMHOOK()
  553. **               : SWMAUTOANS()
  554. **               : SWCLOSECOM()
  555. **
  556. **  This function is the shutdown function that closes the COM port,
  557. **  closes all open files and exits to DOS.
  558. **
  559. **  nPort = COM port in use.
  560. **
  561. **
  562. ***********************************************************************
  563.  
  564. FUNCTION SWShutDown(nPort)
  565. LOCAL nRet
  566.  
  567. nRet := 0
  568. nRet := SWStatus("Turnning Off Auto-Answer...")
  569. nRet := SWMEscape(nPort)
  570. nRet := SWMHook(nPort,"0")
  571. nRet := SWMAutoAns(nPort,"0")
  572. close databases
  573. close all
  574. nRet := SWStatus("System Returning To DOS...")
  575. nRet := SWCloseCom(nPort, 0)
  576.  
  577. RETURN(0)
  578.  
  579.  
  580.  
  581. ***********************************************************************
  582. **
  583. **       Function: SWWAITFORCALL()
  584. **
  585. **      Called by: MAIN()
  586. **
  587. **          Calls: SWSTATUS()
  588. **               : SWGETCD()
  589. **               : AUTOBAUD()
  590. **
  591. **  This function monitors the modem line for an incomming call.
  592. **  When a call is received, it will answer the call and check
  593. **  the callers baud rate.
  594. **
  595. **  nPort = COM port in use.
  596. **
  597. ***********************************************************************
  598.  
  599. FUNCTION SWWaitForCall(nPort)
  600. LOCAL nRet, nKey
  601.  
  602. nRet := SWStatus("Waiting For Call...")
  603. nRet := -1
  604.  
  605. do while lastkey() != 27
  606.    nKey := inkey()
  607.  
  608.    if SWGetCD(nPort)
  609.       
  610.       if !lDirect
  611.          nRet := SWSRTSCTSF(nPort,SWTRUE)
  612.          nRet := AutoBaud(nPort, 20, SWTRUE)
  613.       else
  614.          nRet := nBaud
  615.       endif
  616.       
  617.       @3,69 say alltrim(str(nRet,6,0))
  618.       nRet := SWStatus("Call CONNECTed At "+alltrim(str(nRet,6,0)))
  619.       nRet := 0
  620.       exit
  621.       
  622.    endif
  623.    
  624. enddo
  625.  
  626. RETURN(nRet)
  627.  
  628.  
  629.  
  630. ***********************************************************************
  631. **
  632. **       Function: AUTOBAUD()
  633. **
  634. **      Called by: SWWAITFORCALL()
  635. **
  636. **          Calls: SWGETSEC()
  637. **               : SWRXEMPTY()
  638. **               : SWMGETRESP()
  639. **               : SWSETBAUD()
  640. **
  641. **
  642. **
  643. ** This function is designed to be called after the modem (in auto-answer)
  644. ** answers the phone or dialing the phone to CONNECT to another mode.  When
  645. ** two modem CONNECT, they may negotiate a baud rate and drop from your
  646. ** current UART baud rate setting to a lower baud rate.  This function will
  647. ** read the modem response in VERBOSE mode or NON-VERBOSE mode for the 
  648. ** CONNECT baud rate.  The function will optionally call the SWSetBaud()
  649. ** function based on the (lSetBaudRate) parameter.  The function returns
  650. ** the detected baud rate.
  651. ** 
  652. ** nPort    = Port vale for the open COM port.
  653. ** nMaxTime    = Number od seconds to wait for a response.
  654. ** lSetBaudRate    = Optional setting of the baud rate.
  655. **
  656. ** 
  657. ***********************************************************************
  658.  
  659. FUNCTION AutoBaud(nPort, nMaxTime, lSetBaudRate)
  660. LOCAL cResponseString, nReturnCode, nBaud, lBaudDetected
  661.  
  662. nMaxTime    := SWGetSec() + nMaxTime
  663. nBaud         := SWCTIMEDOUT
  664. lBaudDetected    := SWFALSE
  665. cResponseString := ""
  666.  
  667. do while SWTRUE
  668.    
  669.    if SWGetSec() > nMaxTime    && Timer check
  670.       nBaud := SWCTIMEDOUT
  671.       exit
  672.    endif
  673.  
  674.    if !SWGetCD(nPort)
  675.       nBaud := SWCNOCARRIER
  676.       exit
  677.    endif
  678.    
  679.    if !SWRXEmpty(nPort)
  680.       
  681.       nReturnCode := SWMGetResp(nPort,@cResponseString,2)
  682.       
  683. ***** Check VERBOSE and NON-VERBOSE return strings *****
  684.       
  685.       do case
  686.       case cResponseString == "CONNECT"       .or. cResponseString == "1"
  687.          nBaud := 300
  688.          lBaudDetected := SWTRUE
  689.       case cResponseString == "CONNECT 1200"  .or. cResponseString == "5"
  690.          nBaud := 1200
  691.          lBaudDetected := SWTRUE
  692.       case cResponseString == "CONNECT 2400"  .or. cResponseString == "10"
  693.          nBaud := 2400
  694.          lBaudDetected := SWTRUE
  695.       case cResponseString == "CONNECT 4800"  .or. cResponseString == "11"
  696.          nBaud := 4800
  697.          lBaudDetected := SWTRUE
  698.       case cResponseString == "CONNECT 9600"  .or. cResponseString == "12"
  699.          nBaud := 9600
  700.          lBaudDetected := SWTRUE
  701.       case cResponseString == "CONNECT 19200" .or. cResponseString == "14"
  702.          nBaud := 19200
  703.          lBaudDetected := SWTRUE
  704.       endcase
  705.       
  706. ***** Set optional baud rate *****
  707.       
  708.       if lBaudDetected == SWTRUE
  709.          if lSetBaudRate == SWTRUE
  710.             nReturnCode := SWSetBaud(nPort,nBaud)
  711.         nReturnCode := SWTXChar(nPort,13)
  712.          endif
  713.          exit
  714.       endif
  715.       
  716.    endif
  717. enddo
  718.  
  719. RETURN(nBaud)
  720.  
  721.  
  722.  
  723. ***********************************************************************
  724. **
  725. **       Function: SWLOGIN()
  726. **
  727. **      Called by: MAIN()
  728. **
  729. **          Calls: SWSTATUS()
  730. **               : SWACLEAR()
  731. **               : SWTXASCII()
  732. **               : SWFLUSHRX()
  733. **               : SWAPOSCUR()
  734. **               : SWAERSLINE()
  735. **               : SWASAY()
  736. **               : SWAGET()
  737. **
  738. **        Indexes: USER.NDX 
  739. **
  740. **  This function prompts the user for login information.
  741. **
  742. **  nPort = COM port in use.
  743. **
  744. ***********************************************************************
  745.  
  746. FUNCTION SWLogIn(nPort)
  747. LOCAL nTrys, lOK, nRet, cSeekVar, cYN
  748.  
  749. cFirst     := ""
  750. cLast      := ""
  751. cPassWord  := ""
  752. nTrys      := 0
  753. lOK       := SWFALSE
  754. nRet       := 0
  755. cSeekVar   := ""
  756. cYN        := "F"
  757.  
  758.  
  759. nRet := inkey(1)
  760. nRet := SWFlushRX(nPort)
  761.  
  762. nRet := SWStatus("Waiting For Remote CARRIER...")
  763. nRet := inkey(10)
  764.  
  765. nRet := SWStatus("Sending Open Screen...")
  766. nRet := SWAClear(nPort)
  767.  
  768.  
  769. if file("OPEN.ANS")
  770.    nRet := SWTXASCII(nPort,"OPEN.ANS",SWFALSE)
  771.    
  772. else
  773.    nRet := SWStatus("File OPEN.ANS Does Not Exist...")
  774.    
  775. endif
  776.  
  777. nRet := inkey(1)
  778. nRet := SWStatus("Waiting For User Login...")
  779.  
  780. for nTrys := 1 to 3
  781.    nRet := SWFlushRX(nPort)
  782.    
  783.    nRet := SWAPosCur(nPort,21,1)
  784.    nRet := SWAErsLine(nPort)
  785.    nRet := SWASay(nPort,21,1,"Enter First Name:")
  786.    nRet := SWAGet(nPort,21,19,@cFirst,10,60,SWTRUE)
  787.  
  788.    if nRet == SWCLOCALABORT
  789.       nTrys := 4
  790.       loop
  791.  
  792.    endif
  793.  
  794.    cFirst := upper(cFirst)
  795.    
  796.    nRet := SWAPosCur(nPort,22,1)
  797.    nRet := SWAErsLine(nPort)
  798.    nRet := SWASay(nPort,22,1,"Enter Last Name :")
  799.    nRet := SWAGet(nPort,22,19,@cLast,15,60,SWTRUE)
  800.  
  801.    if nRet == SWCLOCALABORT
  802.       nTrys := 4
  803.       loop
  804.  
  805.    endif
  806.  
  807.    cLast := upper(cLast)
  808.    
  809.    nRet := SWAPosCur(nPort,23,1)
  810.    nRet := SWAErsLine(nPort)
  811.    nRet := SWASay(nPort,23,1,"Enter Password  :")
  812.    nRet := SWAGet(nPort,23,19,@cPassWord,10,60,SWFALSE)
  813.  
  814.    if nRet == SWCLOCALABORT
  815.       nTrys := 4
  816.       loop
  817.  
  818.    endif
  819.  
  820.    cPassWord := upper(cPassWord)
  821.    
  822.    if (empty(cFirst)) .or. (empty(cLast)) .or. (empty(cPassWord))
  823.       loop
  824.       
  825.    endif
  826.    
  827.    select BBSUSERS
  828.    set index to user
  829.    
  830.    cSeekVar := substr(cLast+space(15),1,15)+substr(cFirst+space(10),1,10)+substr(cPassWord+space(10),1,10)
  831.    
  832.    seek cSeekVar
  833.    
  834.    if found()
  835.       nRet := recno()
  836.       replace FUSERCALL with FUSERCALL+1
  837.       exit
  838.       
  839.    else
  840.       
  841.       nRet := SWAClear(nPort)
  842.       nRet := SWASay(nPort,1,1,"Are You A New User To This System (Y/N) :")
  843.       nRet := SWAGet(nPort,1,43,@cYN,2,60,SWTRUE)
  844.       
  845.       if upper(cYN) == "Y"
  846.          
  847.          nRet := SWStatus("New User Logging On...")
  848.          
  849.          cYN := "N"
  850.          nRet := SWASay(nPort,4,1,"First Name : "+trim(cFirst))
  851.          nRet := SWASay(nPort,5,1,"Last Name  : "+trim(cLast))
  852.          nRet := SWASay(nPort,6,1,"Password   : "+trim(cPassWord))
  853.          
  854.          nRet := SWASay(nPort,8,1,"Is This All Correct (Y/N) :")
  855.          nRet := SWAGet(nPort,8,29,@cYN,2,60,SWTRUE)
  856.          
  857.          if upper(cYN) == "Y"
  858.             
  859.             append blank
  860.             
  861.             replace FFIRST     with cFirst
  862.             replace FLAST      with cLast
  863.             replace FPASSWORD  with cPassWord
  864.             replace FUSERCALL  with 1
  865.             replace FUSERLEVEL with nDefLevel
  866.             nRet := recno()
  867.             exit
  868.             
  869.          endif
  870.          
  871.       endif
  872.       
  873.    endif
  874.    
  875. next
  876.  
  877. RETURN(nRet)
  878.  
  879.  
  880.  
  881. ***********************************************************************
  882. **
  883. **       Function: SWOPENFILES()
  884. **
  885. **      Called by: MAIN()
  886. **
  887. **          Calls: SWSTATUS()
  888. **
  889. **           Uses: BBSPARMS.DBF           Alias: BBSPARMS
  890. **               : BBSUSERS.DBF           Alias: BBSUSERS
  891. **               : BBSFILES.DBF           Alias: BBSFILES
  892. **
  893. **        Indexes: USER.NDX           
  894. **               : FILES.NDX
  895. **
  896. **  This function open all .DBFs and indexes for the EZ-BBS.
  897. **
  898. **  lIndex = SWTRUE -> index all files, SWFALSE -> do not index files.
  899. **
  900. **
  901. ***********************************************************************
  902.  
  903. FUNCTION SWOpenFiles(lIndex)
  904. LOCAL nRet
  905.  
  906. nRet := SWStatus("Opening All .DBF and Index Files...")
  907.  
  908. select 1
  909. use BBSPARMS alias BBSPARMS
  910.  
  911. select 2
  912. use BBSUSERS alias BBSUSERS
  913. select BBSUSERS
  914. go top
  915. if lIndex
  916.    index on FLAST+FFIRST+FPASSWORD to user
  917.    
  918. endif
  919.  
  920. select 3
  921. use BBSFILES alias BBSFILES
  922. select BBSFILES
  923. go top
  924. if lIndex
  925.    index on FFILE to files
  926.    
  927. endif
  928.  
  929. RETURN(0)
  930.  
  931.  
  932.  
  933. ***********************************************************************
  934. **
  935. **       Function: SWPRESSKEY()
  936. **
  937. **      Called by: MAIN()
  938. **               : SWLISTFILES()
  939. **               : SWLISTUSERS()
  940. **
  941. **          Calls: SWTXCHAR()
  942. **               : SWTXSTRING()
  943. **               : SWFLUSHRX()
  944. **               : SWWTRXCNT()
  945. **
  946. **  This functions sends the message Press Any Key To Continue... to
  947. **  the remote user and waits for the key stroke.
  948. **
  949. **  nPort = COM port in use.
  950. **
  951. ***********************************************************************
  952.  
  953. FUNCTION SWPressKey(nPort)
  954. LOCAL nRet
  955.  
  956. nRet := SWTXChar(nPort,13)
  957. nRet := SWTXChar(nPort,10)
  958. nRet := SWTXString(nPort,"Press Any Key To Continue...")
  959. nRet := SWFlushRX(nPort)
  960. nRet := SWWtRXCnt(nPort,30*SWSECOND,1)
  961. nRet := SWFlushRX(nPort)
  962.  
  963. RETURN(0)
  964.  
  965.  
  966.  
  967. ***********************************************************************
  968. **
  969. **       Function: SWMAINMENU()
  970. **
  971. **      Called by: MAIN()
  972. **
  973. **          Calls: SWSTATUS()
  974. **               : SWACLEAR()
  975. **               : SWACOLOR()
  976. **               : SWABOX()
  977. **               : SWASAY()
  978. **               : SWAPROMPT()
  979. **               : SWLISTFILES()
  980. **               : SWTRANSMENUMENU()
  981. **               : SWTRANSFER()
  982. **               : SWERRTOTXT()
  983. **               : SWLISTUSERS()
  984. **
  985. **  This function is the remote main menu of EZ-BBS.
  986. **
  987. **  nPort = COM port in use.
  988. **
  989. ***********************************************************************
  990.  
  991. FUNCTION SWMainMenu(nPort)
  992. LOCAL aMain := {;
  993.    {9,10, "File Listing   "," List all files on this system"},;
  994.    {10,10,"Download A File"," Download a file to your PC  "},;
  995.    {11,10,"Upload A File  "," Upload a file to this system "},;
  996.    {12,10,"User Listing   "," List all users on this system"},;
  997.    {13,10,"Quit           "," Say goodbye and hang up (Log Off)"};
  998.    }
  999. LOCAL nRet, nArrayLength, nRow, nCol
  1000.  
  1001. nRow         := 7
  1002. nCol         := 8
  1003. nArrayLength := len(aMain)
  1004.  
  1005. do while SWTRUE
  1006.    
  1007.    nRet := SWStatus("At Main Menu...")
  1008.    nRet := SWAClear(nPort)
  1009.    
  1010.    nRet := SWAColor(nPort,SWAFWHITE,SWABBLUE)
  1011.    nRet := SWABox(nPort, nRow, nCol, nRow+8, nCol+18, cFr)
  1012.    
  1013.    nRet := SWASay(nPort,nMaxRows-2,1,replicate(chr(205),nMaxCols))
  1014.    nRet := SWASay(nPort,nMaxRows,1,replicate(chr(205),nMaxCols))
  1015.    
  1016.    nRet := SWAColor(nPort,SWAFWHITE,SWABRED)
  1017.    nRet := SWASay(nPort,nRow,nCol+2," Main Menu ")
  1018.    
  1019.    nRet := SWAPrompt(nPort,@aMain,nMaxRows-1,1,SWAFWHITE,SWABBLUE,SWAFWHITE,SWABYELLOW,nArrayLength)
  1020.    
  1021.    do case
  1022.    case nRet == 1
  1023.       nRet := SWListFiles(nPort)
  1024.       
  1025.    case nRet == 2
  1026.       nRet := SWTransMenuMenu(nPort)        && Sending
  1027.       if nRet != 6
  1028.          nRet := SWTransfer(nPort,nRet,0)
  1029.          nRet := SWStatus("File Transfer Results "+SWErrToTxt(nRet,0))
  1030.       endif
  1031.       
  1032.    case nRet == 3
  1033.       nRet := SWTransMenuMenu(nPort)        && Receiving
  1034.       if nRet != 6
  1035.          nRet := SWTransfer(nPort,nRet,1)
  1036.          nRet := SWStatus("File Transfer Results "+SWErrToTxt(nRet,0))
  1037.       endif
  1038.       
  1039.    case nRet == 4
  1040.       nRet := SWListUsers(nPort)
  1041.       
  1042.    case (nRet == 5) .or. (nRet == SWCNOCARRIER) .or. (nRet == SWCLOCALABORT)
  1043.       exit
  1044.       
  1045.    endcase
  1046.    
  1047. enddo
  1048.  
  1049. RETURN(nRet)
  1050.  
  1051.  
  1052.  
  1053. ***********************************************************************
  1054. **
  1055. **       Function: SWLISTFILES()
  1056. **
  1057. **      Called by: SWMAINMENU()
  1058. **
  1059. **          Calls: SWSTATUS()
  1060. **               : SWACLEAR()
  1061. **               : SWACOLOR()
  1062. **               : SWASAY()
  1063. **               : SWAGET()
  1064. **               : SWSKIPLINE()
  1065. **               : SWPRESSKEY()
  1066. **
  1067. **        Indexes: FILES.NDX
  1068. **
  1069. **  This function displays to the remote a file listing of files 
  1070. **  contained in the BBSFILES.DBF.
  1071. **
  1072. **  nPort = COM port in use.
  1073. **
  1074. ***********************************************************************
  1075.  
  1076. FUNCTION SWListFiles(nPort)
  1077. LOCAL nRet, nCounter, cHeader, cYN, lSpin
  1078.  
  1079. nRet     := 0
  1080. nCounter := 0
  1081. cHeader  := "File              Size    Description"
  1082. cYN      := "Y"
  1083. lSpin    := SWTRUE
  1084.  
  1085. select BBSFILES
  1086. set index to files
  1087. go top
  1088.  
  1089. nRet := SWStatus("Listing Files...")
  1090.  
  1091. do while lSpin
  1092.    nRet := SWAClear(nPort)
  1093.    
  1094.    nRet := SWAColor(nPort,SWAFMAGENTA,SWABBLACK)
  1095.    nRet := SWASay(nPort,1,1,cHeader)
  1096.    
  1097.    nRet := SWAColor(nPort,SWAFYELLOW,SWABBLACK)
  1098.    nRet := SWASay(nPort,2,1,replicate("-",nMaxCols))
  1099.    nCounter := 2
  1100.    
  1101.    do while SWTRUE
  1102.       if FSECURITY <= nUserLevel
  1103.          
  1104.          nCounter := nCounter + 1
  1105.          
  1106.          nRet := SWAColor(nPort,SWAFCYAN,SWABBLACK)
  1107.          nRet := SWASay(nPort,nCounter,1,FFILE)
  1108.          nRet := SWAColor(nPort,SWAFWHITE,SWABBLACK)
  1109.          nRet := SWASay(nPort,nCounter,15,str(FSIZE,10,0))
  1110.          nRet := SWAColor(nPort,SWAFGREEN,SWABBLACK)
  1111.          nRet := SWASay(nPort,nCounter,27,trim(FDESC))
  1112.  
  1113.          if nCounter == 22
  1114.             nRet := SWAColor(nPort,SWAFWHITE,SWABBLACK)
  1115.             nRet := SWASay(nPort,24,1,"More (Y/N) ")
  1116.             nRet := SWAGet(nPort,24,13,@cYN,2,60,SWTRUE)
  1117.             
  1118.             if upper(cYN) == "N"
  1119.                lSpin := SWFALSE
  1120.                exit
  1121.             else
  1122.                nRet := SWAClear(nPort)
  1123.                exit
  1124.                
  1125.             endif
  1126.             
  1127.          endif
  1128.          
  1129.       endif
  1130.       
  1131.       skip
  1132.       
  1133.       if eof()
  1134.          nRet := SWSkipLine(nPort,1)
  1135.          nRet := SWAColor(nPort,SWAFWHITE,SWABBLACK)
  1136.          nRet := SWPressKey(nPort)
  1137.          lSpin := SWFALSE
  1138.          exit
  1139.          
  1140.       endif
  1141.       
  1142.    enddo
  1143.    
  1144. enddo
  1145.  
  1146. RETURN(0)
  1147.  
  1148.  
  1149. ***********************************************************************
  1150. **
  1151. **       Function: SWLISTUSERS()
  1152. **
  1153. **      Called by: SWMAINMENU()
  1154. **
  1155. **          Calls: SWSTATUS()
  1156. **               : SWACLEAR()
  1157. **               : SWACOLOR()
  1158. **               : SWASAY()
  1159. **               : SWAGET()
  1160. **               : SWSKIPLINE()
  1161. **               : SWPRESSKEY()
  1162. **
  1163. **        Indexes: USER.NDX 
  1164. **
  1165. **  This function displays to the remote a user listing of users 
  1166. **  contained in the BBSUSERS.DBF.
  1167. **
  1168. **  nPort = COM port in use.          
  1169. **
  1170. ***********************************************************************
  1171.  
  1172. FUNCTION SWListUsers(nPort)
  1173. LOCAL nRet, nCounter, cHeader, cBuffer, cYN, lSpin
  1174.  
  1175. nRet     := 0
  1176. nCounter := 0
  1177. cHeader  := "User Names    (Last, First)"
  1178. cBuffer  := ""
  1179. cYN      := "Y"
  1180. lSpin    := SWTRUE
  1181.  
  1182. select BBSUSERS
  1183. set index to user
  1184. go top
  1185.  
  1186. nRet := SWStatus("Listing Users...")
  1187. do while lSpin
  1188.    nRet := SWAClear(nPort)
  1189.    
  1190.    nRet := SWAColor(nPort,SWAFMAGENTA,SWABBLACK)
  1191.    nRet := SWASay(nPort,1,1,cHeader)
  1192.    
  1193.    nRet := SWAColor(nPort,SWAFYELLOW,SWABBLACK)
  1194.    nRet := SWASay(nPort,2,1,replicate("-",40))
  1195.    nCounter := 2
  1196.    
  1197.    do while SWTRUE
  1198.       cBuffer := trim(FLAST)+", "+trim(FFIRST)
  1199.       nCounter := nCounter + 1
  1200.       
  1201.       nRet := SWAColor(nPort,SWAFCYAN,SWABBLACK)
  1202.       nRet := SWASay(nPort,nCounter,1,cBuffer)
  1203.       
  1204.       if nCounter == 22
  1205.          
  1206.          nRet := SWAColor(nPort,SWAFWHITE,SWABBLACK)
  1207.          nRet := SWASay(nPort,24,1,"More (Y/N) ")
  1208.          nRet := SWAGet(nPort,24,13,@cYN,2,60,SWTRUE)
  1209.          
  1210.          if upper(cYN) == "N"
  1211.             lSpin := SWFALSE
  1212.             exit
  1213.  
  1214.          else
  1215.             nRet := SWAClear(nPort)
  1216.             exit
  1217.             
  1218.          endif
  1219.  
  1220.       endif
  1221.       
  1222.       skip
  1223.       
  1224.       if eof()
  1225.          nRet  := SWSkipLine(nPort,1)
  1226.          nRet  := SWAColor(nPort,SWAFWHITE,SWABBLACK)
  1227.          nRet  := SWPressKey(nPort)
  1228.          lSpin := SWFALSE
  1229.          exit
  1230.          
  1231.       endif
  1232.       
  1233.    enddo
  1234.    
  1235. enddo
  1236.  
  1237. RETURN(0)
  1238.  
  1239.  
  1240.  
  1241. ***********************************************************************
  1242. **
  1243. **       Function: SWTRANSMENU()
  1244. **
  1245. **          Calls: SWSTATUS()
  1246. **               : SWACOLOR()
  1247. **               : SWABOX()
  1248. **               : SWASAY()
  1249. **               : SWAPROMPT()
  1250. **
  1251. **  This function send the file transfer menu to the remote user.  It
  1252. **  is used for both up-loads and down-loads.
  1253. **
  1254. **  nPort = COM port in use.
  1255. **
  1256. ***********************************************************************
  1257.  
  1258. FUNCTION SWTransMenu(nPort)
  1259. LOCAL aTrans := {;
  1260.    {10,30,"XMODEM     "," CRC/Checksum 128 block"},;
  1261.    {11,30,"YMODEM     "," CRC/Checksum 1024 block"},;
  1262.    {12,30,"ASCII      "," ASCII file transfer"},;
  1263.    {13,30,"1K-XMODEM  "," CRC/Checksum 1024 block"},;
  1264.    {14,30,"1K-XMODEM-G"," CRC/Checksum 1024 block (No Error Correction)"},;
  1265.    {15,30,"Cancel     "," Return to Main Menu"};
  1266.    }
  1267. LOCAL nRet, nArrayLength, nRow, nCol
  1268.  
  1269. nRow         := 8
  1270. nCol         := 28
  1271. nArrayLength := len(aTrans)
  1272. nRet         := SWStatus("File Transfer Menu...")
  1273.  
  1274. do while SWTRUE
  1275.    
  1276.    nRet := SWAColor(nPort,SWAFWHITE,SWABBLUE)
  1277.    nRet := SWABox(nPort, nRow, nCol, nRow+9, nCol+14, cFr)
  1278.    
  1279.    nRet := SWASay(nPort,nMaxRows-2,1,replicate(chr(205),nMaxCols))
  1280.    nRet := SWASay(nPort,nMaxRows,1,replicate(chr(205),nMaxCols))
  1281.    
  1282.    nRet := SWAColor(nPort,SWAFWHITE,SWABRED)
  1283.    nRet := SWASay(nPort,nRow,nCol+2," Protocols ")
  1284.    
  1285.    nRet := SWAPrompt(nPort,@aTrans,nMaxRows-1,1,SWAFWHITE,SWABBLUE,SWAFWHITE,SWABYELLOW,nArrayLength)
  1286.    
  1287.    if nRet <= 6
  1288.       exit
  1289.       
  1290.    endif
  1291.    
  1292. enddo
  1293.  
  1294. RETURN(nRet)
  1295.  
  1296.  
  1297.  
  1298. ***********************************************************************
  1299. **
  1300. **       Function: SWTRANSFER()
  1301. **
  1302. **      Called by: SWMAINMENU()
  1303. **
  1304. **          Calls: SWASAY()
  1305. **               : SWAGET()
  1306. **               : SWSTATUS()
  1307. **               : SWFLUSHRX()
  1308. **               : SWWTRXCNT()
  1309. **               : SWTXMODEM()
  1310. **               : SWTYMODEM()
  1311. **               : SWTXASCII()
  1312. **               : SWTXMOD1K()
  1313. **               : SWTXMOD1KG()
  1314. **               : SWRXMODEM()
  1315. **               : SWRYMODEM()
  1316. **               : SWRXASCII()
  1317. **               : SWRXMOD1K()
  1318. **               : SWRXMOD1KG()
  1319. **               : SWERRTOTXT()
  1320. **               : SWFILESIZE()
  1321. **
  1322. **        Indexes: FILES.NDX
  1323. **
  1324. **  This function calls the chosen transfer protocol.
  1325. **
  1326. **  nPort      = COM port in use.
  1327. **  nType      = Transfer protocol.
  1328. **  nDirection = Up-load / download.
  1329. **
  1330. ***********************************************************************
  1331.  
  1332. FUNCTION SWTransfer(nPort,nType,nDirection)
  1333. LOCAL nRet, cFileName, nTemp, cDescription
  1334.  
  1335. select BBSFILES
  1336. set index to files
  1337. go top
  1338.  
  1339. cFileName    := ""
  1340. cDescription := ""
  1341.  
  1342. nRet := SWASay(nPort,nMaxRows-1,1,space(nMaxCols))
  1343. nRet := SWASay(nPort,nMaxRows-1,1," Enter File Name: ")
  1344. nRet := SWAGet(nPort,nMaxRows-1,19,@cFileName,13,60,SWTRUE)
  1345.  
  1346. cFileName := trim(cFileName)
  1347.  
  1348. if cFileName == ""
  1349. else
  1350.    
  1351.    if nDirection == 0
  1352.       seek cFileName
  1353.       
  1354.       if !found()
  1355.          nType := 0
  1356.          
  1357.       else
  1358.          
  1359.          if FSECURITY > nUserLevel
  1360.             nType := 0
  1361.             
  1362.          endif
  1363.          
  1364.       endif
  1365.       
  1366.    else
  1367.       
  1368.       seek cFileName
  1369.       if file(cFileName) .or. found()
  1370.          nType := 0
  1371.          
  1372.       endif
  1373.       
  1374.    endif
  1375.    
  1376.    if nType != 0
  1377.       nTemp := SWASay(nPort,nMaxRows-1,1,space(nMaxCols))
  1378.       nTemp := SWASay(nPort,nMaxRows-1,1," Begin Your Transfer -> "+trim(cFileName))
  1379.       
  1380.    endif
  1381.    
  1382.    if nDirection == 0        && Sending
  1383.       
  1384.       nRet := SWStatus("Sending File -> "+trim(cFileName))
  1385.       nRet := SWFlushRX(nPort)
  1386.       nRet := SWWtRXCnt(nPort,2*SWSECOND,1)
  1387.       
  1388.       do case
  1389.       case nType == 0
  1390.          nRet := SWASay(nPort,nMaxRows-1,1,space(nMaxCols))
  1391.          nRet := SWASay(nPort,nMaxRows-1,1," File "+trim(cFileName)+" Does Not Exist, Please Try Again")
  1392.          nRet := inkey(2)
  1393.          nRet := SWCUNABLETOOPENFILE
  1394.          
  1395.       case nType == 1
  1396.          nRet := SWTXMODEM(nPort,trim(FFILE))
  1397.          
  1398.       case nType == 2
  1399.          nRet := SWTYMODEM(nPort,trim(FFILE))
  1400.          
  1401.       case nType == 3
  1402.          nRet := SWTXASCII(nPort,trim(FFILE),SWFALSE)
  1403.          
  1404.       case nType == 4
  1405.          nRet := SWTXMOD1K(nPort,trim(FFILE))
  1406.          
  1407.       case nType == 5
  1408.          nRet := SWTXMOD1KG(nPort,trim(FFILE))
  1409.          
  1410.       endcase
  1411.       
  1412.    else                && Receiving
  1413.       
  1414.       nRet := SWStatus("Receiving File -> "+trim(cFileName))
  1415.       nRet := inkey(2)
  1416.       
  1417.       do case
  1418.       case nType == 0
  1419.          nRet := SWASay(nPort,nMaxRows-1,1,space(nMaxCols))
  1420.          nRet := SWASay(nPort,1,1,"File "+trim(cFileName)+" Already Exist, Please Change File Name")
  1421.          nRet := inkey(2)
  1422.          nRet := SWCUNABLETOOPENFILE
  1423.          
  1424.       case nType == 1
  1425.          nRet := SWRXMODEM(nPort,cFileName)
  1426.          
  1427.       case nType == 2
  1428.          nRet := SWRYMODEM(nPort,cFileName)
  1429.          
  1430.       case nType == 3
  1431.          nRet := SWWtRXCnt(nPort,15*SWSECOND,10)
  1432.          nRet := SWRXASCII(nPort,cFileName,SWFALSE,5)
  1433.          if nRet == SWCTIMEDOUT
  1434.             nRet := SWCSUCCESSFUL
  1435.          endif
  1436.          
  1437.       case nType == 4
  1438.          nRet := SWRXMOD1K(nPort,cFileName)
  1439.          
  1440.       case nType == 5
  1441.          nRet := SWRXMOD1KG(nPort,cFileName)
  1442.          
  1443.       endcase
  1444.       
  1445.    endif
  1446.    
  1447. endif
  1448.  
  1449. nTemp := SWASay(nPort,nMaxRows-1,1,space(nMaxCols))
  1450. nTemp := SWASay(nPort,nMaxRows-1,1," File Transfer response, "+SWErrToTxt(nRet,0))
  1451. nTemp := inkey(2)
  1452.  
  1453. if nRet == SWCSUCCESSFUL .and. nDirection == 1
  1454.    nRet := SWStatus("Entering File Description...")
  1455.    
  1456.    nTemp := SWASay(nPort,nMaxRows-1,1,"Description:   ")
  1457.    nTemp := SWAGet(nPort,nMaxRows-1,16,@cDescription,60,60,SWTRUE)
  1458.    
  1459.    append blank
  1460.    replace FFILE     with cFileName
  1461.    replace FDESC     with cDescription
  1462.    replace FSIZE     with SWFileSize(cFileName)
  1463.    replace FSECURITY with 0
  1464.    
  1465. endif
  1466.  
  1467. RETURN(nRet)
  1468.  
  1469.  
  1470.  
  1471. ***********************************************************************
  1472. **
  1473. **       Function: SWSTATUS()
  1474. **
  1475. **      Called by: MAIN()
  1476. **               : SWINITCOM()
  1477. **               : SWRESETMODEM()
  1478. **               : SWSHUTDOWN()
  1479. **               : SWWAITFORCALL()
  1480. **               : SWLOGIN()
  1481. **               : SWOPENFILES()
  1482. **               : SWMAINMENU()
  1483. **               : SWLISTFILES()
  1484. **               : SWLISTUSERS()
  1485. **               : SWTRANSMENU()
  1486. **               : SWTRANSFER()
  1487. **
  1488. **  This function displays to the local screen the status of a user
  1489. **  online.
  1490. **
  1491. **  cString = String to display.
  1492. **
  1493. **
  1494. ***********************************************************************
  1495.  
  1496. FUNCTION SWStatus(cString)
  1497.  
  1498. @23,2 say space(77)
  1499. @23,2 say alltrim(cString)
  1500.  
  1501. RETURN(0)
  1502.  
  1503.  
  1504.  
  1505. ***********************************************************************
  1506. **
  1507. **       Function: SWBACKDROP()
  1508. **
  1509. **      Called by: MAIN()
  1510. **
  1511. **  This function creates the EZ-BBS local screen.
  1512. **
  1513. ***********************************************************************
  1514.  
  1515. FUNCTION SWBackDrop()
  1516. LOCAL nCol, getlist
  1517.  
  1518. clear
  1519. nCol := 2
  1520. set color to &cBlue
  1521. @0,nCol-2 to 5,50 double
  1522. set color to &cRed
  1523. @0,nCol say " User Information "
  1524. set color to &cBlue
  1525. @1,nCol say "Name:       "
  1526. @2,nCol say "Password:   "
  1527. @3,nCol say "Calls:      "
  1528. @4,nCol say "User Level: "
  1529.  
  1530. select BBSPARMS
  1531.  
  1532. nCol := 55
  1533. set color to &cBlue
  1534. @0,nCol-2 to 5,79 double
  1535. set color to &cRed
  1536. @0,nCol say " EZ BBS Online "
  1537. set color to &cBlue
  1538. @1,nCol say "CONNECT Type: "+iif(lDirect==SWTRUE,"Direct","Modem")
  1539. @2,nCol say "COM Port    : "+str(FPORT+1,1,0)
  1540. @3,nCol say "Baud Rate   : "+alltrim(str(FBAUD,6,0))
  1541. @4,nCol say "Total Calls : "+alltrim(str(FCALLS,9,0))
  1542.  
  1543. nCol := 2
  1544. set color to &cBlue
  1545. @22,nCol-2 to 24,79 double
  1546. set color to &cRed
  1547. @22,nCol say " Status Information "
  1548. @22,65 say " ESC To Quit "
  1549. set color to &cBlue
  1550.  
  1551.  
  1552. nCol := 12
  1553. set color to &cBlue
  1554. @7,nCol-2 to 16,69 double
  1555. set color to &cRed
  1556. @7,nCol say " Program Information "
  1557. set color to &cBlue
  1558.  
  1559. @8,nCol  say "EZ-BBS Version "+EZBBSVER
  1560. @9,nCol  say SWAsyncVer(1)
  1561. @10,nCol say os()
  1562. @11,nCol say version()
  1563.  
  1564. @13,nCol say "EZ-BBS in written in Clipper 5 and SilverClip (SPCS)"
  1565. @14,nCol say "To receive more information on SilverClip (SPCS)"
  1566. @15,nCol say "Call SilverWare Inc. at (214) 247-0131 "
  1567.  
  1568. RETURN(0)
  1569.  
  1570.  
  1571.  
  1572. ***********************************************************************
  1573. **
  1574. **       Function: SWFILESIZE()
  1575. **
  1576. **      Called by: SWTRANSFER()
  1577. **
  1578. **  This function returns the file size of a cFileSpec.
  1579. **
  1580. **  cFileSpec = drive:\path\filename.ext
  1581. **
  1582. **
  1583. ***********************************************************************
  1584.  
  1585. FUNCTION SWFileSize(cFileSpec)
  1586. LOCAL  nHandle, nLength, nRet
  1587.  
  1588. nHandle := fopen(cFileSpec,0)        && Open file read only
  1589. nLength := fseek(nHandle,0,2)        && Find eof
  1590. nRet    := fclose(nHandle)        && Close file
  1591.  
  1592. RETURN(nLength)
  1593.  
  1594.  
  1595.  
  1596. ***********************************************************************
  1597. **
  1598. **       Function: SWSKIPLINE()
  1599. **
  1600. **      Called by: SWLISTFILES()
  1601. **               : SWLISTUSERS()
  1602. **
  1603. **          Calls: SWTXCHAR()
  1604. **
  1605. **  This function will move the remote cursor down nLines.
  1606. **
  1607. **  nPort  = COM port in use.
  1608. **  nLines = Number of lines to skip.
  1609. **
  1610. ***********************************************************************
  1611.  
  1612. FUNCTION SWSkipLine(nPort,nLines)
  1613. LOCAL nCounter, nRet
  1614.  
  1615. for nCounter := 1 to nLines
  1616.    nRet := SWTXChar(nPort,13)
  1617.    nRet := SWTXChar(nPort,10)
  1618.    
  1619. next
  1620.  
  1621. RETURN(nLines)
  1622.  
  1623.  
  1624.  
  1625. ***************************
  1626. ***************************
  1627. ***************************
  1628. ***** ANSI Functions ******
  1629. ***************************
  1630. ***************************
  1631. ***************************
  1632.  
  1633.  
  1634. ***********************************************************************
  1635. **
  1636. **       Function: SWASAY()
  1637. **
  1638. **      Called by: MAIN()
  1639. **               : SWLOGIN()
  1640. **               : SWMAINMENU()
  1641. **               : SWLISTFILES()
  1642. **               : SWLISTUSERS()
  1643. **               : SWTRANSMENU()
  1644. **               : SWTRANSFER()
  1645. **               : SWAGET()
  1646. **               : SWABOX()
  1647. **               : SWAPROMPT()
  1648. **
  1649. **          Calls: SWAPOSCUR()
  1650. **               : SWTXBUFFER()
  1651. **
  1652. ***********************************************************************
  1653.  
  1654. FUNCTION SWASay(nPort,nRow,nCol,cString)
  1655. LOCAL nRet
  1656.  
  1657. nRet := 0
  1658. nRet := SWAPosCur(nPort,nRow,nCol)
  1659. nRet := SWTXBuffer(nPort,cString,len(cString))
  1660.  
  1661. RETURN(0)
  1662.  
  1663.  
  1664.  
  1665. ***********************************************************************
  1666. **
  1667. **       Function: SWAPOSCUR()
  1668. **
  1669. **      Called by: MAIN()
  1670. **               : SWLOGIN()
  1671. **               : SWASAY()
  1672. **               : SWAGET()
  1673. **               : SWAPROMPT()
  1674. **
  1675. **          Calls: SWTXBUFFER()
  1676. **
  1677. **  This is an ANSI @say function.
  1678. **
  1679. **  nPort = COM port in use.
  1680. **  nRow  = Row position. 
  1681. **  nCol  = Column position.
  1682. **
  1683. ***********************************************************************
  1684.  
  1685. FUNCTION SWAPosCur(nPort,nRow,nCol)
  1686. LOCAL cANSIRowCol, nRet
  1687.  
  1688. cANSIRowCol := chr(27)+"["+alltrim(str(nRow,2,0))+";"+alltrim(str(nCol,2,0))+"H"
  1689. nRet        := SWTXBuffer(nPort,cANSIRowCol,len(cANSIRowCol))
  1690.  
  1691. RETURN(0)
  1692.  
  1693.  
  1694.  
  1695. ***********************************************************************
  1696. **
  1697. **       Function: SWACOLOR()
  1698. **
  1699. **      Called by: MAIN()
  1700. **               : SWMAINMENU()
  1701. **               : SWLISTFILES()
  1702. **               : SWLISTUSERS()
  1703. **               : SWTRANSMENU()
  1704. **               : SWACLEAR()
  1705. **               : SWAPROMPT()
  1706. **
  1707. **          Calls: SWTXBUFFER()
  1708. **
  1709. **  This is an ANSI (set color to) function.
  1710. **
  1711. **  nPort     = COM port in use.
  1712. **  nForeGrnd = Foreground color.
  1713. **  nBackGrnd = Background color.
  1714. **
  1715. ***********************************************************************
  1716.  
  1717. FUNCTION SWAColor(nPort,nForeGrnd,nBackGrnd)
  1718. LOCAL cForeGrnd, cBackGrnd, nRet, cColorBuffer
  1719.  
  1720. cForeGrnd    := alltrim(str(nForeGrnd,2,0))
  1721. cBackGrnd    := alltrim(str(nBackGrnd,2,0))
  1722. cColorBuffer := chr(27)+"["+cForeGrnd+"m"+chr(27)+"["+cBackGrnd+"m"
  1723. nRet         := SWTXBuffer(nPort,cColorBuffer,len(cColorBuffer))
  1724.  
  1725. RETURN(0)
  1726.  
  1727.  
  1728.  
  1729. ***********************************************************************
  1730. **
  1731. **       Function: SWACLEAR()
  1732. **
  1733. **      Called by: MAIN()
  1734. **               : SWLOGIN()
  1735. **               : SWMAINMENU()
  1736. **               : SWLISTFILES()
  1737. **               : SWLISTUSERS()
  1738. **
  1739. **          Calls: SWTXBUFFER()
  1740. **               : SWACOLOR()
  1741. **
  1742. **  This is an ANSI (clear screen) function.
  1743. **
  1744. **  nPort = COM port in use.
  1745. **
  1746. ***********************************************************************
  1747.  
  1748. FUNCTION SWAClear(nPort)
  1749. LOCAL cBuffer, nRet
  1750.  
  1751. cBuffer := chr(27)+"[40m"+chr(27)+"[2J"+chr(27)+"[40m"
  1752. nRet    := SWTXBuffer(nPort,cBuffer,len(cBuffer))
  1753. nRet    := SWAColor(nPort,SWABOLD,SWABBLACK)
  1754.  
  1755. RETURN(0)
  1756.  
  1757.  
  1758.  
  1759. ***********************************************************************
  1760. **
  1761. **       Function: SWAGET()
  1762. **
  1763. **      Called by: SWLOGIN()
  1764. **               : SWLISTFILES()
  1765. **               : SWLISTUSERS()
  1766. **               : SWTRANSFER()
  1767. **
  1768. **          Calls: SWAPOSCUR()
  1769. **               : SWASAY()
  1770. **               : SWFLUSHRX()
  1771. **               : SWRXSTRING()
  1772. **
  1773. **  This is an ANSI (get/read) function.
  1774. **
  1775. **  nPort      = COM port in use
  1776. **  nRow       = Row position. 
  1777. **  nCol       = Column position.
  1778. **  cGetString = String variable (pass by ref. @) for get.
  1779. **  nMaxLength = Data entry length.
  1780. **  nMaxTime   = Time out for entry.
  1781. **  lRegular   = SWTRUE -> echo key strokes, SWFALSE -> echo dots
  1782. **
  1783. ***********************************************************************
  1784.  
  1785. FUNCTION SWAGet(nPort,nRow,nCol,cGetString,nMaxLength,nMaxTime,lRegular)
  1786. LOCAL nRet
  1787.  
  1788. nRet := SWAPosCur(nPort,nRow,nCol)
  1789. nRet := SWASay(nPort,nRow,nCol,space(nMaxLength))
  1790. nRet := SWAPosCur(nPort,nRow,nCol)
  1791. nRet := SWFlushRX(nPort)
  1792. nRet := SWRXString(nPort,@cGetString,nMaxLength,13,nMaxTime,.t.,lRegular,46,283)
  1793.  
  1794. if nRet == SWCTERMINATORREACHED
  1795.    cGetString := substr(cGetString,1,len(cGetString)-1)
  1796.    
  1797. endif
  1798.  
  1799. RETURN(nRet)
  1800.  
  1801.  
  1802.  
  1803. ***********************************************************************
  1804. **
  1805. **       Function: SWACURUP()
  1806. **
  1807. **          Calls: SWTXBUFFER()
  1808. **
  1809. **  This function move the remote cursor up nLinesUp.
  1810. **
  1811. **  nPort    = COM port in use.
  1812. **  nLinesUp = Number lines to move.
  1813. **
  1814. ***********************************************************************
  1815.  
  1816. FUNCTION SWACurUp(nPort,nLinesUp)
  1817. LOCAL cBuffer, nRet
  1818.  
  1819. cBuffer := chr(27)+"["+alltrim(str(nLinesUp,2,0))+"A"
  1820. nRet    := SWTXBuffer(nPort,cBuffer,len(cBuffer))
  1821.  
  1822. RETURN(nRet)
  1823.  
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829. ***********************************************************************
  1830. **
  1831. **       Function: SWACURDWN()
  1832. **
  1833. **          Calls: SWTXBUFFER()
  1834. **
  1835. **  This function move the remote cursor down nLinesDwn.
  1836. **
  1837. **  nPort     = COM port in use.
  1838. **  nLinesDwn = Number lines to move.
  1839. **
  1840. ***********************************************************************
  1841.  
  1842. FUNCTION SWACurDwn(nPort,nLinesDwn)
  1843. LOCAL cBuffer, nRet
  1844.  
  1845. cBuffer := chr(27)+"["+alltrim(str(nLinesDwn,2,0))+"B"
  1846. nRet    := SWTXBuffer(nPort,cBuffer,len(cBuffer))
  1847.  
  1848. RETURN(nRet)
  1849.  
  1850.  
  1851.  
  1852. ***********************************************************************
  1853. **
  1854. **       Function: SWACURRIGHT()
  1855. **
  1856. **          Calls: SWTXBUFFER()
  1857. **
  1858. **  This function move the remote cursor to the right nColsRight.
  1859. **
  1860. **  nPort      = COM port in use.
  1861. **  nColsRight = Number of columns to move.
  1862. **
  1863. ***********************************************************************
  1864.  
  1865. FUNCTION SWACurRight(nPort,nColsRight)
  1866. LOCAL cBuffer, nRet
  1867.  
  1868. cBuffer := chr(27)+"["+alltrim(str(nColsRight,2,0))+"C"
  1869. nRet    := SWTXBuffer(nPort,cBuffer,len(cBuffer))
  1870.  
  1871. RETURN(nRet)
  1872.  
  1873.  
  1874.  
  1875. ***********************************************************************
  1876. **
  1877. **       Function: SWACURLEFT()
  1878. **
  1879. **          Calls: SWTXBUFFER()
  1880. **
  1881. **  This function move the remote cursor to the left nColsLeft.
  1882. **
  1883. **  nPort     = COM port in use.
  1884. **  nColsLeft = Number of columns to move.
  1885. **
  1886. ***********************************************************************
  1887.  
  1888. FUNCTION SWACurLeft(nPort,nColsLeft)
  1889. LOCAL cBuffer, nRet
  1890.  
  1891. cBuffer := chr(27)+"["+alltrim(str(nColsLeft,2,0))+"D"
  1892. nRet    := SWTXBuffer(nPort,cBuffer,len(cBuffer))
  1893.  
  1894. RETURN(nRet)
  1895.  
  1896.  
  1897.  
  1898. ***********************************************************************
  1899. **
  1900. **       Function: SWAERSEOL()
  1901. **
  1902. **          Calls: SWTXBUFFER()
  1903. **
  1904. **  This function will erase from the current cursor position to the
  1905. **  end of the current line. (row)
  1906. **
  1907. **  nPort = COM port in use.
  1908. **
  1909. **
  1910. ***********************************************************************
  1911.  
  1912. FUNCTION SWAErsEOL(nPort)
  1913. LOCAL cBuffer, nRet
  1914.  
  1915. cBuffer := chr(27)+"[0K"
  1916. nRet    := SWTXBuffer(nPort,cBuffer,len(cBuffer))
  1917.  
  1918. RETURN(nRet)
  1919.  
  1920.  
  1921.  
  1922. ***********************************************************************
  1923. **
  1924. **       Function: SWAERSBOL()
  1925. **
  1926. **          Calls: SWTXBUFFER()
  1927. **
  1928. **  This function will erase from the current cursor position to the
  1929. **  beginning of the current line. (row)
  1930. **
  1931. **  nPort = COM port in use.
  1932. **
  1933. ***********************************************************************
  1934.  
  1935. FUNCTION SWAErsBOL(nPort)
  1936. LOCAL cBuffer, nRet
  1937.  
  1938. cBuffer := chr(27)+"[1K"
  1939. nRet    := SWTXBuffer(nPort,cBuffer,len(cBuffer))
  1940.  
  1941. RETURN(nRet)
  1942.  
  1943.  
  1944.  
  1945. ***********************************************************************
  1946. **
  1947. **       Function: SWAERSLINE()
  1948. **
  1949. **      Called by: SWLOGIN()
  1950. **               : SWAPROMPT()
  1951. **
  1952. **          Calls: SWTXBUFFER()
  1953. **
  1954. **  This function will erase the entire current line.
  1955. **
  1956. **  nPort = COM port in use.
  1957. **
  1958. ***********************************************************************
  1959.  
  1960. FUNCTION SWAErsLine(nPort)
  1961. LOCAL cBuffer, nRet
  1962.  
  1963. cBuffer := chr(27)+"[2K"
  1964. nRet    := SWTXBuffer(nPort,cBuffer,len(cBuffer))
  1965.  
  1966. RETURN(nRet)
  1967.  
  1968.  
  1969.  
  1970. ***********************************************************************
  1971. **
  1972. **       Function: SWAERSEOS()
  1973. **
  1974. **          Calls: SWTXBUFFER()
  1975. **
  1976. **  This function will erase from the current cursor position to the
  1977. **  end of the screen.
  1978. **
  1979. **  nPort = COM port in use.
  1980. **
  1981. ***********************************************************************
  1982.  
  1983. FUNCTION SWAErsEOS(nPort)
  1984. LOCAL cBuffer, nRet
  1985.  
  1986. cBuffer := chr(27)+"[0J"
  1987. nRet    := SWTXBuffer(nPort,cBuffer,len(cBuffer))
  1988.  
  1989. RETURN(nRet)
  1990.  
  1991.  
  1992.  
  1993. ***********************************************************************
  1994. **
  1995. **       Function: SWAERSBOS()
  1996. **
  1997. **          Calls: SWTXBUFFER()
  1998. **
  1999. **  This function will erase from the current cursor position to the
  2000. **  beginning of the screen.
  2001. **
  2002. **  nPort = COM port in use.
  2003. **
  2004. ***********************************************************************
  2005.  
  2006. FUNCTION SWAErsBOS(nPort)
  2007. LOCAL cBuffer, nRet
  2008.  
  2009. cBuffer := chr(27)+"[1J"
  2010. nRet    := SWTXBuffer(nPort,cBuffer,len(cBuffer))
  2011.  
  2012. RETURN(nRet)
  2013.  
  2014.  
  2015.  
  2016. ***********************************************************************
  2017. **
  2018. **       Function: SWABOX()
  2019. **
  2020. **      Called by: MAIN()
  2021. **               : SWMAINMENU()
  2022. **               : SWTRANSMENU()
  2023. **
  2024. **          Calls: SWASAY()
  2025. **
  2026. **  This function draws a box on the remote screen.
  2027. **
  2028. **  nPort  = COM port in use.
  2029. **  nRow1  = Upper left row.
  2030. **  nCol1  = Upper left column.
  2031. **  nRow2  = Lower right row.
  2032. **  nCol2  = Lower right column.
  2033. **  cFrame = Box frame.
  2034. **
  2035. ***********************************************************************
  2036.  
  2037. FUNCTION SWABox(nPort, nRow1, nCol1, nRow2, nCol2, cFrame)
  2038. LOCAL nLines, nWidth, nLoop, cUL, cUR, cBR, cBL, cLeft, cRight, cTop, cBottom, cClear, lClear, nRet, nSpin
  2039.  
  2040. cUL     := substr(cFrame,1,1)        && Upper Left Of Box
  2041. cUR     := substr(cFrame,3,1)        && Upper Right Of Box
  2042. cBR     := substr(cFrame,5,1)        && Bottom Right Of Box
  2043. cBL     := substr(cFrame,7,1)        && Bottom Left Of Box
  2044. cLeft   := substr(cFrame,4,1)        && Left Of Box
  2045. cRight  := substr(cFrame,8,1)        && Right Of Box
  2046. cTop    := substr(cFrame,2,1)        && Top Of Box
  2047. cBottom := substr(cFrame,6,1)        && Bottom Of Box
  2048. cClear  := space(1)            && Clear chr()
  2049. lClear  := .f.                && Check if cClear passed
  2050.  
  2051. if len(cFrame) == 9
  2052.    cClear := substr(cFrame,9,1)
  2053.    lClear := .t.
  2054. endif
  2055.  
  2056. nLines  := nRow2-nRow1
  2057. nWidth  := (nCol2-nCol1)-1
  2058.  
  2059. nRet := SWASay(nPort,nRow1,nCol1,cUL+replicate(cTop,nWidth)+cUR)
  2060.  
  2061. for nLoop := 1 to nLines -1
  2062.    nRet := SWASay(nPort,nRow1+nLoop,nCol1,cLeft)
  2063.    
  2064.    if lClear
  2065.       nRet := SWASay(nPort,nRow1+nLoop,nCol1+1,replicate(cClear,nWidth))
  2066.    endif
  2067.    
  2068.    nRet := SWASay(nPort,nRow1+nLoop,nCol2,cRight)
  2069.    
  2070. next
  2071. nRet := SWASay(nPort,nRow2,nCol1,cBL+replicate(cBottom,nWidth)+cBR)
  2072.  
  2073. RETURN(0)
  2074.  
  2075.  
  2076.  
  2077. ***********************************************************************
  2078. **
  2079. **       Function: SWAPROMPT()
  2080. **
  2081. **      Called by: SWMAINMENU()
  2082. **               : SWTRANSMENU()
  2083. **
  2084. **          Calls: SWFLUSHRX()
  2085. **               : SWACOLOR()
  2086. **               : SWASAY()
  2087. **               : SWAPOSCUR()
  2088. **               : SWGETCD()
  2089. **               : SWRXEMPTY()
  2090. **               : SWPEEKCHR()
  2091. **               : SWWTRXCNT()
  2092. **               : SWRXBUFFER()
  2093. **               : SWRXCHAR()
  2094. **               : SWAERSLINE()
  2095. **
  2096. **  This is an ANSI light bar menu prompt function.
  2097. **
  2098. **  nPort        = COM port in use.
  2099. **  aPromptArray = 2 dim array/table containing prompt parameters.
  2100. **                 ie: {  {nRow,nCol,cPrompt,cMessage};
  2101. **                        {nRow,nCol,cPrompt,cMessage} }
  2102. **  nMessageRow  = Row for cMessage.
  2103. **  nMesageCol   = Column for cMessage.
  2104. **  nFColor      = cPrompt foreground color.
  2105. **  nBColor      = cPrompt background color.
  2106. **  nFHighLight  = cPrompt high-lighted foreground color.
  2107. **  nBHighLight  = cPrompt high-lighted background color.
  2108. **  nElements    = Number of prompts.
  2109. **
  2110. ***********************************************************************
  2111.  
  2112. FUNCTION SWAPrompt(nPort,aPromptArray,nMessageRow,nMesageCol,nFColor,nBColor,nFHighLight,nBHighLight,nElements)
  2113. LOCAL nLoop, nRet, nKey, nPrev, nExitVal, nSpin, cPrompt, nMaxMessage
  2114.  
  2115. nRet := SWFlushRX(nPort)
  2116. nMaxMessage := 0
  2117.  
  2118. for nLoop := 1 to nElements
  2119.    nRet := SWAColor(nPort,nFColor,nBColor)
  2120.    nRet := SWASay(nPort,aPromptArray[nLoop,1],aPromptArray[nLoop,2],aPromptArray[nLoop,3])
  2121.    nMaxMessage := iif(len(aPromptArray[nLoop,4])>nMaxMessage,len(aPromptArray[nLoop,4]),nMaxMessage)
  2122.  
  2123. next
  2124.  
  2125. nLoop    := 1
  2126. nExitVal := 0
  2127.  
  2128. do while .t.
  2129.    
  2130.    nRet := SWAColor(nPort,nFHighLight,nBHighLight)
  2131.    nRet := SWASay(nPort,aPromptArray[nLoop,1],aPromptArray[nLoop,2],aPromptArray[nLoop,3])
  2132.    nRet := SWAColor(nPort,nFColor,nBColor)
  2133.    nRet := SWAPosCur(nPort,nMessageRow,nMesageCol)
  2134.    nRet := SWASay(nPort,nMessageRow,nMesageCol,replicate(" ",nMaxMessage))
  2135.    nRet := SWASay(nPort,nMessageRow,nMesageCol,aPromptArray[nLoop,4])
  2136.    nRet := SWAPosCur(nPort,aPromptArray[nLoop,1],aPromptArray[nLoop,2])
  2137.  
  2138.    cPrompt := ""
  2139.    
  2140.    do while .t.                && Parse key strokes
  2141.       
  2142.       if !SWGetCD(nPort)
  2143.          nKey := SWCNOCARRIER
  2144.          exit
  2145.          
  2146.       endif
  2147.       
  2148.       nRet := inkey()
  2149.       
  2150.       if lastkey() == 27
  2151.          nKey := SWCLOCALABORT
  2152.          exit
  2153.          
  2154.       endif
  2155.       
  2156.       
  2157.       if !SWRXEmpty(nPort)
  2158.          
  2159.          if SWPeekChr(nPort,0) != 13
  2160.             
  2161.             nRet := SWWtRXCnt(nPort,3*SWSECOND,3)
  2162.             
  2163.             do case
  2164.             case nRet == SWCSUCCESSFUL
  2165.                nRet := SWRXBuffer(nPort,@cPrompt,3,-1,@nKey)
  2166.                nKey := asc(substr(cPrompt,3,1))
  2167.                exit
  2168.                
  2169.             case nRet == SWCTIMEDOUT
  2170.                nKey := SWPeekChr(nPort,0)
  2171.                if nKey == 13
  2172.                   exit
  2173.                endif
  2174.                
  2175.             otherwise
  2176.                loop
  2177.                
  2178.             endcase
  2179.             
  2180.          else
  2181.             nKey := SWRXChar(nPort)
  2182.             exit
  2183.             
  2184.          endif
  2185.          
  2186.       endif
  2187.       
  2188.    enddo
  2189.    
  2190.    nRet := SWFlushRX(nPort)
  2191.    
  2192.    do case
  2193.    case nKey == 65 .or. nKey == 68    && Uparrow, Ctrl-E
  2194.       nPrev := nLoop
  2195.       nLoop := nLoop - 1
  2196.       nLoop := iif(nLoop=0,nElements,nLoop)
  2197.       
  2198.    case nKey == 66 .or. nKey == 67     && Dnarrow, Ctrl-X
  2199.       nPrev := nLoop
  2200.       nLoop := nLoop + 1
  2201.       nLoop := iif(nLoop>nElements,1,nLoop)
  2202.       
  2203.    case nKey == 72       && Home, Ctrl-A
  2204.       nPrev := nLoop
  2205.       nLoop := 1
  2206.       
  2207.    case nKey == 75       && End, Ctrl-F
  2208.       nPrev := nLoop
  2209.       nLoop := nElements
  2210.       
  2211.    case nKey == 13      && Enter, Ctrl-M
  2212.       nExitVal := nLoop
  2213.       exit
  2214.       
  2215.    case nKey == SWCNOCARRIER
  2216.       nExitVal := SWCNOCARRIER
  2217.       exit
  2218.       
  2219.    case nKey == SWCLOCALABORT
  2220.       nExitVal := SWCLOCALABORT
  2221.       exit
  2222.       
  2223.    otherwise
  2224.       
  2225.       nExitVal := 0
  2226.       for nSpin := 1 to nElements
  2227.          if upper(substr(aPromptArray[nSpin,3],1,1)) == upper(chr(nKey))
  2228.             nExitVal := nSpin
  2229.             nSpin := nElements + 1
  2230.          endif
  2231.       next
  2232.       
  2233.       if nExitVal == 0
  2234.          loop
  2235.       else
  2236.          nPrev   := nLoop
  2237.          nLoop   := nExitVal
  2238.          nRet := SWAColor(nPort,nFHighLight,nBHighLight)
  2239.          nRet := SWASay(nPort,aPromptArray[nLoop,1],aPromptArray[nLoop,2],aPromptArray[nLoop,3])
  2240.          
  2241.          nRet := SWAColor(nPort,nFColor,nBColor)
  2242.          
  2243.          nRet := SWAPosCur(nPort,nMessageRow,nMesageCol)
  2244.          nRet := SWAErsLine(nPort)
  2245.          nRet := SWASay(nPort,nMessageRow,nMesageCol,aPromptArray[nLoop,4])
  2246.          
  2247.          nRet := SWASay(nPort,aPromptArray[nPrev,1],aPromptArray[nPrev,2],aPromptArray[nPrev,3])
  2248.          exit
  2249.       endif
  2250.       
  2251.    endcase
  2252.    
  2253.    nRet := SWAColor(nPort,nFColor,nBColor)
  2254.    nRet := SWASay(nPort,aPromptArray[nPrev,1],aPromptArray[nPrev,2],aPromptArray[nPrev,3])
  2255.    
  2256. enddo
  2257.  
  2258. RETURN(nExitVal)
  2259.  
  2260. ** EOF: EZBBSC.PRG
  2261.