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

  1. '$DEBUG PBDEBUG ON
  2. $INCLUDE "METAS.BAS"       ' compiler configuration options
  3. $INCLUDE "CONSTANTS.BAS"   ' conditional compilation options
  4. DEFINT A-Z                 ' all vars are signed short integers
  5. $INCLUDE "DECLARES.BAS"    ' all sub/function declarations for externals
  6. OPTION BINARY BASE 1       ' all files start at byte 1
  7. $INCLUDE "TYPES.BAS"       ' type structures for dBASE/XModem and E-Mail
  8. $INCLUDE "DIMS.BAS"        ' all global dimensions
  9. $INCLUDE "SHARED.BAS"      ' all global variables
  10. $INCLUDE "FIXUP.INC"       ' create jump table for keywords
  11. COMPILEDATE$ = "rv 02.01.94"
  12. ' PROZO$ is displayed when the user connects
  13.  
  14. PRXVER$="PRZ0098" ' revision stamp for compiled programs
  15. PROZO$= "^0@CLS()^B^c@DUP(@CHR(8),10)MSP:PROZOL Microframe Operating System v.98"+CHR$(13,10)+_
  16.  "Copyright (C) 1994  Mermaid Software Products  All Rights Reserved"+CHR$(13,10,13,10)
  17. ErrorMsg%=%True
  18. $IF %MONOWATCH
  19. ON TIMER(5) GOSUB MONOCOPY
  20. TIMER ON
  21. $ENDIF
  22.  
  23. $IF %KILLF10
  24. ON KEY(10) GOSUB F10PRESSED
  25. KEY(10) ON
  26. $ENDIF
  27.  
  28.  BT.Update.Always% = -1 ' for Vest BTree indexing
  29.  
  30. ' set ports
  31. def seg=&h40
  32. poke 0,&hf8  '03F8  sets com1 address irq 4
  33. poke 1,&h03
  34. poke 2,&hf8  '02F8  sets com2 address irq 3
  35. poke 3,&h02
  36. poke 4,&he8  '03E8  sets com3 address irq 4
  37. poke 5,&h03
  38. poke 6,&he8  '02E8  sets com4 address irq 3
  39. poke 7,&h02
  40.  
  41. $IF NOT %NOTASKS
  42.  TaskDepth%=4           ' default "depth" for background processing calls
  43. $ENDIF
  44. CALL DVGETVERSION    'Initialize Desqview API  (see also WINAPI.BAS)
  45. IF ISFALSE INSTR(UCASE$(COMMAND$),"/E") THEN
  46.         ' for debugging, this command line switch will supress the ON ERROR
  47.         ' error checking of PowerBASIC.  Any error will crash with a pgm-ctr
  48.         ' number, which helps us find any bugs (shame) in the source code.
  49.         ON ERROR GOTO 10000
  50.     ELSE
  51.         ON KEY(10) GOSUB 10000
  52.         KEY(10) ON
  53. END IF
  54. ' The commandline switch /IRQ=nn will allow us to override the default IRQ
  55. ' for the com port.  This will allow many more COM ports to be used on a
  56. ' single machine running Desqview or something similar
  57. IF INSTR(UCASE$(COMMAND$),"/IRQ=") THEN
  58. IRQ$=MID$(COMMAND$,INSTR(UCASE$(COMMAND$),"/IRQ=")+5,1)
  59. END IF
  60.  
  61. ' The commandline switch /PORT=nn allows us to override the default port
  62. ' address, allowing us to simulate COM5+
  63. IF INSTR(UCASE$(COMMAND$),"/PORT=") THEN
  64. ' must be 4 digit hex number
  65. PORTADDR$=MID$(COMMAND$,INSTR(UCASE$(COMMAND$),"/PORT=")+6,4)
  66. END IF
  67.  
  68. IF INSTR(UCASE$(COMMAND$),"/DIRECT=") THEN
  69. ' indicates direct connect and baud rate
  70. DIRECT$=MID$(COMMAND$,INSTR(UCASE$(COMMAND$),"/DIRECT=")+8)+" "
  71. DIRECT$=LEFT$(DIRECT$,INSTR(DIRECT$," ")-1)
  72. DIRECT$=REMOVE$(DIRECT$,",")
  73. END IF
  74.  
  75. CrLf$=CHR$(13,10) ' used for all carriage returns
  76.  
  77.  
  78. IIFState%=%TRUE
  79. IfState%=%True                   ' used for block CASE..END CASE
  80. COMMANDLINE$ = UCASE$(COMMAND$)  '
  81. LET UserTime# = 360000           ' amount of time user may be logged in
  82. CLS:LOCATE ,,1                   ' make cursor visible
  83. PROZOPRINT PROZO$                  ' copyright
  84. PROZOPRINT CompileDate$+CrLf$     ' compile date fyi
  85. AnswerThePhone:                  ' we come here from the ANSWER command
  86. IF Comline THEN RESETMODEM       ' hang up if connected
  87. PROZOPRINT CrLf$                  '
  88.  
  89. ' ______________ CONFIGURATION VARIABLES _____________________
  90. CLOSE
  91. $INCLUDE "CONFIG.BAS" ' ......................Load config file
  92.  
  93. IF LEFT$(COMMANDLINE$, 1) = "-" THEN GOTO COMPILER '..........COMPILER MODE
  94.  
  95. IF LEFT$(COMMANDLINE$, 3) = "COM" THEN '........................ANSWER MODE
  96.    PARM$ = LEFT$(COMMANDLINE$, 5)+BAUD$+"," + Proto$
  97.    IF IRQ$<>""THEN PARM$=PARM$+",IR"+IRQ$
  98.    Port% = VAL(MID$(PARM$, 4, 1)):
  99.    IF PORTADDR$<>"" THEN '.......................POKE nonstandard port addr.
  100.     DEF SEG = &H40
  101.     poke (Port%-1)*2,val("&H"+right$(PORTADDR$,2))
  102.     poke (Port%-1)*2+1,val("&H"+left$(PORTADDR$,2))
  103.         Padd% = peeki (Port%-1)*2
  104.     DEF SEG
  105.    ELSE
  106.        DEF SEG = &H40
  107.         padd% = peeki (port%-1)*2
  108.        DEF SEG
  109.    END IF
  110.    Node$ = "PORT" + STR$(Port%): GOTO HOST
  111. END IF
  112.  
  113.  
  114.  
  115. DO:DUMMY$=POPARG$:LOOP WHILE ArgPtr%   ' clear argument stack
  116. IF LEN(COMMANDLINE$) THEN              ' if PROZOL command is on command line
  117.         PROZOL COMMANDLINE$             ' then execute it
  118. END IF
  119. DO:DUMMY$=POPARG$:LOOP WHILE ArgPtr%   ' clear argument stack
  120. GOTO PROGINPUT                    ' do not answer the phone
  121.  
  122.  
  123. HOST:
  124.  
  125. WAITINGFORRING:
  126. IF LEN(DIRECT$) THEN
  127.     REPLACE BAUD$ WITH DIRECT$ IN PARM$
  128.         Comline=1:e=0:Carrier%=1
  129.         BAUD$=DIRECT$
  130.         BAUD=VAL(DIRECT$)
  131.         COMOPEN PARM$
  132. ELSE
  133. $INCLUDE "ANSWER.BAS"   ' set up the modem and wait for caller
  134. END IF
  135. ' a call has come in at this point
  136. SOUND 2000,2:SOUND 500,.5:DELAY .1:SOUND 500,.5
  137. PROZOCLS
  138. PROZOPRINT PROZO$ ' display copyright
  139. PROZOPRINT "][ CORE " + ENVIRON$("HOSTNODE")+"  "+ Node$ + "  BPS:" + STR$(Baud) + CrLf$
  140. PROGDELAY 2
  141. PROZOL OnAnswer$ ' execute PROZOL command specified in config at ON ANSWER
  142.  
  143. $SEGMENT '===================================================================
  144. ' this main loop controls the execution of all PROZOL programs
  145. ' and the immediate mode interpreter command line
  146. PROGINPUT:
  147.  
  148.   IF TerminalMode% THEN
  149.     IF LOC(6) THEN DM INPUT$(LOC(6),6)
  150.   END IF
  151.  
  152. IF Prog% THEN               'single-step parent program if currently running
  153.  
  154. stp:
  155.  
  156.   IF Progline% = 1000 THEN Prog% = 0: Ifstate%=%True:GOTO PROGINPUT  ' stop if run-off end
  157.   IF RTRIM$(PROGRAM$(Progline%)) = "" THEN INCR Progline%: GOTO stp
  158.   Prog$ = PROGRAM$(Progline%)             ' load line to process into Prog$
  159.   IF Progline%=1 then
  160.        if len(Program$(0)) then prx%=%True else prx%=%False
  161.   END IF
  162.  
  163. END IF
  164. IF Prog% = 0 THEN  ' if no parent is running then display system prompt
  165. Prx%=%False
  166. PROZOPRINT PROMPT$
  167.  
  168. VALUE$=PROZOINPUT$
  169.  
  170.         IF VAL(Value$) THEN
  171.     A = VAL(Value$): b = INSTR(Value$, " "): IF b = 0 OR A > 1000 THEN DM "ILLEGAL PROGRAM LINE" + CrLf$ + CHR$(7): GOTO PROGINPUT
  172.         LET PROGRAM$(A) = MID$(Value$, b + 1)
  173.     IF A>MaxLine% THEN MaxLine% = A
  174.      GOTO PROGINPUT
  175.     END IF
  176.  
  177. Prog$ = Value$
  178. END IF
  179. ChaffLoop:
  180. '*************************************************************************
  181. IF IfState% THEN
  182.  
  183. IF Prx%=%False THEN PREP Prog$'........ PREPROCESS THE STATEMENT?
  184. RepeatLabel:
  185. RepeatFlag%=0 '................... set to true if statement is to be repeated
  186. ExitFlag%=0 '............... set to true if statement is aborted by condition
  187. ArgPtr%=0
  188. IIfState%=%True
  189. 'EProg$=Prog$
  190. $IF NOT %NOTASKS
  191. CALL TASKMAN
  192. $ENDIF
  193. EXEC Prog$ '.......................... EXECUTE THE PROGRAM LINE !!!!!!!!!!!!!
  194.     IF RepeatFlag% GOTO RepeatLabel
  195.  
  196.         ELSE
  197.  
  198. IF UCASE$(ltrim$(rtrim$(Prog$)))="ELSE"or prog$=symelse$ then IfState%=%True
  199. IF UCASE$(ltrim$(rtrim$(Prog$)))="ENDCASE" or prog$=symendcase$ THEN IfState%=%True
  200.  
  201.         END IF
  202.  
  203. '*************************************************************************
  204. BackFromError:
  205.         IF AnswerFlag% THEN AnswerFlag%=0:GOTO ANSWERTHEPHONE
  206.  
  207. IF Prog% THEN INCR Progline% else IfState%=%True:IfPointer%=0:StackPointer%=0
  208. GOTO PROGINPUT
  209.  
  210. $INCLUDE "ERROR.BAS"     ' error handler
  211.  
  212. DATA "UNK"
  213. $INCLUDE "ERRORMSG.BAS"  ' data statements containing error messages
  214.  
  215. '' Subroutines begin here ==============================================
  216. $IF NOT %NOTASKS
  217. $INCLUDE "TASKMAN.BAS"  ' Task manager for background routines
  218. $ENDIF
  219. $INCLUDE "ANSIPRIN.BAS" ' ansi printing
  220. $INCLUDE "CALC.BAS"     ' arithmetic calculator routine (RCD)
  221. $INCLUDE "PREP.BAS"     ' Interpreted code pre-processor subroutine
  222. $INCLUDE "CUSTOM.BAS"   ' SUBs and FUNCTIONs for custom commands
  223. $INCLUDE "PROZO_IO.BAS"  ' General input output procedures
  224. $INCLUDE "EXEC.BAS"     ' execute a prepared line of code
  225. $INCLUDE "RIP.BAS"
  226. $SEGMENT
  227. $INCLUDE "DATABASE.BAS" ' database procedures
  228. $INCLUDE "BTREE.BAS"    ' database index btree for <=64K records
  229. $INCLUDE "COMSUBS.BAS"  ' all communications i/o subroutines
  230. $INCLUDE "GETVAR$.BAS"  ' return the value of a PROZOL variable
  231. $INCLUDE "VSET.BAS"     ' set the value of PROZOL variables
  232. $SEGMENT
  233. $INCLUDE "TRANSLAT.BAS" ' merge PROZOL variables with text
  234. $INCLUDE "FUNCTION.BAS" ' process functions in text
  235. $INCLUDE "SYMBOLS.BAS"  ' process terminal emulation codes in text
  236. $INCLUDE "REPRINT.BAS"  ' print without moving cursor
  237. $INCLUDE "WAITSTAT.BAS" ' if key is in buffer
  238. $INCLUDE "CWAIT.BAS"    ' wait until key is pressed
  239. $INCLUDE "PROGDELA.BAS" ' timed delay loop for all delays (may add tasks)
  240. $INCLUDE "TIMEOUT.BAS"  ' what happens on user kb timeout
  241. $INCLUDE "GETCOMME.BAS" ' get and display mail if any
  242. $INCLUDE "PUTCOMME.BAS" ' write mail comment to disk
  243. $INCLUDE "RESETMOD.BAS" ' reset the modem
  244.  
  245. $INCLUDE "EFFECT.BAS"   ' sound effects
  246. $INCLUDE "EXIST.BAS"    ' old format of file exist function
  247. $INCLUDE "XMODEMIN.BAS" ' rec xmodem file
  248. $INCLUDE "XMODEMOU.BAS" ' send xmodem file
  249. $INCLUDE "SYSRESET.BAS" ' reset system/re-run
  250. $INCLUDE "GETACKNA.BAS" ' for xmodem
  251. $INCLUDE "GETXCHAR.BAS" ' for xmodem
  252. $INCLUDE "PUSHPOP.BAS"  ' stacks
  253. $INCLUDE "COMPILER.BAS" ' compiler procedure
  254.  
  255. $LINK "STRINGA.OBJ"     ' CRC routines for xmodem
  256. $LINK "DVCALLS.OBJ"     ' optimizing routines for DV
  257.  
  258. $SEGMENT
  259. $INCLUDE "CONF.BAS"     ' conference subroutines
  260. $INCLUDE "OLM.BAS"      ' "on line messages" live multiuser messages
  261. $INCLUDE "CHAT.BAS"     ' live 6-way multi-user chat
  262. $INCLUDE "DMMENU.BAS"   ' ansi box
  263. $INCLUDE "DMWINDO.BAS"  ' ansi menu
  264. $INCLUDE "DMXMENU.BAS"  ' better ansi menu
  265.  
  266. $INCLUDE "GETGO.BAS"    ' hot run other programs from menus/input
  267. $INCLUDE "OBASE.BAS"    ' database index routines for databases > 64K recs
  268. $INCLUDE "EDIT.BAS"     ' full screen field input routines
  269. $INCLUDE "AUTOEDIT.BAS" ' name and address cleanup routines
  270. $INCLUDE "QUIKSORT.BAS" ' c.a.r.hoare's quiksort implementation
  271. $INCLUDE "DIREXIST.BAS" ' function to tell if a dir exists
  272. $SEGMENT
  273. $INCLUDE "PCBTYPE.BAS"  ' display a pcboard file listing
  274. $INCLUDE "EDLIN.BAS"    ' an EDLIN clone for editing.
  275. $INCLUDE "EDITCOMM.BAS" ' edit mail and post
  276.  
  277. SUB PROZOL (X$)
  278.     PREP X$
  279.         EXEC X$
  280. END SUB
  281.  
  282. FUNCTION PRO$
  283. IF Ext$<>"" THEN PRO$=Ext$ ELSE IF Tty THEN PRO$=".TTY" ELSE PRO$=".PRO"
  284. END FUNCTION
  285.  
  286. MONOCOPY:
  287. DEF SEG = &HB800
  288. ASDFASDF$=PEEK$(0,4000)
  289. DEF SEG = &HB000
  290. POKE$ 0,ASDFASDF$
  291. DEF SEG
  292. RETURN
  293.  
  294. F10PRESSED:
  295. END
  296.  
  297. ' PowerBASIC Units
  298. $LINK "RINSTR.PBU" ' Necessary for Reverse-Instr (do this inline later)
  299. '$LINK "BASIC.PBU" ' BASIC compatible interpreter (to be added later)
  300. '$LINK "ANSIPRIN.PBU" ' ANSI driver
  301. '$LINK "EXTMATHB.PBU" ' Extended math
  302. '$LINK "EVAL.PBU"     ' replacement for CALC
  303. $LINK "ELIZA.PBU"
  304.