home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / blind / blindin.bas
BASIC Source File  |  1992-11-09  |  4KB  |  140 lines

  1. DEFINT A-Z
  2.  
  3. '-------------------
  4. '   BLINDIN.BAS
  5. '-------------------
  6. '   To demonstrate a SUB that sends CHR$(176) to the screen instead
  7. '   of the key strokes entered by the operator -- as in the entry of
  8. '   a password, or any situation when what the operator is typing
  9. '   should not appear on the screen.
  10. '
  11. '   This sub is distributed as Shareware, wherein you can "Try Before
  12. '   You Buy."  You are welcome to use the program for any period you
  13. '   feel appropriate to "Evaluate" it.  (Even make copies and give to
  14. '   colleagues, provided you don't change anything or eliminate this
  15. '   explanatory message.
  16. '
  17. '   If you decide to really make use of this routine, you should
  18. '   register it with the author....
  19. '
  20. 'Kirk Woodward ∙ d/b/a People Centered Programs We accept Visa and MasterCard
  21. '  PO Box 610171 ∙ Dallas, TX 75261-0171 ∙ 817-488-4940  FAX: 817-488-4945
  22. '
  23. '   Your registration fee of $10 will bring you the current version of
  24. '   this routine AND a special BONUS SUB that you will find useful at
  25. '   no additional charge.
  26.  
  27. DECLARE SUB BlindEnter (EnteredString$, Eline, Ecol)
  28.  
  29.     CLS
  30.     SLEEP 1
  31.  
  32.     EnteredString$ = SPACE$(15)
  33.     BlindEnter EnteredString$, 10, 35
  34.  
  35.     LOCATE 12, 17
  36.     COLOR 7, 0
  37.     PRINT "Operator Entered: ";
  38.     COLOR 15, 0
  39.     PRINT EnteredString$
  40.  
  41.     LOCATE 15, 15
  42.     COLOR 14, 0
  43.     PRINT "Any key re-runs the demo, ESC ends the demo."
  44.     x$ = INPUT$(1)
  45.  
  46.     IF x$ <> CHR$(27) THEN RUN "blindin.bas"
  47.  
  48.     CLS
  49.  
  50.     OPEN "blindin.bas" FOR INPUT AS #1
  51.     LINE INPUT #1, CommentLine$
  52.     LINE INPUT #1, CommentLine$
  53.     LINE INPUT #1, CommentLine$
  54.     FOR x = 1 TO 22
  55.         LINE INPUT #1, CommentLine$
  56.         PRINT CommentLine$
  57.     NEXT
  58.     
  59.     END
  60.  
  61. SUB BlindEnter (EnteredString$, Eline, Ecol)
  62.  
  63.     '   Where:  EnteredString$   =  The "real" keystrokes operator made.
  64.     '           Eline            =  The Line where the data is entered
  65.     '           Ecol             =  The column where the data is entered
  66.     '
  67.     '   The SUB expects, at entry, for the EnteredString$ to be filled
  68.     '   with spaces in order to set the maximum length of the field.
  69.     '
  70.     '   CHR$(176) = ░ is displayed in place of the actual key stroke
  71.     '   but can be changed to anything you like in the code below.
  72.     '
  73.     '   There is NO error checking to determine if the field can be
  74.     '   be displayed properly.
  75.     '
  76.     '   The only `editing' key that is accepted is the backspace key.
  77.  
  78.     LOCATE Eline - 1, 1
  79.     PRINT "Enter some data . . ."
  80.     LOCATE Eline, Ecol
  81.     COLOR 0, 7                         '    print black on white
  82.     PRINT EnteredString$
  83.     FieldLength = LEN(EnteredString$)
  84.     EnteredString$ = ""
  85.     
  86.     DO
  87.  
  88.         DO
  89.             K$ = INKEY$
  90.         LOOP UNTIL K$ > ""
  91.  
  92.         K$ = UCASE$(K$)
  93.  
  94.  
  95.         SELECT CASE K$
  96.  
  97.             CASE CHR$(13)       ' enter key pressed
  98.                 EXIT SUB
  99.  
  100.             '   It is within
  101.             '   this block that you could make further constraints on
  102.             '   on what would be accepted by the routine.  As written
  103.             '   everything above CHR$(31) is accepted.
  104.             '
  105.             '   If you plan extensive use of this routine (more than
  106.             '   just a few keystrokes) you will likely want to make
  107.             '   provision for the routine to deal with more editing
  108.             '   keys than just the backspace key.
  109.  
  110.             CASE CHR$(8)       '  backspace key was pressed
  111.  
  112.                     IF LEN(DisplayString$) >= 1 THEN
  113.                         DisplayString$ = LEFT$(DisplayString$, LEN(DisplayString$) - 1)
  114.                         EnteredString$ = LEFT$(EnteredString$, LEN(EnteredString$) - 1)
  115.                     ELSE
  116.                         BEEP
  117.                     END IF
  118.  
  119.             CASE ELSE
  120.                 IF K$ >= CHR$(32) THEN
  121.                     EnteredString$ = EnteredString$ + K$
  122.                     DisplayString$ = DisplayString$ + CHR$(176)
  123.                 ELSE
  124.                     BEEP
  125.                 END IF
  126.  
  127.         END SELECT
  128.  
  129.         LOCATE Eline, Ecol: PRINT SPACE$(FieldLength)
  130.         LOCATE Eline, Ecol: PRINT DisplayString$
  131.         IF LEN(EnteredString$) = FieldLength THEN EXIT SUB
  132.  
  133.     LOOP
  134.  
  135.  
  136.     
  137.  
  138. END SUB
  139.  
  140.