home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / bbs / ansig100.zip / PBPRINT.BAS < prev    next >
BASIC Source File  |  1993-11-05  |  6KB  |  152 lines

  1. DECLARE FUNCTION PBFilter$ (B$)
  2. DECLARE SUB PBPrint (B$)
  3. DEFINT A-Z
  4. CONST true = -1, false = 0
  5. ' AnsiGraph Toolkit....
  6. '         ┌┬──┐ ┌┬──┐ ┌┐ ┐ ┐ ┌┬──┐ ┌┬──┐ ┌┬─┐  ┌┬──┐ ┌┬──┐ ┌┬──┐ ┬┬──┐
  7. '         ├┼──┘ ├┤  │ ├┤ │ │ ├┼─   ├┼─┬┘ ├┼─┴┐ ├┤  │ ├┼──┤ ├┼─┬┘ ├┤  │
  8. '         └┘    └┴──┘ └┴─┴─┘ └┴──┘ └┘ └  └┴──┘ └┴──┘ └┘  ┘ └┘ └  ┴┴──┘
  9. '
  10. '                      █▀▀▄ █▀▀▄     █▀▀█ █▄  █ ▄▀▀▀ ▀█▀         Version
  11. '                      █▀▀  █▀▀▄ ▀▀▀ █▀▀█ █ ▀▄█  ▀▀▄  █            1.4
  12. '                      ▀    ▀▀▀      ▀  ▀ ▀   ▀ ▀▀▀  ▀▀▀
  13. '
  14. '                     ██████▄ ██████▄ ▐██▌ ▄█████▄ ███████
  15. '                     ██▄▄▄██ ██   ██  ██  ██   ██   ▐█▌
  16. '                     ██▀▀▀▀  ██████   ██  ██   ██   ▐█▌
  17. '                     ██      ██  ▀██ ▐██▌ ██   ██   ▐█▌
  18. '
  19. '
  20. '     █▀▄ ╓──┐ ╥─┐  ╥──┐ ╥──┐ ╓─╥─┐      ▄▀▀ ╥──┐ ─╥─ ╥──┐ ╥──┐
  21. '     █▀▄ ║  │ ╟─┴┐ ╟─   ╟─┬┘   ║         ▀▄ ╟──┘  ║  ╟─   ╟─┬┘
  22. '     ▀ ▀ ╙──┘ ╨──┘ ╨──┘ ╨ ┴    ╨        ▀▀  ╨    ─╨─ ╨──┘ ╨ ┴
  23. '
  24. '────────────────────────────────────────────────────────────────────────────────
  25. '         ───┐ ─╖                                        ▀
  26. '         ╓──┘  ║   █▀█ █▀▄ █▀█ █▀█ █▀▄ █▀█  █▀█▀█ █▀█▀█ █ █▀█ █▀█
  27. '         ╙─── ─╨─  █▀▀ ▀   ▀▀▀ ▀▀█ ▀   ▀▀ ▀ ▀ ▀ ▀ ▀ ▀ ▀ ▀ ▀ ▀ ▀▀█
  28. ' ──────────────────────────────▀▀─────────────────────────────▀▀────────────────
  29. '
  30. '        Robert L. Spier                Internet: robert.spier@hardgood.com
  31. '        One Lookout Circle             Rime: Robert Spier -> APPLEWIZ or -> ACC
  32. '        Larchmont, NY 10538            Intelec: Robert Spier in Netchat, Programming.
  33. '
  34. '  See AnsiG.txt for more info.  Registration $20.
  35. '
  36. ' Created at a whim because the PcBoard @X.. codes were too bulky and ineficent
  37. ' this little subroutine accepts standard Powerboard Color Commands, and
  38. ' then prints the string, IN COLOR!
  39. ' In informal testing this is almost two times as fast as the PCB-ANSI @X..
  40. ' is and is easier as well.
  41. '
  42. ' If you wish to extract the normal string from a PB String use PBFilter.
  43. ' It is a simple function, and it extracts the normal string!
  44. '
  45. ' NOTE: As written PBPrint does NOT add a CRLF to the end of each line.
  46. ' Remember PRINT txt$;?  Either add it yourself, with a txt$+CHR$(13)
  47. ' or go into PBPrint and toss the semi-colon on the LAST print statement
  48. ' in the sub.  If you change other print statements you may ruin the code.
  49. '
  50. ' (c) 1993 Robert Spier
  51.  
  52. 'Demo #1:
  53. 'CLS
  54. 'a$ = "&1&1 $2$2 &3&3 $4$4 &5&5 $6$6 &7&7 $8$8 &9&9 $10$10 &11&11 $12$12 &13&13&14&14&15&15"
  55. 'PbPrint a$
  56.  
  57. 'Demo #2:
  58. 'OPEN "\PCBFILE" FOR INPUT AS 1
  59. 'DO
  60. 'LINE INPUT #1, a$
  61. 'pbprint a$
  62. 'pbprint CHR$(13)   'This line is important when you are reading files.  Could
  63.                     'be replaced with just PRINT or change the line above to:
  64.                     'pbprint a$+chr$(13)
  65. 'LOOP UNTIL EOF(1)
  66. 'CLOSE
  67.  
  68. FUNCTION PBFilter$ (FilterStr$)
  69. B$ = FilterStr$
  70. DO
  71.         'Figure out whether we are talking about Foreground or BackGround
  72.         NextInF = INSTR(B$, "&")
  73.         NextInB = INSTR(B$, "$")
  74.         IF NextInF < NextInB OR NextInB = 0 THEN
  75.                 SearchChar$ = "&"
  76.                 NextIn = NextInF
  77.         ELSE
  78.                 NextIn = NextInB
  79.                 SearchChar$ = "$"
  80.         END IF
  81.  
  82.         IF NextIn THEN
  83.                 a$ = a$ + LEFT$(B$, NextIn - 1)
  84.                 B$ = RIGHT$(B$, LEN(B$) - NextIn)
  85.                 NextIn = INSTR(B$, SearchChar$)
  86.                 B$ = RIGHT$(B$, LEN(B$) - NextIn)
  87.                 NextInF = INSTR(B$, "&")
  88.                 NextInB = INSTR(B$, "$")
  89.                 IF NextInF < NextInB OR NextInB = 0 THEN
  90.                         another = NextInF
  91.                 ELSE
  92.                         another = NextInB
  93.                 END IF
  94.                 IF another THEN
  95.                         a$ = a$ + LEFT$(B$, another - 1)
  96.                         B$ = RIGHT$(B$, LEN(B$) - another + 1)
  97.                         END IF
  98.                 ELSE
  99.                         EXIT DO
  100.                 END IF
  101. LOOP
  102.   
  103.     PBFilter$ = a$ + B$
  104.     
  105.  
  106. END FUNCTION
  107.  
  108. SUB PBPrint (B$)
  109. IF LEFT$(B$, 6) = "PBANSI" THEN B$ = RIGHT$(B$, LEN(B$) - 6) 'Just in case!
  110. DO
  111.         'Figure out whether we are talking about Foreground or BackGround  
  112.         NextInF = INSTR(B$, "&")
  113.         NextInB = INSTR(B$, "$")
  114.         IF NextInF < NextInB AND NextInF <> 0 OR NextInB = 0 THEN
  115.                 SearchChar$ = "&"
  116.                 FG = true
  117.                 NextIn = NextInF
  118.         ELSE
  119.                 NextIn = NextInB
  120.                 SearchChar$ = "$"
  121.                 FG = false
  122.         END IF
  123.  
  124.         IF NextIn THEN
  125.                 PRINT LEFT$(B$, NextIn - 1);
  126.                 B$ = RIGHT$(B$, LEN(B$) - NextIn)
  127.                 NextIn = INSTR(B$, SearchChar$)
  128.                 Form$ = MID$(B$, 1, NextIn - 1)
  129.                 t = VAL(Form$)
  130.                 IF FG = true THEN COLOR t ELSE COLOR , t
  131.                 B$ = RIGHT$(B$, LEN(B$) - NextIn)
  132.                 NextInF = INSTR(B$, "&")
  133.                 NextInB = INSTR(B$, "$")
  134.                 IF NextInF < NextInB OR NextInB = 0 THEN
  135.                         another = NextInF
  136.                 ELSE
  137.                         another = NextInB
  138.                 END IF
  139.                 IF another THEN
  140.                         PRINT LEFT$(B$, another - 1);
  141.                         B$ = RIGHT$(B$, LEN(B$) - another + 1)
  142.                         END IF
  143.                 ELSE
  144.                         EXIT DO
  145.                 END IF
  146. LOOP
  147.    
  148.     PRINT B$;
  149.  
  150. END SUB
  151.  
  152.