home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / vrac / homonlib.zip / TELETYPE.BAS < prev    next >
BASIC Source File  |  1995-04-13  |  2KB  |  41 lines

  1. DEFINT A-Z
  2.  
  3. DECLARE SUB TeleType (text$, delay)
  4.  
  5. SUB TeleType (text$, delay)
  6. '****************************************************************************
  7. 'Prints text one character at a time beginning at the current cursor location.
  8. '
  9. 'The delay between each character being printed is measured in 1/100ths of a
  10. ' second (a delay of 100 would equal one second).  If a value of zero or less
  11. ' is specified, the delay defaults to 5/100ths of a second.  If a key is
  12. ' pressed during the SUB, the remainder of the string is printed without any
  13. ' delay.
  14. '
  15. 'You could easily add some sound to this procedure.  I recommend using SOUND
  16. ' 20000,1 after each letter except spaces and a delay of at least 7.
  17. '
  18. '****************************************************************************
  19.  
  20. d! = delay                              'Convert delay from an integer to a
  21.                                         'single precision variable.
  22.  
  23. IF d! < 1 THEN d! = 5                   'Assign the default delay of 1/20th
  24.                                         'of a second (5/100).
  25.  
  26. d! = d! / 100                           'Change delay to 100ths of a second.
  27.  
  28. FOR x = 1 TO LEN(text$)                 'Print text$ one character at a time.
  29.   
  30.      PRINT MID$(text$, x, 1);
  31.   
  32.      now! = TIMER                       'Get the current value of TIMER.
  33.      WHILE TIMER < (now! + d!): WEND    'Wait for TIMER to increase by d!.
  34.   
  35.      IF INKEY$ <> "" THEN d! = 0        'If a key is pressed, stop delaying.
  36.  
  37. NEXT x
  38.  
  39. END SUB
  40.  
  41.