Posts: 34
Threads: 4
Joined: Apr 2022
Reputation:
0
I have been trying to figure out how to do this, scroll program output when it fills more than one screenful , but I have had no luck so far. I am currently working on Lesson 4 of Terry's Tutorial. Some example programs, as well as my own experiments, use a lot more screen length than just one. For example, one of the example programs counts to 100 (from whatever starting point you give it); I would like to be able to see all of the output from it (as well as the results of my own hacks, which I do in order to make sure I can replicate and understand creatively what the lesson(s) teach).
Posts: 2,696
Threads: 327
Joined: Apr 2022
Reputation:
217
If all you need is a text output, you can always swap from the SCREEN _NEWIMAGE screens and use $CONSOLE:ONLY to print to the terminal, which allows for built in scrolling (up to whatever the buffer length is set at -- it's not limitless scrolling either).
Otherwise, all you can do is print a single page of text to the screen at a time. To create that scrolling effect, you'd need to print to the screen inside a DO...LOOP, read the user input, and then change the starting point of that large list based on what the user wants/needs.
I'm not certain when Terry covers such a process in his tutorial, but it's not that complicated really to do a "scrollable list". If he doesn't have a chapter on creating one, maybe he'll work one up for everyone to take a gander at in his free time.
(If not, I'll whip one up late one night when I'm restless and can't sleep, for folks to study sometime. )
Posts: 1,272
Threads: 119
Joined: Apr 2022
Reputation:
100
Go ahead Steve, I'm working on the additions to Lesson 5 at the moment and am in the groove so to speak. Don't want to step away from it right now.
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Posts: 3,974
Threads: 177
Joined: Apr 2022
Reputation:
219
04-08-2024, 11:37 PM
(This post was last modified: 04-08-2024, 11:41 PM by bplus.)
@Tim since you are just starting try out Console only you can even copy text from it!
There is a real simple scroll example in Wiki, was it mousewheel?
I am on wrong computer to look it up... update, yes but it was for file contents but if you put all display stuff in an array it works the same.
I also have a tool for scrolling (and selecting) an array if you are interested.
b = b + ...
Posts: 652
Threads: 96
Joined: Apr 2022
Reputation:
22
04-08-2024, 11:40 PM
(This post was last modified: 04-09-2024, 12:05 AM by PhilOfPerth.)
This is all I do (change the Pos()0) limit to whatever)
Locate 1, 40
For a = 33 To 200
Print Tab(40); a; Chr$(a)
If Pos(0) > 30 Then Locate 31, 40
_Delay .1
Next
Posts: 34
Threads: 4
Joined: Apr 2022
Reputation:
0
04-09-2024, 12:05 AM
(This post was last modified: 04-09-2024, 12:06 AM by Tim.)
This is the exercise/program from the Tutorial that I am trying to be able to see in its entirety, or to scroll:
SCREEN _NEWIMAGE(800, 600, 32)
PRINT "This program will count to 100 from the number you supply."
PRINT
INPUT "Enter the number to start counting from > ", count%
WHILE count% <= 100
PRINT count%
count% = count% + 1
WEND
Posts: 3,974
Threads: 177
Joined: Apr 2022
Reputation:
219
04-09-2024, 12:08 AM
(This post was last modified: 04-09-2024, 12:09 AM by bplus.)
Code: (Select All) 'Screen _NewImage(800, 600, 32)
$Console:Only
Print "This program will count to 100 from the number you supply."
Print
Input "Enter the number to start counting from > ", count%
While count% <= 100
Print count%
count% = count% + 1
Wend
this will work for that program too;
Code: (Select All) Screen _NewImage(800, 600, 32)
''Console:Only
Print "This program will count to 100 from the number you supply."
Print
Input "Enter the number to start counting from > ", count%
While count% <= 100
Print count%;
count% = count% + 1
Wend
b = b + ...
Posts: 34
Threads: 4
Joined: Apr 2022
Reputation:
0
(04-09-2024, 12:08 AM)bplus Wrote: Code: (Select All) 'Screen _NewImage(800, 600, 32)
$Console:Only
Print "This program will count to 100 from the number you supply."
Print
Input "Enter the number to start counting from > ", count%
While count% <= 100
Print count%
count% = count% + 1
Wend
this will work for that program too;
Code: (Select All) Screen _NewImage(800, 600, 32)
''Console:Only
Print "This program will count to 100 from the number you supply."
Print
Input "Enter the number to start counting from > ", count%
While count% <= 100
Print count%;
count% = count% + 1
Wend
I have done that, and it worked fine; I still want to be able to scroll without going to console:only mode. If I can.
Posts: 652
Threads: 96
Joined: Apr 2022
Reputation:
22
Code: (Select All) 'This will slow down scroll after screen reaches row 30
Screen _NewImage(800, 600, 32)
Print "This program will count to 100 from the number you supply."
Print
Input "Enter the number to start counting from > ", count%
While count% <= 100
_KeyClear
Print count%
If CsrLin > 30 Then Sleep 1 ' or sleep 2 etc
count% = count% + 1
Wend
Posts: 3,974
Threads: 177
Joined: Apr 2022
Reputation:
219
04-09-2024, 12:34 AM
(This post was last modified: 04-09-2024, 03:34 AM by bplus.)
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
b = b + ...
|