home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OL.LZH / PROCS.LZH / READTBL.ICN < prev    next >
Text File  |  1991-09-05  |  2KB  |  82 lines

  1. ############################################################################
  2. #
  3. #    Name:     readtbl.icn
  4. #
  5. #    Title:     Read user-created stripsgml table
  6. #
  7. #    Author:     Richard L. Goerwitz
  8. #
  9. #    Version: 1.1
  10. #
  11. #    Date:     June 1, 1991
  12. #
  13. ############################################################################
  14. #  
  15. #  This file is part of the strpsgml package.  It does the job of read-
  16. #  ing option user-created mapping information from a file.  The purpose
  17. #  of this file is to specify how each code in a given input text should
  18. #  be translated.  Each line has the form:
  19. #
  20. #      SGML-designator    start_code    end_code
  21. #
  22. #  where the SGML designator is something like "quote" (without the quota-
  23. #  tion marks), and the start and end codes are the way in which you want
  24. #  the beginning and end of a <quote>...<\quote> sequence to be transla-
  25. #  ted.  Presumably, in this instance, your codes would indicate some set
  26. #  level of indentation, and perhaps a font change.  If you don't have an
  27. #  end code for a particular SGML designator, just leave it blank.
  28. #
  29. ############################################################################
  30. #
  31. #  Links: strpsgml.icn
  32. #
  33. ############################################################################
  34.  
  35. link strpsgml
  36.  
  37. procedure readtbl(f)
  38.  
  39.     local t, line, k, on_sequence, off_sequence
  40.  
  41.     /f & stop("readtbl:  Arg must be a valid open file.")
  42.  
  43.     t := table()
  44.  
  45.     every line := trim(!f,'\t ') do {
  46.     line ? {
  47.         k := tabslashupto('\t:') &
  48.         tab(many('\t:')) &
  49.         on_sequence := tabslashupto('\t:') | tab(0)
  50.         tab(many('\t:'))
  51.         off_sequence := tab(0)
  52.     } | stop("readtbl:  Bad map file format.")
  53.     insert(t, k, outstr(on_sequence, off_sequence))
  54.     }
  55.  
  56.     return t
  57.  
  58. end
  59.  
  60.  
  61.  
  62. procedure tabslashupto(c,s)
  63.  
  64.     POS := &pos
  65.  
  66.     while tab(upto('\\' ++ c)) do {
  67.     if ="\\" then {
  68.         move(1)
  69.         next
  70.     }
  71.     else {
  72.         if any(c) then {
  73.         suspend &subject[POS:.&pos]
  74.         }
  75.     }
  76.     }
  77.  
  78.     &pos := POS
  79.     fail
  80.  
  81. end
  82.