better yet, i have combined 2 examples.
problem is i need it to return the final$ variable instead of using text to type it so it appears in the window that tdk made.
Rem Project: textwrap
Rem Created: Monday, July 19, 2010
Rem ***** Main Source File *****
Rem Example Demo For TDK_Man's Scrolling Text Window Function
Rem Copyright TDK_Man January 2008
Rem Creates 3 On-Screen Scrolling Text Windows. User types into Window 3 And
Rem The Computer Generates Random Text In Windows 1 And 2
Dim Display$(100,6): Rem <<<<< Array required for function!!!
Dim ArrayPointer(0,6): Rem <<<<< Array required for function!!!
Dim SplitLine$(10,6): Rem <<<<< Array required for function!!!
Set Display Mode 800,600,32
Sync On: Sync Rate 0
Randomize Timer()
Rem Set Up Function Variables...
XPos1=70: XPos2=410: XPos3=240: Rem X position of scroll boxes
YPos1=50: YPos2=50: YPos3=300: Rem Y position of scroll boxes
ScrollBoxWidth = 320: Rem Width of scroll (Set to screen width for full screen)
ScrollBoxHeight = 240: Rem Height of scroll (Set to screen height for full screen)
Border = 1: Rem Set this to 0 for no border and 1 for a white border
BColour = RGB(0,30,0): Rem Text box background colour value
TColour = RGB(255,255,0): Rem Text colour value
Rem Call Function Three Times To Initialise The Three Text Windows...
text1$="print this"
ScrollPrint(1,XPos1,YPos1,ScrollBoxWidth,ScrollBoxHeight,typeWrite(text1$,screen width()/2-text width(text$)/2,screen height()/2-text height(text$)/2,24,200),BColour,TColour,Border): Rem <<<< Call this instead of Print
ScrollPrint(2,XPos2,YPos2,ScrollBoxWidth,ScrollBoxHeight,"Random Text Window 2",BColour,TColour,Border): Rem <<<< Call this instead of Print
ScrollPrint(3,XPos3,YPos3,ScrollBoxWidth,ScrollBoxHeight,"User Text Window",BColour,TColour,Border): Rem <<<< Call this instead of Print
Rem Main Loop - Including Allowing You To Add your Own Text To Text Box 3...
Do
Gosub TextBox1Input: Rem Add Random Text To Text Area 1
Gosub TextBox2Input: Rem Add Random Text To Text Area 2
Gosub UserInput: Rem Allow User To Add To Text Area 3
Sync
Loop
End
TextBox1Input:
L=Rnd(120)+40: A$ = "": LastChar$=" "
For N=1 To L
T = Rnd(36)+97
If T>122
If LastChar$<>" "
LastChar$=" "
A$ = A$ + LastChar$
Endif
Else
LastChar$=Chr$(T)
A$ = A$ + LastChar$
Endif
Next N
ScrollPrint(1,XPos1,YPos1,ScrollBoxWidth,ScrollBoxHeight,A$,BColour,TColour,Border): Rem <<<< Call this instead of Print
Return
TextBox2Input:
L=Rnd(120)+40: A$ = "": LastChar$=" "
For N=1 To L
T = Rnd(36)+97
If T>122
If LastChar$<>" "
LastChar$=" "
A$ = A$ + LastChar$
Endif
Else
LastChar$=Chr$(T)
A$ = A$ + LastChar$
Endif
Next N
ScrollPrint(2,XPos2,YPos2,ScrollBoxWidth,ScrollBoxHeight,A$,BColour,TColour,Border): Rem <<<< Call this instead of Print
Return
UserInput:
Ink 0,0: Box 0,550,799,599
Ink RGB(255,255,255),0: Set Cursor 0,570: Input "Your Own Text: ";A$
ScrollPrint(3,XPos3,YPos3,ScrollBoxWidth,ScrollBoxHeight,A$,BColour,TColour,Border): Rem <<<< Call this instead of Print
Return
Rem *****************************************************************************************
Rem ******** Functions *********
Rem *****************************************************************************************
function typeWrite(typed$ as string, xpos as integer, ypos as integer, tsize as integer, speed as integer)
set text size tsize
for i = 0 to len(typed$)
final$ = final$ + mid$(typed$,i)
wait speed+rnd(speed)
text xpos,ypos,final$
sync
if i = len(typed$)
exitfunction
ENDIF
next i
endfunction final$
Function ScrollPrint(WindowNum,XPos,YPos,ScrollBoxWidth,ScrollBoxHeight,NewLine$,BColour,TColour,Border)
Rem ******************************************************************************************
Rem Note: The following 3 Dim lines MUST be included at the start of your program
Rem before calling the function or it will result in an eror.
Rem
Rem Dim Display$(100,6): Rem Array required for function
Rem Dim ArrayPointer(0,6): Rem Array required for function
Rem Dim SplitLine$(10,6): Rem Array required for function
Rem
Rem ******************************************************************************************
TH = Text Height("A"): Numlines = (ScrollBoxHeight/TH)-2: LinesToAdd = 1
If NewLine$ <> ""
LineWidth = Text Width(NewLine$): NumChars = Len(NewLine$)
If LineWidth > ScrollBoxWidth-10
ThisLine$ = "": CharCount = 0: TotalCharCount = 0
Repeat
Inc CharCount: Inc TotalCharCount
ThisChar$ = Mid$(NewLine$,CharCount)
If ThisChar$ = " " Then LastSpace = CharCount
ThisLine$ = ThisLine$+ThisChar$
ThisLineLen = Text Width(ThisLine$)
If ThisLineLen > ScrollBoxWidth-10
SplitLine$(LinesToAdd,WindowNum)= Left$(ThisLine$,LastSpace)
NewLine$ = Right$(NewLine$,Len(NewLine$)-Len(SplitLine$(LinesToAdd,WindowNum)))
Inc LinesToAdd
CharCount = 0: ThisLine$ = "": ThisLineLen = 0
Endif
Until Text Width(NewLine$) < ScrollBoxWidth-10
SplitLine$(LinesToAdd,WindowNum) = NewLine$
Endif
If LinesToAdd = 1
If ArrayPointer(0,WindowNum) < Numlines+1
Display$(ArrayPointer(0,WindowNum),WindowNum) = NewLine$
ArrayPointer(0,WindowNum) = ArrayPointer(0,WindowNum)+1
Else
Display$(ArrayPointer(0,WindowNum),WindowNum) = NewLine$
For N = 0 To Numlines
Display$(N,WindowNum) = Display$(N+1,WindowNum)
Next N
Endif
Else
If ArrayPointer(0,WindowNum)+LinesToAdd < Numlines+1
For N=0 To LinesToAdd-1
Display$(ArrayPointer(0,WindowNum)+N,WindowNum) = SplitLine$(N+1,WindowNum)
Next N
ArrayPointer(0,WindowNum) = ArrayPointer(0,WindowNum)+LinesToAdd
Else
For N=0 To LinesToAdd-1
Display$(ArrayPointer(0,WindowNum)+N,WindowNum) = SplitLine$(N+1,WindowNum): Rem Add These Line To End Of Array
Next N
LinesToScroll = LinesToAdd-(NumLines-ArrayPointer(0,WindowNum))-1
For N = 0 To Numlines+LinesToAdd
Display$(N,WindowNum) = Display$(N+LinesToScroll,WindowNum)
Next N
ArrayPointer(0,WindowNum) = ArrayPointer(0,WindowNum)+LinesToAdd
If ArrayPointer(0,WindowNum) > Numlines+1 Then ArrayPointer(0,WindowNum) = Numlines+1
Endif
Endif
If Border = 1
Ink RGB(255,255,255),0
Box XPos,YPos,XPos+ScrollBoxWidth-1,YPos+ScrollBoxHeight-1
Endif
Ink BColour,0
Box XPos+1,YPos+1,XPos+ScrollBoxWidth-2,YPos+ScrollBoxHeight-2
Ink TColour,0
For Y = 0 To NumLines
Text XPos+4,Y*TH+YPos+2,Display$(Y,WindowNum)
Next Y
Endif
EndFunction
CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/