home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_BAS / PBTCLASS.ZIP / PHBK.BAS < prev    next >
BASIC Source File  |  1994-02-08  |  5KB  |  216 lines

  1. $CPU 8086
  2. $LIB ALL OFF
  3. $ERROR ALL OFF
  4. $OPTIMIZE SIZE
  5. $COMPILE EXE
  6.  
  7. $INCLUDE "PBTCLASS.DEC"
  8.  
  9. InitPBScreen
  10.  
  11. DIM Temp$(1:1000), L$(8), LL$$(8)
  12. MAP Tmp$$ * 320, 40 AS LL$$(1), 40 AS LL$$(2), 40 AS LL$$(3), 40 AS LL$$(4),_
  13.     40 AS LL$$(5), 40 AS LL$$(6), 40 AS LL$$(7), 40 as LL$$(8)
  14.  
  15. Xpos = POS(0)
  16. Ypos = CSRLIN
  17.  
  18. Ver$ = "v3.01"
  19.  
  20. Fil$ = COMMAND$
  21. IF Fil$ = "" THEN Fil$ = "PHBK.DAT"
  22. IF DIR$(Fil$) = "" THEN
  23.   OPEN "O", 1, Fil$:
  24.   PRINT #1, SPACE$(321)
  25.   CLOSE #1
  26. END IF
  27.  
  28. OPEN "B", 1, Fil$
  29.   K = (LOF(1)-1)/320
  30.   FOR I = 0 TO K-1
  31.     SEEK 1, I*320
  32.     GET$ 1, 320, Temp$(I+1)
  33.   NEXT I
  34. CLOSE
  35.  
  36. SkipIt:
  37. FOR I = 1 TO K-1
  38.   Temp$(I) = MID$(Temp$(I), 2)+LEFT$(Temp$(I+1), 1)
  39. NEXT I
  40.  
  41. Temp$(K) = MID$(Temp$(K), 2)+" "
  42. CLR$ = SPACE$(47)
  43.  
  44. OpenWin 7, 17, 12, 50, 1, Attr(14, 4), Attr(15, 1), 3, 1, 0
  45. WPrintC 2, "PHBK "+Ver$, 0
  46. WPrintC 4, "Command Line Phone Book", 0
  47. WPrintC 5, "(c) Copyright 1991, 93 by Dave Navarro,  Jr.", 0
  48. WPrintC 6, "All Rights Reserved", 0
  49. WPrintC 9, "Written using PBTools:Classic 1.32", 0
  50. SLEEP 3
  51. ClearWin
  52. WPrint 1, 2, "Name", Attr(14, 1)
  53. WPrint 2, 2, "Addr", Attr(14, 1)
  54. WPrint 5, 2, "Phone", Attr(14, 1)
  55. WPrint 6, 2, "Notes", Attr(14, 1)
  56. WPrint 9, 2, STRING$(46, "─"), Attr(14, 1)
  57. COLOR 15, 1
  58. Current = 1
  59.  
  60. Cur:
  61.   Tmp$$ = Temp$(Current)
  62.   GOSUB Display
  63.   WPrint 10, 1, CLR$, Attr(14, 1)
  64.   WPrintC 10, "F1-New  F2-Edit  F3-Del  F4-Search  F5-Print ", Attr(14, 1)
  65.   Title 1, Attr(14, 4), "["+STR$(Current)+" of"+STR$(K)+" ]───"
  66.  
  67. GetAKey:
  68.   I$ = GetKey$
  69.   IF I$ = CHR$(27) THEN Quit
  70.   IF I$ = CHR$(0, 81) THEN PgDn
  71.   IF I$ = CHR$(0, 73) THEN PgUp
  72.   IF I$ = CHR$(0, 59) THEN New
  73.   IF I$ = CHR$(0, 63) THEN PrinLab
  74.   IF I$ = CHR$(0, 60) THEN EdLab
  75.   IF I$ = CHR$(0, 62) THEN Strt = 1:GOTO Search
  76.   IF I$ = CHR$(0, 61) THEN DelRec
  77.   GOTO GetAKey
  78.  
  79. PrinLab:
  80.   LPRINT " "+LL$$(1)
  81.   LPRINT " "+LL$$(2)
  82.   LPRINT " "+LL$$(3)
  83.   LPRINT " "+LL$$(4)
  84.   LPRINT
  85.   LPRINT
  86.   GOTO Cur
  87.  
  88. DelRec:
  89.   WPrint 10, 1, CLR$, Attr(14, 1)
  90.   WPrintC 10, "Press ENTER to delete,  ESC to abort", Attr(14, 1)
  91.   KeyLoop:
  92.     I$ = GetKey$
  93.     IF I$ = CHR$(27) THEN Cur
  94.     IF I$<>CHR$(13) THEN KeyLoop
  95.     ARRAY DELETE Temp$(Current)
  96.     DECR K
  97.     IF Current>K THEN Current = 1
  98.     GOTO SaveIt
  99.  
  100. Search:
  101.   WPrint 10, 1, CLR$, Attr(14, 1)
  102.   WPrint 10, 2, "Find: ", Attr(14, 1)
  103.   T$ = CHR$(13)+CHR$(27):IF Sch$ = "" THEN Sch$ = SPACE$(40)
  104.   TextEd Ypos(1)+10, Xpos(1)+10, 0, Attr(15, 1), Attr(15, 1), Sch$, T$
  105.   IF T$ = CHR$(27) THEN Cur
  106.   Look:
  107.     FOR I = Strt TO K
  108.       IF INSTR(UCASE$(Temp$(I)), UCASE$(Trim$(Sch$))) THEN Skip
  109.     NEXT I
  110.     WPrint 10, 1, CLR$, Attr(14, 1)
  111.     WPrintC 10, "All Records Searched", Attr(14, 1)
  112.     DELAY 2
  113.     GOTO Cur
  114.     Skip:
  115.       Tmp$$ = Temp$(I)
  116.       GOSUB Display
  117.       Strt = I+1:Current = Strt-1
  118.       Title 1, Attr(14, 4), "["+STR$(Current)+" of"+STR$(K)+" ]───"
  119.       WPrint 10, 1, CLR$, Attr(14, 1)
  120.       WPrintC 10, "Press ENTER to continue,  ESC to END", Attr(14, 1)
  121.       GetAKee:
  122.         I$ = GetKey$
  123.         IF I$ = CHR$(27) THEN Cur
  124.         IF I$<>CHR$(13) THEN GetAKee
  125.         GOTO Look
  126.  
  127. SaveIt:
  128.   WPrint 10, 1, CLR$, Attr(14, 1)
  129.   WPrintC 10, "Saving:"+Fil$, Attr(14, 1)
  130.   OPEN "O", 1, Fil$
  131.   IF K<256 THEN PRINT#1,  CHR$(K); ELSE  PRINT#1,  CHR$(255);
  132.   FOR I = 1 TO K
  133.     PRINT #1, Temp$(I);
  134.   NEXT I
  135.   CLOSE
  136.   GOTO Cur
  137.  
  138. New:
  139.   WPrint 10, 1, CLR$, Attr(14, 1)
  140.   WPrintC 10, "Press F1 to validate entry", Attr(14, 1)
  141.   Title 1, Attr(14, 4), "["+STR$(K+1)+" of"+STR$(K)+" ]───"
  142.   Tmp$$ = SPACE$(320)
  143.   Cpos = 0
  144.   GOSUB Display
  145.   TL = 1
  146.   WHILE TL<>-1
  147.     GOSUB GetInput
  148.   WEND
  149.   Validate:
  150.     L$ = ""
  151.     FOR X = 1 TO 8
  152.       L$ = L$+L$(X)
  153.     NEXT
  154.     IF L$ = SPACE$(320) THEN Cur
  155.     INCR K
  156.     Temp$(K) = L$
  157.     ARRAY SORT Temp$(1) FOR K
  158.     FOR Current = 1 TO K
  159.       IF Temp$(Current)<>L$ THEN NEXT Current
  160.     GOTO SaveIt
  161.  
  162. EdLab:
  163.   WPrint 10, 1, CLR$, Attr(14, 1)
  164.   WPrintC 10, "Press F1 to validate entry", Attr(14, 1)
  165.   Cpos = 0
  166.   GOSUB Display
  167.   TL = 1
  168.   Ed = 1
  169.   WHILE TL<>-1
  170.     GOSUB GetInput
  171.   WEND
  172.   Validate2:
  173.     L$ = ""
  174.     FOR X = 1 TO 8
  175.       L$ = L$+L$(X)
  176.     NEXT
  177.     Temp$(Current) = L$
  178.     GOTO SaveIt
  179.  
  180. PgUp:
  181.   DECR Current
  182.   IF Current<1 THEN Current = K
  183.   GOTO Cur
  184.  
  185. PgDn:
  186.   INCR Current
  187.   IF Current>K THEN Current = 1
  188.   GOTO Cur
  189.  
  190. Quit:
  191.   CloseWin
  192.   COLOR 7, 0
  193.   LOCATE Ypos, Xpos, 0
  194.   PRINT "PHBK "+Ver$+" ■ Command Line Phone Book"
  195.   PRINT "(c) Copyright 1991,93 by Dave Navarro, Jr."
  196.   END
  197.  
  198. Display:
  199.   FOR X = 1 TO 8
  200.     L$(X) = LL$$(X)
  201.     WPrint X, 8, L$(X), Attr(15, 1)
  202.   NEXT
  203.   RETURN
  204.  
  205. GetInput:
  206.   TextEd TL+7, 27, Cpos, Attr(15, 1), 0, L$(TL), T$
  207.   IF T$ = CHR$(27) THEN RETURN Cur
  208.   IF T$ = CHR$(0, 59) THEN TL = -1:RETURN
  209.   IF T$ = CHR$(13) THEN Cpos = 0:INCR TL
  210.   IF T$ = CHR$(8) THEN MID$(L$(TL-1), 40, 1) = " ":Cpos = 39:DECR TL
  211.   IF T$ = CHR$(0, 72) THEN DECR TL
  212.   IF T$ = CHR$(0, 75) THEN CPos = 39:DECR TL
  213.   IF T$ = CHR$(0, 77) THEN Cpos = 0:INCR TL
  214.   IF T$ = CHR$(0, 80) THEN INCR TL
  215.   IF TL>8 THEN TL = 1 ELSE IF TL<1 THEN TL = 8
  216.   RETURN