'===========================================================================
' Subject: VARIOUS TEXT ROUTINES              Date: 09-26-98 (17:29)       
'  Author: Alexander Meyer                    Code: QB, QBasic, PDS        
'  Origin: Meyer.Karl@t-online.de           Packet: TEXT.ABC
'===========================================================================
'                             ////
'                           0(o o)0
'-------------------------ooO (_) Ooo---------------------
' VARIOUS.BAS -- Written in QuickBasic 4.5
'
' Name: Various text routines
' Author: Alexander Meyer
' Date: 09-26-1998
' Description: Various text routines in SCREEN 0
'
'For questions or comments mail to: Meyer.Karl@t-online.de
'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

DECLARE SUB PressKey (Text$, x!, y!, Delay!)
DECLARE SUB CaseColour (Text$, x!, y!)
DECLARE SUB ColourText (Text$, x!, y!)
DECLARE SUB UpCaseLowCase (Text$, x!, y!, Colour!)
DECLARE SUB SchiebTextRueck (Text$, x, y, Bis, Farbe, Delay)
DECLARE SUB SchiebTextVor (Text$, x, y, Bis, Farbe, Delay)
DECLARE SUB SlowText (Text$, Colour, Row, Col, Delay)

'** This program maybe runs too fast on Pentium
' slow it down by changing the delays **

SCREEN 0
CLS
CALL SchiebTextRueck("Various Text", 2, 60, 26, 12, 200)
CALL SchiebTextVor("Routines", 3, 1, 35, 15, 200)
CALL SlowText("Made by Alexander Meyer", 14, 7, 1, 500)
CALL UpCaseLowCase("Hello World!", 9, 1, 12)
CALL ColourText("This is a nice demo", 11, 1)
CALL CaseColour("Hope you like it!", 13, 30)
CALL PressKey("Press any key to continue", 15, 1, 400)
END

SUB CaseColour (Text$, x, y)
  RANDOMIZE TIMER
  FOR i% = 1 TO LEN(Text$)
    TextCase = INT(RND * 2)
    IF TextCase = 0 THEN Char$ = UCASE$(MID$(Text$, i%, 1))
    IF TextCase = 1 THEN Char$ = LCASE$(MID$(Text$, i%, 1))
    Colour = INT(RND * 15 + 1)
    c% = i% + (y - 1)
    LOCATE x, c%: COLOR Colour
    PRINT Char$
  NEXT i%
END SUB

SUB ColourText (Text$, x, y)
  RANDOMIZE TIMER
  FOR i% = 1 TO LEN(Text$)
    Colour = INT(RND * 15 + 1)
    c% = i% + (y - 1)
    LOCATE x, c%: COLOR Colour
    PRINT MID$(Text$, i%, 1)
  NEXT i%
END SUB

SUB PressKey (Text$, x, y, Delay)
  RANDOMIZE TIMER
  DO
  FOR a = 1 TO 2
    FOR i% = 1 TO LEN(Text$)
      TextCase = INT(RND * 2)
      IF TextCase = 0 THEN Char$ = UCASE$(MID$(Text$, i%, 1))
      IF TextCase = 1 THEN Char$ = LCASE$(MID$(Text$, i%, 1))
      Colour = INT(RND * 15 + 1)
      c% = i% + (y - 1)
      LOCATE x, c%: COLOR Colour
      PRINT Char$
      FOR z = 1 TO Delay
        IF INKEY$ <> "" THEN GOTO TheEnd
      NEXT z
    NEXT i%
  NEXT a
  FOR b = 1 TO 15
    COLOR b
    LOCATE x, y: PRINT Text$
    FOR z = 1 TO Delay
      IF INKEY$ <> "" THEN GOTO TheEnd
    NEXT z
  NEXT b
  LOOP WHILE INKEY$ = ""
TheEnd:
END SUB

SUB SchiebTextRueck (Text$, x, y, Bis, Farbe, Delay)
COLOR Farbe
FOR i% = 1 TO Bis
  LOCATE x, y
  PRINT Text$
  FOR z = 1 TO Delay: NEXT z
  LOCATE x, y + LEN(Text$) - 1
  PRINT " "
  y = y - 1
NEXT i%
LOCATE x, y: PRINT Text$
END SUB

SUB SchiebTextVor (Text$, x, y, Bis, Farbe, Delay)
COLOR Farbe
FOR i% = 1 TO Bis
  LOCATE x, y
  PRINT Text$
  FOR z = 1 TO Delay: NEXT z
  LOCATE x, y
  PRINT " "
  y = y + 1
NEXT i%
LOCATE x, y: PRINT Text$
END SUB

SUB SlowText (Text$, Colour, Row, Col, Delay)
COLOR Colour
FOR i% = 1 TO LEN(Text$)
  LOCATE Row, i% + (Col - 1)
  PRINT MID$(Text$, i%, 1)
  FOR z = 1 TO Delay: NEXT z
  SOUND 50, .1
NEXT i%
END SUB

SUB UpCaseLowCase (Text$, x, y, Colour)
  RANDOMIZE TIMER
  FOR i% = 1 TO LEN(Text$)
    TextCase = INT(RND * 2)
    IF TextCase = 0 THEN Char$ = UCASE$(MID$(Text$, i%, 1))
    IF TextCase = 1 THEN Char$ = LCASE$(MID$(Text$, i%, 1))
    c% = i% + (y - 1)
    LOCATE x, c%: COLOR Colour
    PRINT Char$
  NEXT i%
END SUB
