home *** CD-ROM | disk | FTP | other *** search
/ Millennium Time Capsule / AC2000.BIN / disks / hbasic_1 / source / tris.bas < prev    next >
Encoding:
BASIC Source File  |  1997-08-17  |  11.4 KB  |  672 lines

  1.  
  2. REM $option !g
  3. REM $option k400
  4.  
  5. REM REM $include toolbox.bas
  6. REM REM $include pindow.bas
  7. REM REM $include textwind.bas
  8. REM REM $include tris.bh
  9.  
  10. LIBRARY "gemdos"
  11.  
  12. v$="0.0018"
  13. vd$="15/9/96"
  14. DEFINT a-z
  15.  
  16. REM **************************************
  17. SUB init
  18. SHARED b$,c$,g,d$,a,si(27),a$,b,l
  19. STATIC b$,c$,g,d$,a,si(27),a$,b,l
  20.  
  21. PRINT "Loading speech system..."
  22. PRINT " Alphabet... ";
  23.  
  24. b$="E:\TRIS\SPEECH\ALPHABET"
  25. c$=MID$(b$,1,1)
  26. REM G=dsetdrv%(ASC(c$)-ASC("A"))
  27. d$=MID$(b$,3,LEN(b$)-2)
  28. CHDIR d$
  29. a=0
  30.  
  31. DIM si (27)
  32. FOR a=ASC("A") TO ASC("Z") STEP 1
  33. a$=CHR$(a)+".RAW"
  34. b=FEXISTS(a$)
  35.  
  36. IF b THEN
  37. PRINT CHR$(a);
  38. REM OPEN ON a$ FOR INPUT AS #1
  39. REM l=LOF(1)
  40. REM si (a-ASC("A"))=l
  41. END IF
  42.  
  43. IF b=0 THEN
  44. PRINT "!";
  45.  
  46. END IF
  47. NEXT                                                                               
  48.  
  49. PRINT
  50.  
  51. PRINT "    Sounds... ";
  52.  
  53. FOR a=ASC("A") TO ASC("Z")
  54. a$=CHR$(a)+".AVR"
  55. PRINT CHR$(a);
  56. NEXT
  57.  
  58. END SUB
  59.  
  60. REM *********************************
  61.  
  62. REM =================================
  63.  
  64. FUNCTION TreatText$(t$)
  65. SHARED a,c$,t2$,t$
  66. STATIC a,c$,t2$,t$
  67.  
  68. FOR a=1 TO LEN(t$)
  69. c$=MID$(t$,a,1)
  70. c$=UCASE$(c$)
  71.  
  72. IF c$="." THEN t2$=t2$+c$ : c$=CHR$(30)
  73. IF c$=" " THEN t2$=t2$+c$ : c$=CHR$(30)
  74.  
  75. IF ASC(c$)>31 THEN t2$=t2$+c$
  76.  
  77. NEXT a
  78.  
  79. IF RIGHT$(t2$,1)<>" " THEN t2$=t2$+" "
  80. TreatText$=t2$
  81. t2$=""
  82.  
  83. END FUNCTION
  84.  
  85. REM ====================================
  86.  
  87. REM ------------------------------------
  88. FUNCTION NextWord$(w1$,w2$)
  89. REM Gets the next word! Obvious... w1$ contains the word which we 
  90. REM want TO look at next. w2$ contains the sentance to search!
  91. STATIC w$,w1$,w2$,w3$,w1,w2,w3,w4
  92. SHARED w$,w1$,w2$,w3$,w1,w2,w3,w4
  93.  
  94. NextWord$=""
  95.  
  96. w1=INSTR(w2$,w1$)
  97. REM contains the first character of w1$
  98. REM w1 will become first number of next word
  99.  
  100. DO
  101. IF w1<LEN(w2$) THEN w$=MID$(w2$,w1,1) ELSE w$=" "
  102. w1=w1+1
  103. LOOP UNTIL w$=" "
  104.  
  105. REM w1 now should contain the first number.
  106. REM w2 will contain the last character.
  107.  
  108. w2=w1+1
  109.  
  110. DO
  111. IF w2<LEN(w2$) THEN w$=MID$(w2$,w2,1) ELSE w$=" "
  112. w2=w2+1
  113. LOOP UNTIL w$=" "
  114.  
  115. w2=w2-1
  116. w3=w2-w1
  117.  
  118. NextWord$=MID$(w2$,w1,w3)
  119.  
  120. w$="" : w1$="" : w2$="" : w3$=""
  121. w1=0 : w2=0 : w3=0 : w4=0
  122.  
  123. END FUNCTION
  124.  
  125. FUNCTION PrevWord$(p1$,p2$)
  126. REM Erm, just like the above word, execpt it looks for the previous
  127. REM word! Doh!
  128. STATIC p1,p2,p3,p1$,p2$,p3$
  129. SHARED p1,p2,p3,p1$,p2$,p3$
  130.  
  131. PrevWord$=""
  132.  
  133. p1=INSTR(p2$,p1$)
  134.  
  135. DO
  136. IF p1>0 THEN p1$=MID$(p2$,p1,1) ELSE p1$=" "
  137. p1=p1-1
  138. LOOP UNTIL p1$=" "
  139.  
  140. REM p1 now should contain the last number.
  141. REM p2 will contain the first character.
  142.  
  143. p1=p1+1
  144. p2=p1
  145.  
  146. DO
  147. p2=p2-1
  148. IF p2>1 THEN p1$=MID$(p2$,p2,1) ELSE p1$=" "
  149. LOOP UNTIL p1$=" "
  150.  
  151. p3=p1-p2
  152.  
  153. IF p2<0 THEN p2=1
  154.  
  155. REM PRINT #1,"TRIS>PREVWORD>P1='";p1;"' P2='";p2;"' P3='";p3;"'"
  156.  
  157. PrevWord$=MID$(p2$,p2,p3)
  158.  
  159. p1=0 : p2=0 : p3=0
  160. p1$="" : p2$="" : p3$=""
  161.  
  162. END FUNCTION
  163.  
  164. SUB ViewFile(f$)
  165. REM Can file any file, if it's been programmed in, that is.
  166. STATIC f,f$,f2$,f3$,f4$,r$,e$,d2$,key$,num
  167. SHARED f,f$,f2$,f3$,f4$,r$,e$,d2$,key$,num
  168. SHARED text$,texth,wolines(1),TextWindows
  169.  
  170. REM First, get the extension. 
  171. REM File examples... TEXTTEXT.TXT or READ.ME or NONAME
  172.  
  173. f=1
  174.  
  175. r$="" : e$=""
  176.  
  177. IF LEN(f$)<13 AND LEN(f$)>0 THEN
  178.  
  179. DO
  180. IF f<LEN(f$) THEN f2$=MID$(f$,f,1) ELSE f2$="." : e$="!"
  181. f=f+1
  182. LOOP UNTIL f2$="."
  183.  
  184. IF e$="!" THEN f3$="ASC"
  185.  
  186. REM f contains the number of the extension, now to grap it into f3$
  187.  
  188. f3$=MID$(f$,f,LEN(f$)-(f-1))
  189.  
  190. IF f3$<>"GIF" OR f3$<>"TIF" OR f3$<>"MOD" THEN
  191.  
  192. PRINT #1,"TRIS>ViewFile>"+f$
  193.  
  194. IF FEXISTS(f$) THEN
  195.  
  196. OPEN f$ FOR INPUT AS 2
  197. WHILE NOT EOF(2)
  198. num=num+1
  199.  
  200. IF num>20 THEN
  201.  
  202. WINDOW NAME 1," TRIS system "," Press space for next page, enter for next line, Q to quit"
  203. BEEP
  204.  
  205. DO
  206. key$=INKEY$
  207. LOOP UNTIL key$=" " OR key$=CHR$(13) OR UCASE$(key$)="Q"
  208.  
  209. IF key$<>CHR$(13) THEN WINDOW NAME 1," TRIS system ",""
  210.  
  211. IF key$=" " THEN num=0
  212. IF key$=CHR$(13) THEN num=20
  213. IF UCASE$(key$)="Q" THEN CLOSE 2 : r$="Aborted file view" : EXIT SUB
  214.  
  215. END IF
  216.  
  217. LINE INPUT #2,f4$
  218. PRINT f4$
  219.  
  220.  
  221. WEND
  222. CLOSE 2
  223.  
  224. r$="File loaded."
  225.  
  226. WINDOW NAME 1," TRIS system "," "+CURDIR$+"\"
  227.  
  228.  
  229. END IF
  230.  
  231. IF r$="" THEN r$="File not found."
  232. END IF
  233.  
  234. END IF
  235.  
  236. END SUB
  237.  
  238. REM ++++++++++++++++++++++++++++++++++++
  239. SUB CheckText
  240. STATIC t$,t2$,r$,v$,vd$,d1,d2,d3,d4,n$,f$,d1$,d2$,e$,d$,fo$,cd$
  241. SHARED t$,t2$,r$,v$,vd$,d1,d2,d3,d4,n$,f$,d1$,d2$,e$,d$,fo$,cd$
  242.  
  243. r$=""
  244.  
  245. d2$=t$
  246. d1$=t$
  247.  
  248. IF t$="TRIS" THEN
  249. r$="The TRIS - The Real Intelligent System - Version "+v$+". Made by Paul Jones "
  250. r$=r$+"in HiSoft BASIC, on "+vd$+". Copyright to PJCO, Paul Jones Corporation. "
  251. r$=r$+"All rights reserved. TRIS is an artifical intelligent program, PJCO can not"
  252. r$=r$+"be held responsable for what ever TRIS says."
  253. END IF
  254.  
  255. IF t$="MIDIIN" THEN
  256. PRINT : PRINT "MIDI mode - on" : PRINT
  257.  
  258. DO
  259.  
  260. d1=INP(-3)
  261. IF d1 THEN
  262. d2=INP(3)
  263. IF d2<>254 THEN PRINT d2
  264. END IF
  265.  
  266. LOOP UNTIL INKEY$<>""
  267.  
  268. r$="Finished."
  269.  
  270. END IF
  271.  
  272. IF t$="MIDIOUT" THEN
  273.  
  274. PRINT "MIDI out mode - on, type number above or below range of 1-255 to exit"
  275.  
  276. DO
  277.  
  278. INPUT "MIDI OUT>",d3
  279.  
  280. IF d3>-1 AND d3<256 THEN OUT 3,d3
  281. LOOP UNTIL d3<0 OR d3>255
  282.  
  283. r$="Ok."
  284.  
  285. END IF
  286.  
  287. IF MID$(t$,1,6)="NOTEON" THEN
  288.  
  289. d4=VAL(MID$(t$,7,LEN(t$)-6))
  290.  
  291. OUT 3,144 : OUT 3,d4 : OUT 3,80
  292.  
  293. r$="MIDI sent."
  294.  
  295. END IF
  296.  
  297. IF MID$(t$,1,7)="NOTEOFF" THEN
  298.  
  299. d4=VAL(MID$(t$,8,LEN(t$)-7))
  300.  
  301. OUT 3,144 : OUT 3,d4 : OUT 3,0
  302.  
  303. r$="MIDI sent."
  304.  
  305. END IF
  306.  
  307. IF INSTR(t$,"HELLO") THEN r$="Hello user."
  308. IF INSTR(t$,"HI") THEN r$="Hi there!"
  309.  
  310. IF INSTR(t$,"DIR") THEN
  311.  
  312. IF INSTR(t$,"ROOT") THEN
  313.  
  314. IF INSTR(t$,"TO") THEN
  315.  
  316. d$=CHR$(dgetdrv%+ASC("A"))
  317. cd$=d$+":\"
  318.  
  319. CHDIR cd$
  320.  
  321. WINDOW NAME 1," TRIS system "," "+CURDIR$+"\"
  322.  
  323. r$="Root directory." : EXIT SUB
  324.  
  325. END IF
  326. END IF
  327.  
  328. IF INSTR(t$,"CHANGE") THEN
  329.  
  330. t$=d2$
  331. cd$=NextWord$("DIR",t$)
  332. t$=d2$
  333. PRINT #1,"TRIS>CHANGE>CD$='"+cd$+"'"
  334. IF cd$="TO" THEN
  335.     t$=d2$
  336.     cd$=NextWord$("TO ",t$)
  337.     t$=d2$
  338. END IF
  339.  
  340. PRINT #1,"TRIS>CHANGE>DIRECTORY>"+cd$
  341.  
  342. CHDIR cd$
  343.  
  344. WINDOW NAME 1," TRIS system "," "+CURDIR$+"\"
  345.  
  346. r$="Directory changed."
  347.  
  348. END IF
  349.  
  350. t$=d2$
  351. e$="*.*"
  352. fo$=""
  353.  
  354. IF INSTR(t$,"EXT") THEN
  355.  
  356. t$=d2$
  357. e$=NextWord$("EXT",t$)
  358. t$=d2$
  359. e$=MID$(e$,2,LEN(e$))
  360. IF LEN(e$)=3 THEN e$="*."+e$
  361. IF LEN(e$)=0 THEN e$="*.*"
  362.  
  363. PRINT #1,"TRIS>DIR>EXTENSION='"+e$+"'"
  364.  
  365. END IF
  366.  
  367. IF INSTR(t$,"FOLDER") THEN
  368.  
  369. t$=d2$
  370. fo$=NextWord$("FOLDER",t$)
  371. t$=d2$
  372. fo$="\"+MID$(fo$,1,LEN(fo$))
  373.  
  374. PRINT #1,"TRIS>DIR>FOLDER='"+fo$+"'"
  375.  
  376. END IF
  377.  
  378. IF INSTR(t$,"DRIVE")=0 AND INSTR(t$,"FOLDER")=0 AND INSTR(t$,"CHANGE")=0 THEN 
  379. d$=CHR$(dgetdrv%+ASC("A"))
  380. fo$=CURDIR$
  381. FILES CURDIR$+"\"+e$
  382. r$="Directory of '"+CURDIR$+"\"+e$+"' complete."
  383. END IF
  384.  
  385. IF INSTR(t$,"DRIVE") THEN
  386.  
  387. t$=d2$
  388. d$=NextWord$("DRIVE",t$)
  389. t$=d2$
  390.  
  391. IF LEN(d$)=2 THEN d$=MID$(d$,1,1)
  392. IF LEN(d$)>2 THEN d$=CHR$(dgetdrv%+ASC("A"))
  393. IF LEN(d$)=0 THEN d$=CHR$(dgetdrv%+ASC("A"))
  394.  
  395. PRINT #1,"TRIS>DIR>DRIVE '"+d$+"'"
  396.  
  397. IF LEN(d$)=0 THEN FILES d$+":"+fo$+"\"+e$
  398.  
  399. IF LEN(d$)=1 THEN
  400. FILES d$+":"+fo$+"\"+e$
  401.  
  402. PRINT #1,"TRIS>DIR>FILES '"+d$+":"+fo$+"\"+e$+"'"
  403. END IF 
  404.  
  405. END IF
  406.  
  407. IF r$="" THEN r$="Directory of '"+d$+":"+fo$+"\"+e$+"' complete."
  408.  
  409. END IF
  410.  
  411. t$=d2$
  412.  
  413. IF INSTR(t$,"LOOK") THEN
  414.  
  415. t$=d2$
  416.  
  417. n$=NextWord$("LOOK",t$)
  418.  
  419. t$=d2$
  420.  
  421. PRINT #1,"TRIS>>Typed in '"+t$+"'. NextWord='"+n$+"'"
  422.  
  423. IF n$="LIKE" THEN r$="Does it matter?"
  424.  
  425. t$=d2$
  426.  
  427. IF n$="AT" THEN
  428.  
  429. IF r$="" THEN
  430. t$=d2$
  431. f$=NextWord$("AT",t$)
  432. t$=d2$
  433.  
  434. PRINT #1,"TRIS>VIEWFILE>NextWord='"+f$+"'"
  435.  
  436. ViewFile (f$)
  437.  
  438. IF f$="DRIVE" THEN r$="It's very nice. What about it?"
  439.  
  440. END IF
  441. END IF
  442.  
  443. d1$=""
  444.  
  445. END IF
  446.  
  447. t$=d2$
  448.  
  449. IF INSTR(t$,"CD") THEN
  450.  
  451. cd$=NextWord$("CD",t$)
  452.  
  453. t$=d2$
  454.  
  455. CHDIR cd$
  456.  
  457. WINDOW NAME 1," TRIS system "," "+CURDIR$+"\"
  458.  
  459. r$="Changed folder."
  460.  
  461. END IF
  462.  
  463. t$=d2$
  464.  
  465. IF INSTR(t$,"CHANGE") THEN
  466.  
  467. t$=d2$
  468.  
  469. IF INSTR(t$,"DRIVE") THEN
  470. t$=d2$
  471. n$=NextWord$("DRIVE",t$)
  472. t$=d2$
  473.  
  474. IF n$="TO" THEN
  475.     t$=d2$
  476.     n$=NextWord$("TO",t$)
  477.     t$=d2$
  478. END IF
  479.  
  480. d1=dsetdrv%(ASC(n$)-ASC("A"))
  481.  
  482. WINDOW NAME 1," TRIS system "," "+CURDIR$+"\"
  483.  
  484. r$="Drive changed."
  485.  
  486. END IF
  487. END IF
  488.  
  489. t$=d2$
  490.  
  491. IF INSTR(t$,"FOLDER") THEN
  492.  
  493. IF INSTR(t$,"IN") THEN 
  494.  
  495. t$=d2$
  496. n$=NextWord$("FOLDER",t$)
  497. t$=d2$
  498.  
  499. CHDIR n$
  500.  
  501. WINDOW NAME 1," TRIS system "," "+CURDIR$+"\"
  502.  
  503. r$="Gone into folder."
  504.  
  505. END IF
  506.  
  507. IF INSTR(t$,"BACK") THEN
  508.  
  509. CHDIR ".."
  510.  
  511. WINDOW NAME 1," TRIS system "," "+CURDIR$+"\"
  512.  
  513. r$="Gone back a folder."
  514.  
  515. END IF
  516.  
  517. IF INSTR(t$,"PREVIOUS") THEN
  518.  
  519. CHDIR ".."
  520.  
  521. WINDOW NAME 1," TRIS system "," "+CURDIR$+"\"
  522.  
  523. r$="Gone back to previous folder."
  524.  
  525. END IF
  526.  
  527. END IF
  528.  
  529. IF INSTR(t$,"WHAT") THEN
  530.  
  531. IF INSTR(t$,"TIME") THEN
  532.  
  533. r$="The time is: "+TIME$
  534.  
  535. END IF
  536.  
  537. IF INSTR(t$,"DATE") THEN
  538.  
  539. r$="The date is: "+DATE$+" in the form Month-Day-Year"
  540.  
  541. END IF
  542. END IF
  543.  
  544. IF t$="EXIT " THEN r$="Terminating program..."
  545.  
  546. IF r$="" THEN r$="'"+MID$(d2$,1,LEN(d2$)-1)+"' has not been entered into my 'brain'!"
  547.  
  548. END SUB
  549.  
  550. SUB ProcessKeys (ascii$,scan_code, kstate)
  551. STATIC ascii$,scan_code,kstate,k1$,k2$,k3$,finished_flag,t$,r$
  552. SHARED ascii$,scan_code,kstate,k1$,k2$,k3$,finsihed_flag,t$,r$
  553.  
  554. k1$=ascii$
  555. IF ASC(k1$)>31 THEN k2$=k2$+k1$
  556. IF ASC(k1$)=13 THEN
  557. PRINT #1,"USER>"+k2$+CHR$(13)+CHR$(10)
  558. t$=TreatText$(k2$)
  559. PRINT #1,"TRIS>T>"+t$
  560. CALL CheckText
  561. PRINT "TRIS>"+r$
  562. PRINT #1,"TRIS>"+r$
  563. PRINT 
  564. END IF
  565.  
  566. IF ASC(k1$)=8 THEN k2$=MID$(k2$,1,LEN(k2$)-1)
  567. IF k1$<>"" THEN PRINT k1$;
  568.  
  569. IF k2$="EXIT" THEN
  570. finished_flag=-1
  571. PRINT #1,"TRIS>Finish time... "+TIME$
  572. PRINT #1
  573. PRINT #1,STRING$(80,ASC("-"))
  574. CLOSE #1
  575. END IF
  576.  
  577. k3$=k1$
  578. k2$=""
  579.  
  580. END SUB
  581.  
  582.  
  583.  
  584.  
  585. REM ++++++++++++++++++++++++++++++++++++
  586.  
  587. wx=PEEKW(SYSTAB+58)
  588. wy=PEEKW(SYSTAB+60)
  589. ww=PEEKW(SYSTAB+62)
  590. wh=PEEKW(SYSTAB+64)
  591.  
  592. WINDOW OPEN 1," TRIS system ",wx,wy,ww,wh,win_all
  593. WINDOW NAME 1," TRIS system "," "+CURDIR$+"\"
  594.  
  595. REM 1=Title bar
  596. REM 2=Close box
  597. REM 4=Full box
  598. REM 8=Move box
  599. REM 16=Info line
  600. REM 32=Size box
  601. REM 64=Up arrow
  602. REM 128=Down arrow
  603. REM 256=Vertical slider
  604. REM 512=Left Arrow
  605. REM 1024=Right arrow
  606. REM 2048=Horizontal slider
  607.  
  608. WINDOW OUTPUT 1
  609.  
  610. WINDOW CONTRL 1,3,1000
  611. WINDOW CONTRL 1,2,1000
  612.  
  613. WINDOW ON
  614.  
  615. REM **** Initisation ****
  616.  
  617. REM StartProgram "TRIS.RSC",MENU,0
  618. REM keys_enabled=1
  619.  
  620. PRINT
  621. PRINT
  622. PRINT "             Loading the...."
  623. PRINT 
  624. PRINT                                                                               
  625. PRINT "            ############# ###########    ####   ##########      "               
  626. PRINT "                ####      ####    ####   ####  ####             "               
  627. PRINT "                ####      ###########    ####    #########      "               
  628. PRINT "                ####      #### #####     ####          #####    "               
  629. PRINT "                ####      ####    ####   ####  ###########      "               
  630. PRINT 
  631. PRINT "                        The Real Intelligent System "                                                                              
  632. PRINT "                                  V"+v$
  633. PRINT 
  634.  
  635. j=cursconf%(5,0)
  636. dummy=cursconf%(2,j)
  637.  
  638. OPEN "TRISTYPE.DAT" FOR APPEND AS #1
  639. PRINT #1
  640. PRINT #1,STRING$(80,ASC("-"))
  641. PRINT #1
  642. PRINT #1,"TRIS> Start date... "+DATE$
  643. PRINT #1,"TRIS> Start time... "+TIME$
  644. PRINT #1,"TRIS> Version...... "+v$+" ("+vd$+")"
  645. PRINT #1
  646.  
  647. REM HGTLoop
  648.  
  649. DO
  650.  
  651. IF INKEY$=CHR$(27) THEN CLOSE #1 : PRINT "Closed"
  652. LINE INPUT "USER>",dummy$
  653. PRINT #1,"USER>"+dummy$
  654.  
  655. t$=TreatText$(dummy$)
  656.  
  657. PRINT #1,"TRIS>T>"+t$
  658. CALL CheckText
  659.  
  660. PRINT "TRIS>"+r$
  661. PRINT #1,"TRIS>"+r$
  662.  
  663. PRINT 
  664.  
  665. LOOP UNTIL t$="EXIT "
  666. PRINT #1,"TRIS>Finish time... "+TIME$
  667. PRINT #1
  668. PRINT #1,STRING$(80,ASC("-"))
  669. CLOSE #1
  670.  
  671. REM StopProgram
  672. STOP -1