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

  1. DEFINT A-Z
  2.  
  3. DECLARE SUB Spread (text$, row, col, delay)
  4.  
  5. SUB Spread (text$, row, col, delay)
  6. '****************************************************************************
  7. 'Spreads text on the screen in both directions starting from the specified
  8. 'coordinates.  Delay is measured in 100ths of a second.
  9. '****************************************************************************
  10.  
  11. d! = delay                              'Convert delay from an integer to a
  12.                                         'single precision variable.
  13.  
  14. IF d! < 1 THEN d! = 5                   'Assign the default delay of 1/20th
  15.                                         'of a second (5/100).
  16.  
  17. d! = d! / 100                           'Change delay to 100ths of a second.
  18.  
  19. IF text$ = "" THEN EXIT SUB             'Quit if text$ is a null string.
  20.  
  21. txt$ = text$                            'Use a temp variable to modify text$.
  22.  
  23. IF LEN(txt$) MOD 2 = 1 THEN             'If the length of text$ is not even,
  24.      txt$ = txt$ + " "                  'add a space to make it even.
  25. END IF
  26.  
  27. lt$ = LEFT$(txt$, LEN(txt$) \ 2)        'Break it into left & right sides.
  28. rt$ = RIGHT$(txt$, LEN(txt$) \ 2)
  29.  
  30. FOR x = 1 TO LEN(rt$)                   'Could also use lt$, they're equal.
  31.  
  32.      LOCATE row, col                    'Print a letter from the right side.
  33.      PRINT RIGHT$(rt$, x);
  34.   
  35.      IF (col - x) >= 1 THEN             'Only print the left side while the
  36.                                         'value of column is still valid.
  37.           LOCATE row, col - x
  38.           PRINT LEFT$(lt$, x);          'Print a letter from the left side.
  39.      END IF
  40.  
  41.      now! = TIMER                       'Get current value of TIMER.
  42.      WHILE TIMER < (now! + d!): WEND    'Wait for timer to increase by d!
  43.  
  44.      IF INKEY$ <> "" THEN d! = 0        'If a key is pressed, stop delaying.
  45.  
  46. NEXT x
  47.  
  48. END SUB
  49.  
  50.