NinJA999:
Are you using the 2007 download of DBC? I had to switch from using it and go back to the previous version I was using for exactly that reason.
If not, use Sync because the problem is down to you not using it.
All:
I found my Scrolling Text Box function!!
The Function:
Function ScrollPrint(XPos,YPos,ScrollBoxWidth,ScrollBoxHeight,NewLine$,R,G,B,Border)
TextHeight = Text Height("A")
Numlines = ScrollBoxHeight/TextHeight+1: Rem Number of lines to print before scrolling takes place
If NewLine$ <> ""
If LineCount(0) < Numlines
LineCount(0) = LineCount(0)+1
If LineCount(0) > Numlines Then LineCount(0) = Numlines
Endif
ActLine = LineCount(0)
If ActLine < Numlines
Rem Free Array Slots Available...
Display$(ActLine) = NewLine$
Else
Rem Array Full...
For Q = 1 To Numlines-2
Display$(Q) = Display$(Q+1)
Next Q
Display$(Numlines-1) = NewLine$
Endif
If Border = 1
Ink RGB(255,255,255),0: Rem Border line colour
Box XPos,YPos,XPos+ScrollBoxWidth-1,YPos+ScrollBoxHeight-1
Endif
Ink RGB(R,G,B),0: Rem Set to text box background colour
Box XPos+1,YPos+1,XPos+ScrollBoxWidth-2,YPos+ScrollBoxHeight-2
Ink RGB(255,255,255),0: Rem Text colour
For Y = 0 To NumLines-1
Text XPos+2,Y*TextHeight+YPos,Display$(Y+1)
Next Y
Sync
Endif
EndFunction
It's fairly straight forward and works regardless of font face and size used.
Parameters:
XPos,YPos - Screen position of top left corner of text box
ScrollBoxWidth,ScrollBoxHeight - Width and Height of box
NewLine$ - Text to print
R,G,B - Background colour of text box
Border - 0 for no border and 1 for a border around text box
Important!
You MUST include the two following DIM statements at the top of your program:
Dim Display$(100): Rem Array required for function
Dim LineCount(0): Rem Array required for function
Example Usage Demo Program:
Dim Display$(100): Rem Array required for function
Dim LineCount(0): Rem Array required for function
Set Display Mode 640,480,16
Sync On: Sync Rate 0: CLS 0
Rem ******************************************************************
Rem If you need a different font/font size, unrem and alter lines here
Rem Set Text Font "Courier New"
Rem Set Text Size 12
Rem ******************************************************************
XPos=0: Rem X position of scroll box on screen
YPos=0: Rem Y position of scroll box on screen
ScrollBoxWidth = 640: Rem Width of scroll (Set to screen width for full screen)
ScrollBoxHeight = 480: Rem Height of scroll (Set to screen height for full screen)
Border = 0: Rem Set this to 0 for no border and 1 for a white border
R = 0: G = 0: B = 0: Rem Text box background colour RGB values
For A=1 To 100
NewLine$="Example Line Of Text "+Str$(A)
ScrollPrint(XPos,YPos,ScrollBoxWidth,ScrollBoxHeight,NewLine$,R,G,B,Border): Rem <<<< Call this instead of Print
Sleep 40
Next A
End
Function ScrollPrint(XPos,YPos,ScrollBoxWidth,ScrollBoxHeight,NewLine$,R,G,B,Border)
TextHeight = Text Height("A")
Numlines = ScrollBoxHeight/TextHeight+1: Rem Number of lines to print before scrolling takes place
If NewLine$ <> ""
If LineCount(0) < Numlines
LineCount(0) = LineCount(0)+1
If LineCount(0) > Numlines Then LineCount(0) = Numlines
Endif
ActLine = LineCount(0)
If ActLine < Numlines
Rem Free Array Slots Available...
Display$(ActLine) = NewLine$
Else
Rem Array Full...
For Q = 1 To Numlines-2
Display$(Q) = Display$(Q+1)
Next Q
Display$(Numlines-1) = NewLine$
Endif
If Border = 1
Ink RGB(255,255,255),0: Rem Border line colour
Box XPos,YPos,XPos+ScrollBoxWidth-1,YPos+ScrollBoxHeight-1
Endif
Ink RGB(R,G,B),0: Rem Set to text box background colour
Box XPos+1,YPos+1,XPos+ScrollBoxWidth-2,YPos+ScrollBoxHeight-2
Ink RGB(255,255,255),0: Rem Text colour
For Y = 0 To NumLines-1
Text XPos+2,Y*TextHeight+YPos,Display$(Y+1)
Next Y
Sync
Endif
EndFunction
The text scrolling box can be any size and placed anywhere on the screen. It does not word wrap, so the length of the text sent to the function must not be longer than what can fit in the box.
It caters for any size of text and any font.
Might be worth me posting this on the code snippets board again seeing as the original doesn't show up in a search...
TDK_Man