Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scrolling Output That Exceeds Screen Size
#10
here is a scrolling demo for reading any text or bas file that uses crlf to end lines
Code: (Select All)
_Title "Scroll file" ' b+ 2024-04-08
Width 140, 41
_ScreenMove 100, 60
pfile$ = _OpenFileDialog$("Select file to read", _CWD$, "*.bas|*.txt", "text files", 0)
If pfile$ <> "" Then
    t$ = _ReadFile$(pfile$)
    ReDim f$(1 To 1)
    Split t$, Chr$(13) + Chr$(10), f$()
    inputcount = UBound(f$)
    For n = 1 To 40
        Print f$(n)
    Next
    Do
        Do While _MouseInput
            If row >= 0 Then row = row + _MouseWheel Else row = 0 'prevent under scrolling
            If row > inputcount - 40 Then row = inputcount - 40 'prevent over scrolling
            If prevrow <> row Then 'look for a change in row value
                If row > 0 And row <= inputcount - 40 Then
                    Cls: Locate 2, 1
                    For n = row To row + 40
                        Print f$(n)
                    Next
                End If
            End If
            prevrow = row 'store previous row value
        Loop
    Loop Until InKey$ > ""
End If

' note: I buggered this twice now, FOR base 1 array REDIM MyArray (1 to 1) AS ... the (1 to 1) is not same as (1) which was the Blunder!!!
'notes: REDIM the array(0) to be loaded before calling Split '<<<< IMPORTANT dynamic array and empty, can use any lbound though
'This SUB will take a given N delimited string, and delimiter$ and create an array of N+1 strings using the LBOUND of the given dynamic array to load.
'notes: the loadMeArray() needs to be dynamic string array and will not change the LBOUND of the array it is given.  rev 2019-08-27
Sub Split (SplitMeString As String, delim As String, loadMeArray() As String)
    Dim curpos As Long, arrpos As Long, LD As Long, dpos As Long 'fix use the Lbound the array already has
    curpos = 1: arrpos = LBound(loadMeArray): LD = Len(delim)
    dpos = InStr(curpos, SplitMeString, delim)
    Do Until dpos = 0
        loadMeArray(arrpos) = Mid$(SplitMeString, curpos, dpos - curpos)
        arrpos = arrpos + 1
        If arrpos > UBound(loadMeArray) Then ReDim _Preserve loadMeArray(LBound(loadMeArray) To UBound(loadMeArray) + 1000) As String
        curpos = dpos + LD
        dpos = InStr(curpos, SplitMeString, delim)
    Loop
    loadMeArray(arrpos) = Mid$(SplitMeString, curpos)
    ReDim _Preserve loadMeArray(LBound(loadMeArray) To arrpos) As String 'get the ubound correct
End Sub

edit to increase screen size and center it better on screen
edit2 forgot to change page size
dang still finding errors, it's a starter
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Messages In This Thread
RE: Scrolling Output That Exceeds Screen Size - by bplus - 04-09-2024, 12:34 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Font Size in Threads Dimster 5 377 12-12-2025, 04:49 PM
Last Post: Dimster
  auto-detecting screen resolution for optimal window size on non-Windows systems madscijr 11 1,084 11-10-2025, 07:23 PM
Last Post: madscijr
  auto-detecting screen resolution for optimal window size on non-Windows systems madscijr 0 227 10-26-2025, 06:58 PM
Last Post: madscijr
  Make IDE $Console:Only output readably large dakra137 1 541 10-10-2025, 12:21 PM
Last Post: hsiangch_ong
  Inputting output from other languages Helium5793 8 1,321 05-30-2025, 12:30 PM
Last Post: Helium5793

Forum Jump:


Users browsing this thread: 1 Guest(s)