home *** CD-ROM | disk | FTP | other *** search
- ; *** MCHOST.SCP *** Example for using MyComm as a host
- ; Copyright 1994 Ken Dorshimer - All Rights Reserved
- ;
- ; NOTE: This is a _very_ simple host example using the
- ; MyComm "script" language. MyComm is not intended
- ; to be used as a full blown BBS. However by using
- ; the MyComm script language functions and a little
- ; imagination it is possible to create a script that
- ; behaves like a simple host for transfering files.
- ;
- ; This script is provided only as an example to
- ; add a "host like" function to MyComm.
- ;
- ; This example allows for one user-name and one
- ; password. There is no provision for entering messages,
- ; reading messages, or message areas.
- ;
-
- IgnoreCD("Y") ; Ignore Carrier Detect status
- LoclEcho("Y") ; Turn on Host Mode
- :start
- Hangup() ; Make sure we're off-line
- Xmit("ATS0=1") ; Tell modem to answer on one ring
-
- :begin ; Waiting for a call
- Pause(1)
- If("CARDET", "gotcall") ; When call comes in start session
- Goto("begin")
-
- :gotcall
- Xmit("^L) ; Send "Form Feed" to clear screen
-
- ; Send an opening screen. Note that the
- ; ASCII upload function could also be
- ; used to send a text file to the user
- ; that contains your opening screen.
-
- Xmit("Welcome To a Very Little BBS Indeed!")
- Xmit("^M^J") ; Send a blank line
- Xmit("1.4K bps - 8-N-1")
-
- If("NOCARDET", "start") ; If caller hangs up reset script
- GoSub("getname") ; GoSub to the user name routine
- If("NOCARDET", "start") ; If caller hangs up reset script
- GoSub("getpass") ; GoSub to the user password routine
- If("NOCARDET", "start") ; If caller hangs up reset script
-
- ; OK so far let's do something
-
- GoSub("mainmenu") ; Go to the main menu section
- Goto("start") ; Call finished - reset script
-
-
- ; --------------------------
- :getname ; Get user name here
- Xmit("^M^J^M^JUser Name? >")
- PortGet(S0, 8, 60) ; Get Name
- ; Valid User Name?
- ; NOTE: more user names could be added here
- CompStr(S0, "somename", "name_ok")
- ; If name is valid Goto label name_ok
- ; otherwise hangup
- Xmit("^M^JInvalid User Name!^M^JGoodbye!")
- Pause(2)
- Hangup() ; name invalid. sorry bub
- :name_ok
- Return() ; Go Back
-
- ; --------------------------
- :getpass ; Get user Password here
- Xmit("^M^JPassword? >")
- LoclEcho("N") ; Turn off Host Mode so that password
- ; won't get echoed back to user
- PortGet(S0, 8, 60) ; Get Password
- LoclEcho("Y") ; Turn Host Mode back on
-
- ; Valid Password?
- ; NOTE: more passwords could be added here
- CompStr(S0, "somepass", "Pass_ok")
- ; If Password is valid Goto label name_ok
- ; otherwise hangup
- Xmit("^M^JInvalid Password!^M^JGoodbye!")
- Pause(2)
- Hangup() ; Password invalid. sorry bub
- :pass_ok
- Return() ; Go Back
-
- ; --------------------------
- :mainmenu ; Main menu section
-
- ; Nothing fancy here. This could be greatly expanded upon.
- ; For example a menu selection could be for F)ile List
- ; that would then upload an ASCII file containing
- ; a list of available files.
-
- Xmit("^L") ; ^L clears screen
-
- ; Display the Main Menu
-
- Xmit("^M^J^M^J^M^J Main Menu^M^J^M^J")
- Xmit("U)pload File^M^J")
- Xmit("D)ownload File^M^J")
- Xmit("G)oodbye^M^J")
- Xmit("^M^J^M^JEnter Choice >")
-
- If("NOCARDET", "mm_exit") ; If caller hangs up reset script
- PortGet(S0, 1, 60) ; Get user's choice
- ; Compare the user choice and Goto
- ; the appropriate routine
- CompStr(S0, "U", "m_uload")
- CompStr(S0, "D", "m_dload")
- CompStr(S0, "G", "m_gbye")
- ; If choice is invalid inform the user
- ; and redisplay the menu
- Xmit("^M^J^M^J^GInvalid Response!)
- Pause(2) ; wait 2 seconds so user can see message
- Goto("mainmenu") ; try again
-
- :m_uload ; GoSub to the Upload Menu routine
- GoSub("ul_menu")
- Goto("mainmenu") ; The GoSub will Return here
- ; so start main menu again
-
- :m_dload
- GoSub("dl_menu") ; GoSub to the Download Menu routine
- Goto("mainmenu") ; The GoSub will Return here
- ; so start main menu again
-
- :m_gbye ; User decided to leave
- Xmit("^M^J^M^JThanks for calling!^M^J^M^J")
- Pause(2)
- ; Fall through to Return()
-
- :mm_exit ; Main menu exits here
- Return() ; Return back to where main menu
- ; was first called
-
- ; --------------------------
- :ul_menu ; Upload Menu section
- ; Display the menu
-
- Xmit("^L") ; ^L clears screen
- Xmit("^M^J^M^J Upload Menu^M^J^M^J")
- Xmit("A)scii^M^J")
- Xmit("S)EAlink^M^J")
- Xmit("X)modem^M^J")
- Xmit("Xmodem-1(K)^M^J")
- Xmit("Y)modem^M^J")
- Xmit("Ymodem-(G)^M^J")
- Xmit("Ke(R)mit^M^J")
- Xmit("Z)modem^M^J")
- Xmit("Q)uit^M^J)
- Xmit("^M^J^M^JEnter Choice >")
- PortGet(S0, 1, 60) ; Get user's protocol choice
- CompStr(S0, "Q", "ulquit")
- Xmit("^M^J^M^J")
- Xmit("Filename? >")
- PortGet(S1, 12, 60) ; Get filename from user
- Xmit("^M^J^M^J")
-
- CompStr(S1, "", "badfname") ; make sure filename isn't blank
- Goto("fnameok")
- :badfname
- Xmit("^M^J^M^J^GInvalid Filename!")
- Pause(2)
- Goto("ulquit")
- ; Decide which protocol to use
- ; Compare to what user entered
- ; and Goto the appropriate routine
- :fnameok
- CompStr(S0, "A", "uascii")
- CompStr(S0, "S", "usea")
- CompStr(S0, "X", "uxmodem")
- CompStr(S0, "K", "ukmodem")
- CompStr(S0, "Y", "uymodem")
- CompStr(S0, "G", "ugmodem")
- CompStr(S0, "R", "ukermit")
- CompStr(S0, "Z", "uzmodem")
- Xmit("^M^J^M^J^GInvalid protocol!")
- Pause(2)
- :ulquit
- Goto("ul_exit") ; default for Quit or invalid selection
-
- ; The file transfer routines are
- ; called from here
- :uascii
- RecvFile(A, S1)
- Goto("ul_exit")
-
- :usea
- RecvFile(S, S1)
- Goto("ul_exit")
-
- :uxmodem
- RecvFile(X, S1)
- Goto("ul_exit")
-
- :ukmodem
- RecvFile(K, S1)
- Goto("ul_exit")
-
- :uymodem
- RecvFile(Y, S1)
- Goto("ul_exit")
-
- :ugmodem
- RecvFile(G, S1)
- Goto("ul_exit")
-
- :ukermit
- RecvFile(R, S1)
- Goto("ul_exit")
-
- :uzmodem
- RecvFile(Z, S1)
- Goto("ul_exit")
-
- :ul_exit ; exit Upload Menu from here
- Return() ; Return to Main Menu
-
- ; --------------------------
- :dl_menu ; Download Menu section
-
- Xmit("^L") ; ^L clears screen
- Xmit("^M^J^M^J Download Menu^M^J^M^J")
- Xmit("A)scii^M^J")
- Xmit("S)EAlink^M^J")
- Xmit("X)modem^M^J")
- Xmit("Xmodem-1(K)^M^J")
- Xmit("Y)modem^M^J")
- Xmit("Ymodem-(G)^M^J")
- Xmit("Ke(R)mit^M^J")
- Xmit("Z)modem^M^J")
- Xmit("Q)uit^M^J)
- Xmit("^M^J^M^JEnter Choice >")
- PortGet(S0, 1, 60) ; Get user' protocol choice
- CompStr(S0, "Q", "dlquit")
- Xmit("^M^J")
- Xmit("^M^JFilename? >")
- PortGet(S1, 12, 60) ; Get download filename
- Xmit("^M^J")
- ; Decide which protocol to use
- ; Compare to what user entered
- ; and Goto the appropriate routine
- CompStr(S0, "A", "dascii")
- CompStr(S0, "S", "dsea")
- CompStr(S0, "X", "dxmodem")
- CompStr(S0, "K", "dkmodem")
- CompStr(S0, "Y", "dymodem")
- CompStr(S0, "G", "dgmodem")
- CompStr(S0, "R", "dkermit")
- CompStr(S0, "Z", "dzmodem")
- Xmit("^M^J^M^J^GInvalid protocol!")
- Pause(2)
- :dlquit
- Goto("dl_exit") ; default for Quit or invalid selection
-
- ; The file transfer routines are
- ; called from here
- :dascii
- SendFile(A, S1)
- Goto("dl_exit")
-
- :dsea
- SendFile(S, S1)
- Goto("dl_exit")
-
- :dxmodem
- SendFile(X, S1)
- Goto("dl_exit")
-
- :dkmodem
- SendFile(K, S1)
- Goto("dl_exit")
-
- :dymodem
- SendFile(Y, S1)
- Goto("dl_exit")
-
- :dgmodem
- SendFile(G, S1)
- Goto("dl_exit")
-
- :dzmodem
- SendFile(R, S1)
- Goto("dl_exit")
-
- :dzmodem
- SendFile(Z, S1)
- Goto("dl_exit")
-
- :dl_exit ; exit Download Menu from here
- Return() ; Return to Main Menu
-
- :exitscp
- Quit()
-
- ; End - MCHOST.SCP