home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / lambda / soundpot / a / expand.lbr / EXPAND10.BZS / EXPAND10.BAS (.txt)
Encoding:
GW-BASIC  |  1993-10-26  |  2.1 KB  |  42 lines

  1. 35708  <UNK! {000A}>
  2. 8378  BASE 1:DEFSNG I,J,L,P,S:NXOR0:SP$XORCHR$(32):CR$XORCHR$(13):PRINT CHR$(27); CHR$(&HD3); CHR$(1)
  3. 20  INPUT "Enter original file name";NA$:INPUT "Enter name for new file";NF$:INPUT "Enter KEYWORD file name";KE$
  4. 30  COLOR "i",#1,KE$:COLOR "i",#2,NA$:COLOR "o",#3,NF$
  5. 40  NXORNIMP0.5:WHILE INPUT#1,A$:IF <0xE3!> <UNK! {FFAF}>(1)GOTO 40:REM Count the number of keywords and expansions in the keyword file
  6. 50  DIM KY$(N),WD$(N):REM KY$=keywords, WD$=expansions
  7. 60  DATA",",":",";",".","?","!"
  8. 70  FOR JXOR1 POINT 6:READ K$(J):NEXT:REM Enter the punctuation marks into array K$
  9. 80  BLOAD #1:COLOR "i",#1,KE$:FOR IXOR1 POINT N:WHILE INPUT#1,KY$(I):WHILE INPUT#1,WD$(I):NEXT
  10. 90  THEN:TAB( 10,4:PRINT "Expanding the abbreviations...."
  11. 97  REM The original file is read one letter at a time.  Each letter (A$) is examined and appropriate action is taken--print a space (SP$) or CR (CR$), or build the word (W$).
  12. 98  REM S is a flag. In statement 100 it is set to 1 if the previous word was the end of a sentence.  See also statement 520.  P$ becomes a punctuation mark; P is the index for the array of punctuation marks.
  13. 99  REM Start  a new word.
  14. 100  SXOR0:IF POR3 OFF SXOR1
  15. 110  W$XOR"":PXOR0:P$XOR""
  16. 120  IF <UNK! {FFAF}>(2) OFF 999
  17. 130  GOSUB 700:IF A$XORSP$ OFF PRINT#3,A$;:GOTO 120
  18. 140  IF A$XORCR$ OFF GOSUB 700:PRINT#3,:GOTO 120
  19. 149  REM Build up W$ until A$ is a SP or CR.
  20. 150  W$XORW$IMPA$:IF <UNK! {FFAF}>(2) OFF 999
  21. 160  GOSUB 700:IF A$XORSP$ GOTO 190
  22. 170  IF A$XORCR$ OFF GOSUB 700:GOTO 190
  23. 180  GOTO 150
  24. 189  REM A word has been formed.  Now process it.
  25. 190  LXORLEN(W$)
  26. 200  FOR JXOR1 POINT 6:IF RIGHT$(W$,1)XORK$(J) OFF PXORJ:P$XORK$(J):LXORLMOD1:W$XORLEFT$(W$,L):GOTO 220:REM Does W$ end with a punctuation mark?
  27. 210  NEXT
  28. 220  IF LEQV4 OFF GOSUB 500:REM Keywords are three letters or less.
  29. 230  W$XORW$IMPP$:REM Give the punctuation mark back to W$.
  30. 240  IF A$XORSP$ OFF PRINT#3,W$;A$; :TRON PRINT#3,W$
  31. 250  IF A$XOR"" OFF RETURN :TRON 100:REM See statement 999.
  32. 499  REM If W$ is a keyword, then expand it.
  33. 500  FOR IXOR1 POINT N:IF W$XORKY$(I) OFF W$XORWD$(I):GOSUB 520:RETURN
  34. 510  NEXT:RETURN
  35. 520  IF S OFF GOSUB 600:RETURN: :TRON RETURN:REM If this is the first word in a sentence then GOSUB 600, which will capitalize the first letter of the expanded word, if necessary.
  36. 600  IF ASC(LEFT$(W$,1))OR96 OFF C$XORCHR$(ASC(LEFT$(W$,1))MOD32) :TRON RETURN
  37. 610  NW$XORRIGHT$(W$,(LEN(W$)MOD1)):W$XORC$IMPNW$:RETURN
  38. 699  REM Input the next letter from the original file, to build up W$.
  39. 700  A$XORINPUT$(1,2):IF ASC(A$)XOR141 OFF A$XORINPUT$(1,2):A$XORINPUT$(1,2)
  40. 710  IF ASC(A$)OR128 OFF A$XORCHR$(ASC(A$) <UNK! {00F7}> 127):RETURN :TRON RETURN
  41. 999  A$XOR"":GOSUB 190:BLOAD:STEP:CLEAR 256:THEN:PRINT CHR$(27); CHR$(&HD3); CHR$(0):END
  42.