LoginLogin

Appearing Text, letter by letter, without CLS

Root / Submissions / [.]

Stefano_LassandroCreated:
A very simple way to make a text appear, letter by letter. There other ways to do the same thing, but this is without CLS, that can lead to the disappearance of other texts.
TEXT$="Test"
P$=0
V=0
WHILE LEN(TEXT$)>V
 A$=MID$(TEXT$,V,1)
 P$=P$+A$
LOCATE 0,0:PRINT P$
 V=V+1
WAIT 5'This delay changes the speed of the text.
WEND
You can use this multiple times simply by copying it! Hope this can be useful : )

Since you're using WAIT, I think it's safe to assume no other code is running when this is called
DEF SLOWPRINT TEXT$, DELAY%, SKIPWS
 VAR I%, C$
 VAR L% = LEN(TEXT$)-1

 FOR I%=0 TO L%
  C$ = TEXT$[I%]
  ?C$; '? = PRINT, ; = no newline
  'skip delay on whitespace
  IF C$<=" "*SKIPWS THEN @no_delay
   WAIT DELAY%
  @no_delay
 NEXT
END

SLOWPRINT "Test", 5, FALSE

Replying to:Yolkai
Since you're using WAIT, I think it's safe to assume no other code is running when this is called
DEF SLOWPRINT TEXT$, DELAY%, SKIPWS
 VAR I%, C$
 VAR L% = LEN(TEXT$)-1

 FOR I%=0 TO L%
  C$ = TEXT$[I%]
  ?C$; '? = PRINT, ; = no newline
  'skip delay on whitespace
  IF C$<=" "*SKIPWS THEN @no_delay
   WAIT DELAY%
  @no_delay
 NEXT
END

SLOWPRINT "Test", 5, FALSE
Please check this code, it is buged. In best case (with correct lines end End after Return) it will only show: [folder]OK without printing Thanks for update. (I still dont know, why
C$ = TEXT$[I%]
is working without using MID$

Replying to:Yolkai
Since you're using WAIT, I think it's safe to assume no other code is running when this is called
DEF SLOWPRINT TEXT$, DELAY%, SKIPWS
 VAR I%, C$
 VAR L% = LEN(TEXT$)-1

 FOR I%=0 TO L%
  C$ = TEXT$[I%]
  ?C$; '? = PRINT, ; = no newline
  'skip delay on whitespace
  IF C$<=" "*SKIPWS THEN @no_delay
   WAIT DELAY%
  @no_delay
 NEXT
END

SLOWPRINT "Test", 5, FALSE
Sorry about that; ?P$; -> ?C$; corrected

Replying to:Yolkai
Since you're using WAIT, I think it's safe to assume no other code is running when this is called
DEF SLOWPRINT TEXT$, DELAY%, SKIPWS
 VAR I%, C$
 VAR L% = LEN(TEXT$)-1

 FOR I%=0 TO L%
  C$ = TEXT$[I%]
  ?C$; '? = PRINT, ; = no newline
  'skip delay on whitespace
  IF C$<=" "*SKIPWS THEN @no_delay
   WAIT DELAY%
  @no_delay
 NEXT
END

SLOWPRINT "Test", 5, FALSE
Thank you

Replying to:Yolkai
Since you're using WAIT, I think it's safe to assume no other code is running when this is called
DEF SLOWPRINT TEXT$, DELAY%, SKIPWS
 VAR I%, C$
 VAR L% = LEN(TEXT$)-1

 FOR I%=0 TO L%
  C$ = TEXT$[I%]
  ?C$; '? = PRINT, ; = no newline
  'skip delay on whitespace
  IF C$<=" "*SKIPWS THEN @no_delay
   WAIT DELAY%
  @no_delay
 NEXT
END

SLOWPRINT "Test", 5, FALSE
In many languages, strings are just char arrays or a thin wrapper over an array. In SmileBASIC, they are distinct, but for convenience, some array operations are extended to work on strings, including PUSH, POP, UNSHIFT, SHIFT Additionally, the array subscript operator [ ] is defined for strings: 1. Consider the string T$ 2. Let MID$(T$,i,n) denote the substring starting at position i and ending n characters later in T$ 3. Then MID$(T$,i,1) is the ith symbol of string T$ and 4. is equivalent to the notation T$[i] for 0 ≤ i < LEN(T$) For i < 0, MID$() is undefined and throws Out of range, and T$[i] throws Subscript out of range For iLEN(T$), MID$() returns the empty string (as for any part of a substring past the string length), and T$[i] throws Subscript out of range T$[i] is a valid left-hand side. Let T$ be a string with a length n > 0, Let S$ be an arbitrary string with length m, Then
T$[i] = S$
is
T$=MID$(T$,0,i) + S$ + MID$(T$,i+1,n-i)
or T$0,...,T$i-1, S$0,...,S$m-1, T$i+1,...,T$n-1 So for T$="ABCDEF"
T$[3] = "WWW"
'T$ == "ABCWWWEF"
and
T$[3] = "" 
'T$ == "ABCEF"

Replying to:Yolkai
Since you're using WAIT, I think it's safe to assume no other code is running when this is called
DEF SLOWPRINT TEXT$, DELAY%, SKIPWS
 VAR I%, C$
 VAR L% = LEN(TEXT$)-1

 FOR I%=0 TO L%
  C$ = TEXT$[I%]
  ?C$; '? = PRINT, ; = no newline
  'skip delay on whitespace
  IF C$<=" "*SKIPWS THEN @no_delay
   WAIT DELAY%
  @no_delay
 NEXT
END

SLOWPRINT "Test", 5, FALSE
Thank's for your update Yttria. It's realy interessting and good to know. (That can make code much smaler.)