Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A scrolling SUB for text in SCREEN 0
#1
Hi friends
thanks to Pete (whose code I have used to go on with Text Scrolling in SCREEN 0) I have made a versatile version of the code to get a scrolling of text in a window in mode only text (SCREEN 0).
Don't scare yourself with the long list of parameters that the SUB need. It is better than using SHARED variables that made the code lesser portable towards this one that follows.

Code: (Select All)

_Title "Scrolling text in SCREEN 0 with arrow keys"
_ControlChr Off
Dim TRmin As Integer, TRmax As Integer, TCmin As Integer, TCmax As Integer ' it declares the limit of text's area
Dim CharMin As Integer, CharMax As Integer, RowMin As Integer, RowMax As Integer ' it declares the dimensions of text to be printed on the screen
TRmin = 1: TRmax = 25: TCmin = 1: TCmax = 80
CharMin = 1: CharMax = 255: RowMin = 1: RowMax = 40
Width TCmax, TRmax ' screen 0 only text 80 columns for 25 rows


Dim Row As String, Text(RowMin To RowMax) As String, cText(CharMin To CharMax, RowMin To RowMax) As Integer
Dim a As Integer, b As Integer, R As Integer, C As Integer

' initialization

' it builds a string of 255 characters
For a = CharMin To CharMax
    Row = Row + Chr$(a)
Next a
' it builds  40 rows of 255 characters for row
For a = RowMin To RowMax
    Text(a) = Right$(Row, a + 10) + Left$(Row, CharMax - a - 10)
    For b = CharMin To CharMax
        cText(b, a) = (b * a) Mod 7
    Next b
Next a
' here it sets row and column at the start
R = 1
C = 1
PrintTxt TRmin, TRmax, TCmin, TCmax, CharMin, CharMax, RowMin, RowMax, R, C, Text(), cText(), 0
While -1
    _Limit 30
    Row = UCase$(InKey$)
    If Len(Row) = 2 Then
        Select Case InStr("HPKM", Mid$(Row, 2, 1))
            Case 1: R = R - 1
                PrintTxt TRmin, TRmax, TCmin, TCmax, CharMin, CharMax, RowMin, RowMax, R, C, Text(), cText(), 0
            Case 2: R = R + 1
                PrintTxt TRmin, TRmax, TCmin, TCmax, CharMin, CharMax, RowMin, RowMax, R, C, Text(), cText(), 0
            Case 3: C = C - 1
                PrintTxt TRmin, TRmax, TCmin, TCmax, CharMin, CharMax, RowMin, RowMax, R, C, Text(), cText(), 0
            Case 4: C = C + 1
                PrintTxt TRmin, TRmax, TCmin, TCmax, CharMin, CharMax, RowMin, RowMax, R, C, Text(), cText(), 0
        End Select
    End If
    _Display
Wend
End

Sub PrintTxt (TRm As Integer, TRmx As Integer, TCm As Integer, TCmx As Integer, Cm As Integer, Cmx As Integer, Rm As Integer, Rmx As Integer, Ra As Integer, Ca As Integer, T() As String, cT() As Integer, Bc As Integer)
    ' TRm text row min, TRmx text row max, TCm text column min, TCmx text column max, Cm char min, Cmx char max
    ' Rm row min, Rmx row max, Ra row actual, Ca column actual, T() text,cT() color text, Bc background color
    Cls , Bc
    For a = TRm - 1 To TRmx - 1
        Locate a + 1, TCm
        If (a + Ra) < Rmx + 1 And (a + Ra) > Rm - 1 Then
            For b = TCm To TCmx
                If (Ca + b - 1 < Cmx + 1) And (Ca + b - 1 > Cm - 1) Then
                    Color , cT(Ca + b - 1, a + Ra)
                    Print Mid$(T(a + Ra), Ca + b - 1, 1);
                Else
                    Color , Bc
                    Print " ";
                End If
            Next b
        End If
    Next
End Sub

the code is still that of Pete, but changing the parameters of rows of the window and/or of columns of the window you get the same behaviour of the text in the window...
here 2 screenschots after changing the rows or the columns of the window.


[Image: Different-rows-in-screen-0-Immagine-2024...014952.jpg]


[Image: different-columns-in-screen-0-Immagine-2...015646.jpg]

if do you find it interesting, it is possible to build a demonstration that manages different text area in the same window of text in Screen 0.
Thanks for feedbacks
Reply


Messages In This Thread
A scrolling SUB for text in SCREEN 0 - by TempodiBasic - 12-07-2024, 01:48 AM



Users browsing this thread: 2 Guest(s)