Author Topic: Scroll Bar  (Read 8612 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Scroll Bar
« Reply #15 on: September 20, 2019, 04:57:21 pm »
Well I was thinking more like this:
Code: QB64: [Select]
  1.  
  2. TYPE ColoredLines
  3.     s AS STRING
  4.     ink AS INTEGER
  5.     paper AS INTEGER
  6.  
  7. BoxHeight = 15 'list to 15 rows
  8. TXT_Lenght = 60
  9. XPosition = 10
  10. YPosition = 7
  11.  
  12. DIM text(1 TO 100) AS ColoredLines
  13. FOR i = 1 TO 100
  14.     text(i).ink = INT((i - 1) / 10) + 1
  15.     text(i).paper = (text(i).ink + 7) MOD 8
  16.     text(i).s = LEFT$("Line #" + STR$(i) + ", This is " + sayColor$(text(i).ink) + " ink on " + sayColor$(text(i).paper) + " paper." + SPACE$(TXT_Lenght), TXT_Lenght)
  17.  
  18.  
  19. Value = ScrollBar(text(), XPosition, YPosition, TXT_Lenght, BoxHeight)
  20. COLOR 15, 0: LOCATE 2, 10: PRINT "Selected:"; Value
  21.  
  22. FUNCTION ScrollBar (Text() AS ColoredLines, Xposition, Yposition, TXT_Lenght, Height)
  23.     DO UNTIL ScrollBar
  24.         i$ = UCASE$(INKEY$)
  25.         WHILE _MOUSEINPUT
  26.             mwh = _MOUSEWHEEL
  27.             ch = ch + mwh
  28.             IF mwh THEN EXIT WHILE
  29.  
  30.             Fx = _FONTWIDTH
  31.             Fy = _FONTHEIGHT
  32.             IF _MOUSEX >= Fx * Xposition AND _MOUSEX <= Fx * (Xposition + TXT_Lenght) THEN
  33.                 IF _MOUSEY >= Fy * Yposition AND _MOUSEY <= Fy * (Yposition + Height) THEN
  34.                     IF mwh = 0 THEN
  35.                         ch = b + _CEIL((_MOUSEY - (Yposition * Fy)) / Fy)
  36.                     END IF
  37.                 END IF
  38.             END IF
  39.             IF _MOUSEBUTTON(1) THEN i$ = CHR$(13)
  40.         WEND
  41.  
  42.         IF i$ = "A" OR i$ = CHR$(0) + CHR$(72) THEN ch = ch - 1 '+Up
  43.         IF i$ = "Z" OR i$ = CHR$(0) + CHR$(80) THEN ch = ch + 1 '+Dn
  44.         IF i$ = CHR$(0) + CHR$(73) THEN ch = ch - Height 'PgUP
  45.         IF i$ = CHR$(0) + CHR$(81) THEN ch = ch + Height 'PgDN
  46.         IF i$ = CHR$(0) + CHR$(71) THEN ch = LBOUND(text) 'HOME
  47.         IF i$ = CHR$(0) + CHR$(79) THEN ch = UBOUND(text) 'END
  48.  
  49.         IF ch > Height + b THEN b = b + 1: e = e + 1
  50.         IF ch < e - Height THEN b = b - 1: e = e - 1
  51.  
  52.  
  53.         IF b > UBOUND(Text) THEN b = UBOUND(Text)
  54.         IF b < LBOUND(Text) THEN b = LBOUND(Text)
  55.         e = b + Height
  56.         IF e > UBOUND(Text) THEN e = UBOUND(Text): b = e - Height
  57.         IF e < LBOUND(text) THEN e = LBOUND(Text)
  58.  
  59.         IF ch < LBOUND(text) THEN ch = LBOUND(text)
  60.         IF ch > UBOUND(text) THEN ch = UBOUND(text)
  61.  
  62.         R = Yposition
  63.         FOR scroll = b TO e
  64.             IF scroll = ch THEN bckc~& = 15: fore~& = 0 ELSE bckc~& = Text(scroll).paper: fore~& = Text(scroll).ink
  65.             COLOR fore~&, bckc~&
  66.             'IF LEN(Text(scroll)) > TXT_Lenght THEN t$ = LEFT$(Text(scroll), TXT_Lenght - 3) + "..." ELSE t$ = Text(scroll)
  67.             't$ = t$ + SPACE$(TXT_Lenght - LEN(t$))
  68.             'IF LEN(t$) > TXT_Lenght THEN t$ = LEFT$(t$, LEN(t$) - 3) + "..."
  69.             LOCATE R, Xposition: PRINT Text(scroll).s
  70.             R = R + 1
  71.         NEXT
  72.         IF i$ = CHR$(13) THEN ScrollBar = ch
  73.     LOOP
  74.  
  75. FUNCTION sayColor$ (n)
  76.     SELECT CASE n
  77.         CASE 0: sayColor$ = "Black"
  78.         CASE 1: sayColor$ = "Dark Blue"
  79.         CASE 2: sayColor$ = "Dark Green"
  80.         CASE 3: sayColor$ = "Dark Cyan"
  81.         CASE 4: sayColor$ = "Dark Red"
  82.         CASE 5: sayColor$ = "Dark Purple"
  83.         CASE 6: sayColor$ = "Dirty Dark Yellow"
  84.         CASE 7: sayColor$ = "Dark White"
  85.         CASE 8: sayColor$ = "Light Black"
  86.         CASE 9: sayColor$ = "Blue"
  87.         CASE 10: sayColor$ = "Green"
  88.         CASE 11: sayColor$ = "Cyan"
  89.         CASE 12: sayColor$ = "Red"
  90.         CASE 13: sayColor$ = "Purple"
  91.         CASE 14: sayColor$ = "Yellow"
  92.         CASE 15: sayColor$ = "White"
  93.     END SELECT
  94.  
  95.  

  [ You are not allowed to view this attachment ]  

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
Re: Scroll Bar
« Reply #16 on: September 20, 2019, 05:52:35 pm »
Hi Petr

I find your examples good

  [ You are not allowed to view this attachment ]  

cool the combo of keys and mouse....

I got a glitch that I'm not able to recognize in the code! Doing different attempts I get nothing .

Scrolling by wheel of mouse works well when mouse's cursor is not in action on the scrollingbox.
When cursor of mouse is on the scrollingbox the wheel of mouse works only if user points on the first line of scrolling...
nothing happens if cursor of mouse points to another item of the list of scrolling...


Thanks for sharing
« Last Edit: September 20, 2019, 05:56:55 pm by TempodiBasic »
Programming isn't difficult, only it's  consuming time and coffee

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
Re: Scroll Bar
« Reply #17 on: September 20, 2019, 06:02:11 pm »
Hello. Yeah, the wheel only works outside the dump column, because if the mouse is in the dump column, it has priority to calculate the mouse position and thus determine the selection from the list. As for the colors (this is a note for BPlus), then I think it is enough to extend the text field with a flag and choose a color according to the flag. For example, when I return to the original topic, add the water temperature flag and set the text colors according to the water temperature... (or other)

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
Re: Scroll Bar
« Reply #18 on: September 20, 2019, 06:09:06 pm »
Hi Bplus

in this your mod of Petr function for scrolling  you have set off the selection/highlight by pointer of the item pointed by cursor of mouse.

I find in wiki this example of scrolling with wheel of mouse that works like your mod, you must add just color to screen output and the selection highlighting

Code: QB64: [Select]
  1.  
  2. 'Code by Ted Weissgerber
  3. DIM Array$(100)
  4. LINE INPUT "Enter a file name with 100 or more lines of text: ", file$
  5. OPEN file$ FOR INPUT AS #1
  6.   inputcount = inputcount + 1
  7.   LINE INPUT #1, Array$(inputcount)
  8.   IF inputcount = 100 THEN EXIT DO
  9. FOR n = 1 TO 21: PRINT Array$(n): NEXT
  10.     IF row >= 0 THEN row = row + _MOUSEWHEEL ELSE row = 0  'prevent under scrolling
  11.     IF row > inputcount - 20 THEN row = inputcount - 20    'prevent over scrolling
  12.     IF prevrow <> row THEN 'look for a change in row value
  13.       IF row > 0 AND row <= inputcount - 20 THEN
  14.         CLS: LOCATE 2, 1
  15.         FOR n = row TO row + 20
  16.           PRINT Array$(n)
  17.         NEXT
  18.       END IF
  19.     END IF
  20.     prevrow = row 'store previous row value
  21.   LOOP
  22. LOOP UNTIL INKEY$ > ""  
  23.  

you can find it here http://qb64.org/wiki/MOUSEWHEEL

Programming isn't difficult, only it's  consuming time and coffee

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
Re: Scroll Bar
« Reply #19 on: September 20, 2019, 06:17:22 pm »
Hi Petr
sorry for my bad communication

about this
Quote
Hello. Yeah, the wheel only works outside the dump column, because if the mouse is in the dump column, it has priority to calculate the mouse position and thus determine the selection from the list
mouse wheel works also when you point with mouse on the first item showed into the scrollingBox...
so if I point to item 1 and move mouseWheel  the item highlighted moves down until it is item 15, then scrolling again the items scroll down. Well now it says that as last item showed there is at the bottom item 18 and I point by cursor of mouse this last it will be highlighted, now if I move mousewheel up or down i get scrolling the item HighLighted, the same i get if i point by cursor of mouse the first item showed in the listbox. Oe exception is if I point by mouse cursor the item 20!
Thanks to read
« Last Edit: September 20, 2019, 06:27:29 pm by TempodiBasic »
Programming isn't difficult, only it's  consuming time and coffee

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
Re: Scroll Bar
« Reply #20 on: September 20, 2019, 06:23:34 pm »
Hi.

Yeah, the wheel only works outside the dump column, because if the mouse is in the dump column, it has priority to calculate the mouse position and thus determine the selection from the list. As for the colors (this is a note for BPlus), then I think it is enough to extend the text field with a flag and choose a color according to the flag. For example, when I return to the original topic, add the water temperature flag and set the text colors according to the water temperature... (or other)...


Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(500, 600, 256)
  2.  
  3.     Text AS STRING * 30
  4.     Water AS _UNSIGNED _BYTE
  5.  
  6.  
  7.  
  8. DIM Text(200) AS E
  9. FOR N = 0 TO 200
  10.     temperature = RND * 100
  11.     Text(N).Text = "Water temperature: " + STR$(temperature)
  12.     Text(N).Water = temperature
  13.  
  14.  
  15. height = 15 'list to 15 rows
  16. TXT_Lenght = 30
  17. XPosition = 10
  18. YPosition = 7
  19.  
  20.  
  21.  
  22. Value = ScrollBar(Text(), XPosition, YPosition, TXT_Lenght, height)
  23. PRINT "Selected:"; Value
  24.  
  25.  
  26.  
  27. FUNCTION ScrollBar (Text() AS E, Xposition, Yposition, TXT_Lenght, Height)
  28.     DO UNTIL ScrollBar
  29.         i$ = UCASE$(INKEY$)
  30.         WHILE _MOUSEINPUT
  31.             mwh = _MOUSEWHEEL
  32.             ch = ch + mwh
  33.             IF mwh THEN EXIT WHILE
  34.  
  35.             Fx = _FONTWIDTH
  36.             Fy = _FONTHEIGHT
  37.             IF _MOUSEX >= Fx * Xposition AND _MOUSEX <= Fx * (Xposition + TXT_Lenght) THEN
  38.                 IF _MOUSEY >= Fy * Yposition AND _MOUSEY <= Fy * (Yposition + Height) THEN
  39.                     IF mwh = 0 THEN
  40.                         ch = b + _CEIL((_MOUSEY - (Yposition * Fy)) / Fy)
  41.                     END IF
  42.                 END IF
  43.             END IF
  44.             IF _MOUSEBUTTON(1) THEN i$ = CHR$(13)
  45.         WEND
  46.  
  47.         IF i$ = "A" OR i$ = CHR$(0) + CHR$(72) THEN ch = ch - 1 '+Up
  48.         IF i$ = "Z" OR i$ = CHR$(0) + CHR$(80) THEN ch = ch + 1 '+Dn
  49.         IF i$ = CHR$(0) + CHR$(73) THEN ch = ch - Height 'PgUP
  50.         IF i$ = CHR$(0) + CHR$(81) THEN ch = ch + Height 'PgDN
  51.         IF i$ = CHR$(0) + CHR$(71) THEN ch = LBOUND(text) 'HOME
  52.         IF i$ = CHR$(0) + CHR$(79) THEN ch = UBOUND(text) 'END
  53.  
  54.         IF ch > Height + b THEN b = b + 1: e = e + 1
  55.         IF ch < e - Height THEN b = b - 1: e = e - 1
  56.  
  57.  
  58.         IF b > UBOUND(Text) THEN b = UBOUND(Text)
  59.         IF b < LBOUND(Text) THEN b = LBOUND(Text)
  60.         e = b + Height
  61.         IF e > UBOUND(Text) THEN e = UBOUND(Text): b = e - Height
  62.         IF e < LBOUND(text) THEN e = LBOUND(Text)
  63.  
  64.         IF ch < LBOUND(text) THEN ch = LBOUND(text)
  65.         IF ch > UBOUND(text) THEN ch = UBOUND(text)
  66.  
  67.         R = Yposition
  68.         BackgroundColor~& = 0
  69.  
  70.  
  71.         FOR scroll = b TO e
  72.             SELECT CASE Text(scroll).Water
  73.                 CASE 0 TO 20: ForegroundColor~& = 32
  74.                 CASE 20 TO 40: ForegroundColor~& = 52
  75.                 CASE 40 TO 60: ForegroundColor~& = 46
  76.                 CASE 60 TO 80: ForegroundColor~& = 36
  77.                 CASE IS > 80: ForegroundColor~& = 40
  78.             END SELECT
  79.  
  80.             IF scroll = ch THEN bckc~& = 9: fore~& = ForegroundColor~& ELSE bckc~& = BackgroundColor~&: fore~& = ForegroundColor~&
  81.             COLOR fore~&, bckc~&
  82.             IF LEN(Text(scroll).Text) > TXT_Lenght THEN t$ = LEFT$(Text(scroll).Text, TXT_Lenght - 3) + "..." ELSE t$ = Text(scroll).Text
  83.             t$ = t$ + SPACE$(TXT_Lenght - LEN(t$))
  84.             IF LEN(t$) > TXT_Lenght THEN t$ = LEFT$(t$, LEN(t$) - 3) + "..."
  85.             LOCATE R, Xposition: PRINT t$
  86.             R = R + 1
  87.         NEXT
  88.         IF i$ = CHR$(13) THEN ScrollBar = ch
  89.     LOOP
  90.  

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
Re: Scroll Bar
« Reply #21 on: September 20, 2019, 06:52:11 pm »
Hi Petr
also this last code that you have posted shows on my Pc the same strange behaviour, but reading again your affirmation
Quote
Yeah, the wheel only works outside the dump column,
I can suppose that it is linked to the calculation of the position of the cursor of mouse  because it appears only if I point to the first row and the last row of ScrollingBox!
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Scroll Bar
« Reply #22 on: September 20, 2019, 07:52:14 pm »
Hi Bplus

in this your mod of Petr function for scrolling  you have set off the selection/highlight by pointer of the item pointed by cursor of mouse.

I find in wiki this example of scrolling with wheel of mouse that works like your mod, you must add just color to screen output and the selection highlighting

Code: QB64: [Select]
  1.  
  2. 'Code by Ted Weissgerber
  3. DIM Array$(100)
  4. LINE INPUT "Enter a file name with 100 or more lines of text: ", file$
  5. OPEN file$ FOR INPUT AS #1
  6.   inputcount = inputcount + 1
  7.   LINE INPUT #1, Array$(inputcount)
  8.   IF inputcount = 100 THEN EXIT DO
  9. FOR n = 1 TO 21: PRINT Array$(n): NEXT
  10.     IF row >= 0 THEN row = row + _MOUSEWHEEL ELSE row = 0  'prevent under scrolling
  11.     IF row > inputcount - 20 THEN row = inputcount - 20    'prevent over scrolling
  12.     IF prevrow <> row THEN 'look for a change in row value
  13.       IF row > 0 AND row <= inputcount - 20 THEN
  14.         CLS: LOCATE 2, 1
  15.         FOR n = row TO row + 20
  16.           PRINT Array$(n)
  17.         NEXT
  18.       END IF
  19.     END IF
  20.     prevrow = row 'store previous row value
  21.   LOOP
  22. LOOP UNTIL INKEY$ > ""  
  23.  

you can find it here http://qb64.org/wiki/MOUSEWHEEL

Hi TempodiBasic,

Reply #15 IS a mod of Petr's code, I added the ColoredLine Type and SayColor function and modified the display part in Petr's. And the code I first posted could have come from a mod of the Wiki example by Ted for mouse wheel.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
Re: Scroll Bar
« Reply #23 on: September 21, 2019, 03:18:40 am »
Hi TempodiBasic. Here is a slightly modified version, which I think will clearly show why it behaves so in the previous version. Here is added condition IF _MOUSEBUTTON (1), which ensures that the recalculation of the selection position is done only after left-clicking. Therefore, in this version, the mouse wheel responds throughout the list column range:
See row 42, 44.

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(500, 600, 256)
  2.  
  3.     Text AS STRING * 30
  4.     Water AS _UNSIGNED _BYTE
  5.  
  6.  
  7.  
  8. DIM Text(200) AS E
  9. FOR N = 0 TO 200
  10.     temperature = RND * 100
  11.     Text(N).Text = "Water temperature: " + STR$(temperature)
  12.     Text(N).Water = temperature
  13.  
  14.  
  15. height = 15 'list to 15 rows
  16. TXT_Lenght = 30
  17. XPosition = 10
  18. YPosition = 7
  19.  
  20.  
  21.  
  22. Value = ScrollBar(Text(), XPosition, YPosition, TXT_Lenght, height)
  23. PRINT "Selected:"; Value
  24.  
  25.  
  26.  
  27. FUNCTION ScrollBar (Text() AS E, Xposition, Yposition, TXT_Lenght, Height)
  28.     DO UNTIL DONE
  29.         i$ = UCASE$(INKEY$)
  30.         WHILE _MOUSEINPUT
  31.             mwh = _MOUSEWHEEL
  32.             ch = ch + mwh
  33.  
  34.  
  35.             Fx = _FONTWIDTH
  36.             Fy = _FONTHEIGHT
  37.             IF _MOUSEX >= Fx * Xposition AND _MOUSEX <= Fx * (Xposition + TXT_Lenght) THEN
  38.                 IF _MOUSEY >= Fy * Yposition AND _MOUSEY <= Fy * (Yposition + Height) THEN
  39.                     IF _MOUSEBUTTON(1) THEN '                                                                   THIS CONDITION
  40.                         ch = b + _CEIL((_MOUSEY - (Yposition * Fy)) / Fy)
  41.                     END IF '                                                                                     --------------
  42.                 END IF
  43.             END IF
  44.             IF _MOUSEBUTTON(1) THEN i$ = CHR$(13)
  45.         WEND
  46.  
  47.         IF i$ = "A" OR i$ = CHR$(0) + CHR$(72) THEN ch = ch - 1 '+Up
  48.         IF i$ = "Z" OR i$ = CHR$(0) + CHR$(80) THEN ch = ch + 1 '+Dn
  49.         IF i$ = CHR$(0) + CHR$(73) THEN ch = ch - Height 'PgUP
  50.         IF i$ = CHR$(0) + CHR$(81) THEN ch = ch + Height 'PgDN
  51.         IF i$ = CHR$(0) + CHR$(71) THEN ch = LBOUND(text) 'HOME
  52.         IF i$ = CHR$(0) + CHR$(79) THEN ch = UBOUND(text) 'END
  53.  
  54.         IF ch > Height + b THEN b = b + 1: e = e + 1
  55.         IF ch < e - Height THEN b = b - 1: e = e - 1
  56.  
  57.  
  58.         IF b > UBOUND(Text) THEN b = UBOUND(Text)
  59.         IF b < LBOUND(Text) THEN b = LBOUND(Text)
  60.         e = b + Height
  61.         IF e > UBOUND(Text) THEN e = UBOUND(Text): b = e - Height
  62.         IF e < LBOUND(text) THEN e = LBOUND(Text)
  63.  
  64.         IF ch < LBOUND(text) THEN ch = LBOUND(text)
  65.         IF ch > UBOUND(text) THEN ch = UBOUND(text)
  66.  
  67.         R = Yposition
  68.         BackgroundColor~& = 0
  69.  
  70.  
  71.         FOR Scroll = b TO e
  72.             SELECT CASE Text(Scroll).Water
  73.                 CASE 0 TO 20: ForegroundColor~& = 32
  74.                 CASE 20 TO 40: ForegroundColor~& = 52
  75.                 CASE 40 TO 60: ForegroundColor~& = 46
  76.                 CASE 60 TO 80: ForegroundColor~& = 36
  77.                 CASE IS > 80: ForegroundColor~& = 40
  78.             END SELECT
  79.  
  80.             IF Scroll = ch THEN bckc~& = 9: fore~& = ForegroundColor~& ELSE bckc~& = BackgroundColor~&: fore~& = ForegroundColor~&
  81.             COLOR fore~&, bckc~&
  82.             IF LEN(Text(Scroll).Text) > TXT_Lenght THEN t$ = LEFT$(Text(Scroll).Text, TXT_Lenght - 3) + "..." ELSE t$ = Text(Scroll).Text
  83.             t$ = t$ + SPACE$(TXT_Lenght - LEN(t$))
  84.             IF LEN(t$) > TXT_Lenght THEN t$ = LEFT$(t$, LEN(t$) - 3) + "..."
  85.             LOCATE R, Xposition: PRINT t$
  86.             R = R + 1
  87.         NEXT
  88.         IF i$ = CHR$(13) THEN ScrollBar = ch: DONE = 1
  89.     LOOP
  90.  

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
Re: Scroll Bar
« Reply #24 on: September 21, 2019, 06:33:10 am »
Hi Petr
Yes I can affirm that this version has no conflict between pointer and wheel of mouse and
IMHO it is a great present to whom need a such performed task!

Thanks to share
Programming isn't difficult, only it's  consuming time and coffee

Offline Erum

  • Newbie
  • Posts: 10
Re: Scroll Bar
« Reply #25 on: September 21, 2019, 08:12:57 am »
OK, I will make my question more clear.
You see, as I am a beginner with no special knowledge, my program is very basic with something like this:

CLS
myscreen$= _NEWIMAGE(1600, 800, 32)
SCREEN= myscreen$
INPUT "ENTER pH OF SOIL"; p
INPUT "ENTER TEMPERATURE IN FAHRENHEIT"; T
IF p >= 1 AND p < 4.5 AND T > 113 AND T < 134 THEN
    PRINT "pH IS TOO LOW AND TEMPERATURE IS TOO HIGH. CONTROL pH WITH HYDRATED LIMESTONE OR WOOD ASH (0.5 POUNDS OF HYDRATED LIMESTONE EVERY TEN SQUARE FOOT CAN INCREASE pH BY APPROXIMATELY ONE POINT.)"
ELSEIF p >= 1 AND p < 4.5 AND T < 32 THEN
    PRINT "BOTH pH AND TEMPERATURE ARE TOO LOW. CONTROL pH WITH HYDRATED LIMESTONE OR WOOD ASH (0.5 POUNDS OF HYDRATED LIMESTONE EVERY TEN SQUARE FOOT CAN INCREASE pH BY APPROXIMATELY ONE POINT.)"
ELSEIF p > 8.4 AND p <= 14 AND T > 113 AND T <= 134 THEN
    PRINT "BOTH pH AND TEMPERATURE ARE TOO HIGH. CONTROL pH WITH ORGANIC MATTER ( PEAT MOSS), ALUMINIUM SULPHATE, OR SULPHUR (1.2 POUNDS OF ALUMINIUM SULPHATE OR 0.2 POUNDS OF SULPHUR EVERY TEN SQUARE FOOT CAN LOWER pH BY APPROXIMATELY ONE POINT.)"
ELSEIF p > 8.4 AND p < 14 AND T < 32 THEN
    PRINT "pH IS TOO HIGH AND TEMPERATURE IS TOO LOW. CONTROL pH WITH ORAGNIC MATTER LIKE PEAT MOSS, ALUMINIUM SULPHATE, OR SULPHUR (1.2 POUNDS OF ALUMINIUM SULPHATE OR 0.2 POUNDS OF SULPHUR EVRY TEN SQUARE FOOT CAN LOWER pH BY APPROXIMATELY ONE POINT.)"
ELSEIF p >= 4.5 AND p <= 8.4 AND T > 113 AND T < 134 THEN
    PRINT "TEMPERATURE IS TOO HIGH."
ELSEIF p >= 4.5 AND p <= 8.4 AND T < 32 THEN
    PRINT "TEMPERATURE IS TOO LOW."
ELSEIF p <= 14 AND p > 8.4 AND T >= 32 AND T <= 113 THEN
    PRINT "pH IS TOO HIGH. CONTROL IT USING HYDRATED LIMESTONE OR WOOD ASH. (0.5 POUNDS OF HYDRATED LIMESTONE EVERY TEN SQUARE FOOT WILL INCREASE pH BY APPROXIMATELY ONE POINT.)"
ELSEIF p >= 1 AND p < 4.5 AND T >= 32 AND T < 134 THEN
    PRINT "pH IS TOO LOW. CONTROL pH USING HYDRATED LIMETONE OR WOOD ASH (0.5 POUNDS OF HYDRATED LIMESTONE EVERY TEN SQUARE FOOT WILL INCREASE pH BY APPROXIMATELY ONE POINT.)"
ELSEIF p < 1 OR p > 14 AND T > 134 THEN
    PRINT "PLEASE ENTER VALID VALUES."
ELSEIF p >= 1 AND p <= 14 AND T > 134 THEN
    PRINT "ENTER VALID TEMPERATURE VALUE."
ELSEIF p < 1 OR p > 14 AND T <= 134 THEN
    PRINT "ENTER VALID pH VALUE."
ELSEIF T >= 32 AND T <= 50 AND p >= 4.5 AND p <= 5 THEN
    PRINT "PLANTS THAT WILL GROW BEST IN THESE CONDITIONS:"
    PRINT "1.ENGLISH OAK (TREE):"
    PRINT "WATER: SEEDLING:KEEP SOIL WET. YOUNG:1.5 GALLONS A DAY. MATURE:CAN DRAW 50 GALLONS."
    PRINT "FERTILIZER: DON'T USE TILL 2 YEARS OLD. WHEN MATURE, USE 12-6-6 OR 12-4-8 FERTILIZER ANNUALLY (16.6 POUNDS EVERY 1000 SQUARE FEET.)"
    PRINT "DISTANCE: PLANT 25 FEET APART. TEMPERATURE: 32-92 F. pH:4.5-5.0."
    PRINT "SUNLIGHT:HIGH(6-8 HOURS A DAY). MOISTURE PERCENT: MODERATE (21-40%)"
    PRINT
    PRINT "2.PAPER BIRCH (TREE):"
    PRINT "WATER: YOUNG: LET WATER RUN FROM HOSE FOR 30 SEC EVERY 2 WEEKS. MATURE:KEEP SOIL WET 10INCH DEEP."
    PRINT "FERTILIZER: USE 11-22-22 FERTILIZER ANNUALLY AND COVER SOIL WELL. WHEN MATURE, FERTILIZE ONLY WHEN DEFFIECENCY NOTED."
    PRINT "DISTANCE:PLANT 25 FT APART. TEMPERATURE:32-113 F pH:4.5-8.4"
    PRINT "SUNLIGHT: HIGH (6-8 HOURS A DAY). MOISTURE PERCENT: MODERATE (21-40%)"
    PRINT
    PRINT "3.AZALEAS (FLOWERS):"
    PRINT "WATER:4 GALLONS PER SQUARE METRE EVERY 2 WEEKS."
    PRINT "FERTILIZER:USE 10-10-10 FERTILIZER 2-3 TIMES A YEAR."
    PRINT "DISTANCE:PLANT 2 FEET APART. TEMPERATURE:32-76 F. pH:4.5-5.0."
    PRINT "SUNLIGHT: SUNNY TO PARTIAL (HIGH-MED). MOISTURE PERCENT: OPTIMUM 41-60%"
    PRINT
    PRINT "NOTE 1. FERTILIZER FORMULAS STATED SHOW THE PROPORTION OF NITROGEN-PHOSPHORUS-POTASSIUM RESPECTIVELY."
    PRINT "NOTE 2:PLANTS NEED WELL DRAINING AND NOURISHED SOIL AND BEST CO2 AMOUNT FOR THEM IS 1000-1500 PPM (PARTS PER MILLION)"
    PRINT "NOTE 3:INSTEAD OF NPK FERTILIZER YOU CAN USE THESE IN THE PROPORTION YOU REQUIRE:"
    PRINT "COFFEE GROUNDS,BLOOD MEAL, AND COTTON SEED MEAL FOR NITROGEN"
    PRINT "FISH BONE MEAL, STEAMED BONE MEAL, AND ROCK DUST FOR PHOSPHORUS"
    PRINT "KELP MEAL, HARDWOOD ASH, AND GREEN ORGANIC MATERIAL FOR POTASSIUM"

You see, I want to add colours to my program on each line that is printed (each line must have a different background and foreground colour). The colour statements on each line are not working when nested in if-then-else statements., so I want to ask if there is another way of doing this. Also, in some conditions, the amount of best suited plants is quite large, and they all are not fitting on the screen. For that, I need a scroll bar.
Hope you all clearly understand and will do an immense favour by helping me again.
Regards.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
Re: Scroll Bar
« Reply #26 on: September 21, 2019, 08:21:50 am »
Hi Bplus

you're showing complete Reference pages of your posts!
while I was thinking that I had found a third way to do scrolling in wiki page and to not appear to be mine that code I put as first line the author.
I need better glasses !

Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Scroll Bar
« Reply #27 on: September 21, 2019, 09:28:15 am »
Hi Erum,

You can CLS and control COLOR before each and every PRINT statement even when they are inside an IF block.

If you have a block of text to present that does not fit your screen then the little scroller I showed would work fine, you need to set up an array to hold the text, lets call it tempText$() how many lines? 50?

DIM tempText$(1 to 50)
tempText$(1) = "This is line #1 of tempText$()."
tempText$(2) = "This is second line to display."...
continue on to fill up tempText

another way is to put all the lines in DATA statements and READ the lines into tempText$()


Oh heck here is your code rewritten:
Code: QB64: [Select]
  1.  
  2. SCREEN _NEWIMAGE(800, 700, 32) ' <<<< 32 here means you are using RGB and aplha colors _RGB32(red , green, blue)
  3.  
  4. 'set color then CLS so entire background is same
  5. COLOR _RGB32(100, 100, 255), _RGB32(0, 0, 120) ' <<< light blueish ink on dark blue paper
  6. CLS 'so now entire background is dark blue paper
  7.  
  8. INPUT "ENTER pH OF SOIL"; p
  9. INPUT "ENTER TEMPERATURE IN FAHRENHEIT"; T
  10.  
  11. IF p >= 1 AND p < 4.5 AND T > 113 AND T < 134 THEN
  12.     PRINT "pH IS TOO LOW AND TEMPERATURE IS TOO HIGH. CONTROL pH WITH HYDRATED LIMESTONE OR WOOD ASH (0.5 POUNDS OF HYDRATED LIMESTONE EVERY TEN SQUARE FOOT CAN INCREASE pH BY APPROXIMATELY ONE POINT.)"
  13. ELSEIF p >= 1 AND p < 4.5 AND T < 32 THEN
  14.     PRINT "BOTH pH AND TEMPERATURE ARE TOO LOW. CONTROL pH WITH HYDRATED LIMESTONE OR WOOD ASH (0.5 POUNDS OF HYDRATED LIMESTONE EVERY TEN SQUARE FOOT CAN INCREASE pH BY APPROXIMATELY ONE POINT.)"
  15. ELSEIF p > 8.4 AND p <= 14 AND T > 113 AND T <= 134 THEN
  16.     PRINT "BOTH pH AND TEMPERATURE ARE TOO HIGH. CONTROL pH WITH ORGANIC MATTER ( PEAT MOSS), ALUMINIUM SULPHATE, OR SULPHUR (1.2 POUNDS OF ALUMINIUM SULPHATE OR 0.2 POUNDS OF SULPHUR EVERY TEN SQUARE FOOT CAN LOWER pH BY APPROXIMATELY ONE POINT.)"
  17. ELSEIF p > 8.4 AND p < 14 AND T < 32 THEN
  18.     PRINT "pH IS TOO HIGH AND TEMPERATURE IS TOO LOW. CONTROL pH WITH ORAGNIC MATTER LIKE PEAT MOSS, ALUMINIUM SULPHATE, OR SULPHUR (1.2 POUNDS OF ALUMINIUM SULPHATE OR 0.2 POUNDS OF SULPHUR EVRY TEN SQUARE FOOT CAN LOWER pH BY APPROXIMATELY ONE POINT.)"
  19. ELSEIF p >= 4.5 AND p <= 8.4 AND T > 113 AND T < 134 THEN
  20.     PRINT "TEMPERATURE IS TOO HIGH."
  21. ELSEIF p >= 4.5 AND p <= 8.4 AND T < 32 THEN
  22.     PRINT "TEMPERATURE IS TOO LOW."
  23. ELSEIF p <= 14 AND p > 8.4 AND T >= 32 AND T <= 113 THEN
  24.     PRINT "pH IS TOO HIGH. CONTROL IT USING HYDRATED LIMESTONE OR WOOD ASH. (0.5 POUNDS OF HYDRATED LIMESTONE EVERY TEN SQUARE FOOT WILL INCREASE pH BY APPROXIMATELY ONE POINT.)"
  25. ELSEIF p >= 1 AND p < 4.5 AND T >= 32 AND T < 134 THEN
  26.     PRINT "pH IS TOO LOW. CONTROL pH USING HYDRATED LIMETONE OR WOOD ASH (0.5 POUNDS OF HYDRATED LIMESTONE EVERY TEN SQUARE FOOT WILL INCREASE pH BY APPROXIMATELY ONE POINT.)"
  27. ELSEIF p < 1 OR p > 14 AND T > 134 THEN
  28.     PRINT "PLEASE ENTER VALID VALUES."
  29. ELSEIF p >= 1 AND p <= 14 AND T > 134 THEN
  30.     PRINT "ENTER VALID TEMPERATURE VALUE."
  31. ELSEIF p < 1 OR p > 14 AND T <= 134 THEN
  32.     PRINT "ENTER VALID pH VALUE."
  33. ELSEIF T >= 32 AND T <= 50 AND p >= 4.5 AND p <= 5 THEN
  34.     PRINT "PLANTS THAT WILL GROW BEST IN THESE CONDITIONS:"
  35.     COLOR _RGB32(255, 255, 255)
  36.     PRINT "1.ENGLISH OAK (TREE):"
  37.     PRINT "WATER: SEEDLING:KEEP SOIL WET. YOUNG:1.5 GALLONS A DAY. MATURE:CAN DRAW 50 GALLONS."
  38.     PRINT "FERTILIZER: DON'T USE TILL 2 YEARS OLD. WHEN MATURE, USE 12-6-6 OR 12-4-8 FERTILIZER ANNUALLY (16.6 POUNDS EVERY 1000 SQUARE FEET.)"
  39.     PRINT "DISTANCE: PLANT 25 FEET APART. TEMPERATURE: 32-92 F. pH:4.5-5.0."
  40.     PRINT "SUNLIGHT:HIGH(6-8 HOURS A DAY). MOISTURE PERCENT: MODERATE (21-40%)"
  41.     PRINT
  42.     COLOR _RGB32(0, 180, 0)
  43.     PRINT "2.PAPER BIRCH (TREE):"
  44.     PRINT "WATER: YOUNG: LET WATER RUN FROM HOSE FOR 30 SEC EVERY 2 WEEKS. MATURE:KEEP SOIL WET 10INCH DEEP."
  45.     PRINT "FERTILIZER: USE 11-22-22 FERTILIZER ANNUALLY AND COVER SOIL WELL. WHEN MATURE, FERTILIZE ONLY WHEN DEFFIECENCY NOTED."
  46.     PRINT "DISTANCE:PLANT 25 FT APART. TEMPERATURE:32-113 F pH:4.5-8.4"
  47.     PRINT "SUNLIGHT: HIGH (6-8 HOURS A DAY). MOISTURE PERCENT: MODERATE (21-40%)"
  48.     PRINT
  49.     COLOR _RGB32(255, 255, 0)
  50.     PRINT "3.AZALEAS (FLOWERS):"
  51.     PRINT "WATER:4 GALLONS PER SQUARE METRE EVERY 2 WEEKS."
  52.     PRINT "FERTILIZER:USE 10-10-10 FERTILIZER 2-3 TIMES A YEAR."
  53.     PRINT "DISTANCE:PLANT 2 FEET APART. TEMPERATURE:32-76 F. pH:4.5-5.0."
  54.     PRINT "SUNLIGHT: SUNNY TO PARTIAL (HIGH-MED). MOISTURE PERCENT: OPTIMUM 41-60%"
  55.     PRINT
  56.     COLOR _RGB32(200, 0, 100)
  57.     PRINT "NOTE 1. FERTILIZER FORMULAS STATED SHOW THE PROPORTION OF NITROGEN-PHOSPHORUS-POTASSIUM RESPECTIVELY."
  58.     PRINT "NOTE 2:PLANTS NEED WELL DRAINING AND NOURISHED SOIL AND BEST CO2 AMOUNT FOR THEM IS 1000-1500 PPM (PARTS PER MILLION)"
  59.     PRINT "NOTE 3:INSTEAD OF NPK FERTILIZER YOU CAN USE THESE IN THE PROPORTION YOU REQUIRE:"
  60.     PRINT "COFFEE GROUNDS,BLOOD MEAL, AND COTTON SEED MEAL FOR NITROGEN"
  61.     PRINT "FISH BONE MEAL, STEAMED BONE MEAL, AND ROCK DUST FOR PHOSPHORUS"
  62.     PRINT "KELP MEAL, HARDWOOD ASH, AND GREEN ORGANIC MATERIAL FOR POTASSIUM"
  63.  
  64.  

To do scrolling = display of more that a screen worth of information, will take 'special knowledge' over and above basic CLS and COLOR statements because you will need mouse functions and arrays to hold text.

But if you could limit all info pages to one screen size or less, you could offer a menu to each page and then come back to main menu to allow selection of another page. All the commands you would need are CLS, COLOR, PRINT, and INPUT, you could use an IF THEN ELSEIF ENDIF block or SELECT CASE block. Maybe just your level of coding.
« Last Edit: September 21, 2019, 09:56:33 am by bplus »

Offline Erum

  • Newbie
  • Posts: 10
Re: Scroll Bar
« Reply #28 on: September 21, 2019, 10:20:55 am »
Respected bplus,
Could you please tell me the code for just a scroll bar? That would be a big help. I would do a detailed study on that code later.
Regards.
« Last Edit: September 21, 2019, 10:23:11 am by Erum »

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
Re: Scroll Bar
« Reply #29 on: September 21, 2019, 10:33:16 am »
Hi Erum
about your issue I think you have so many to evaluate and then to adapt to your specific goal.

Quote
' Today more than yesterday programming is problem solving so
' a good programmer is a good problem solver that speaks some programming languages
so before write QB64code  you must plan the structure of the program, you must define the items or the objects of the program and how they interact among themselves or what is their behaviour, just after this  you can think how to translate all these things into a programming language (just QB64 here). IMHO only the translation depends about how you know of that language and tips for that language.

Here my little feedback about your piece of code:
IF data to show are a mess maybe that you can manage well the data to show using files. So , if you need, you can change also the data without rewrite the program! (see Bplus suggestions!)

you can build a SUB that works following your needs for printing using PRINT or _PRINTSTRING plus COLOR to set background (paper) and foreground (ink)
Bplus and Steve have made many example in the forum! Search and get solutions!

here  my mod for  more readably (I hope so ):
Code: QB64: [Select]
  1. ' Bplus suggestion
  2. SCREEN _NEWIMAGE(1600, 800, 32) ' <<<< 32 here means you are using RGB and aplha colors _RGB32(red , green, blue)
  3.  
  4. 'set color then CLS so entire background is same
  5. COLOR _RGB32(100, 100, 255), _RGB32(0, 0, 120) ' <<< light blueish ink on dark blue paper
  6. CLS 'so now entire background is dark blue paper
  7.  
  8. ' input data
  9. INPUT "ENTER pH OF SOIL"; p
  10. INPUT "ENTER TEMPERATURE IN FAHRENHEIT"; T
  11.  
  12. 'reducing the forest     TDB
  13. ' IF you use NESTED if..then..else..end if
  14. ' and not CHAINED if..then..else..end if
  15. ' the code can be more readable for humans :-)
  16. ' Today more than yesterday programming is problem solving so
  17. ' a good programmer is a good problem solver that speaks some programming languages
  18.  
  19. 'analizer  of input and giver of output
  20. IF p >= 1 AND p < 4.5 THEN
  21.     'p >= 1 AND p < 4.5 AND <-- seems the same
  22.     IF T > 113 AND T < 134 THEN
  23.         PRINT "pH IS TOO LOW AND TEMPERATURE IS TOO HIGH. CONTROL pH WITH HYDRATED LIMESTONE OR WOOD ASH (0.5 POUNDS OF HYDRATED LIMESTONE EVERY TEN SQUARE FOOT CAN INCREASE pH BY APPROXIMATELY ONE POINT.)"
  24.     ELSEIF T < 32 THEN
  25.         PRINT "BOTH pH AND TEMPERATURE ARE TOO LOW. CONTROL pH WITH HYDRATED LIMESTONE OR WOOD ASH (0.5 POUNDS OF HYDRATED LIMESTONE EVERY TEN SQUARE FOOT CAN INCREASE pH BY APPROXIMATELY ONE POINT.)"
  26.     ELSEIF T >= 32 AND T < 134 THEN
  27.         PRINT "pH IS TOO LOW. CONTROL pH USING HYDRATED LIMETONE OR WOOD ASH (0.5 POUNDS OF HYDRATED LIMESTONE EVERY TEN SQUARE FOOT WILL INCREASE pH BY APPROXIMATELY ONE POINT.)"
  28.     END IF
  29.     '    IF p >= 1 AND p < 4.5 AND is the same condition of previous IF
  30. ELSEIF p > 8.4 AND p <= 14 THEN
  31.     'IF p > 8.4 AND p < 14 AND <-- seems the same
  32.     ' p <= 14 AND p > 8.4 AND  <-- seems the same
  33.     IF T > 113 AND T <= 134 THEN
  34.         PRINT "BOTH pH AND TEMPERATURE ARE TOO HIGH. CONTROL pH WITH ORGANIC MATTER ( PEAT MOSS), ALUMINIUM SULPHATE, OR SULPHUR (1.2 POUNDS OF ALUMINIUM SULPHATE OR 0.2 POUNDS OF SULPHUR EVERY TEN SQUARE FOOT CAN LOWER pH BY APPROXIMATELY ONE POINT.)"
  35.     ELSEIF T < 32 THEN
  36.         PRINT "pH IS TOO HIGH AND TEMPERATURE IS TOO LOW. CONTROL pH WITH ORAGNIC MATTER LIKE PEAT MOSS, ALUMINIUM SULPHATE, OR SULPHUR (1.2 POUNDS OF ALUMINIUM SULPHATE OR 0.2 POUNDS OF SULPHUR EVRY TEN SQUARE FOOT CAN LOWER pH BY APPROXIMATELY ONE POINT.)"
  37.     ELSEIF T >= 32 AND T <= 113 THEN
  38.         PRINT "pH IS TOO HIGH. CONTROL IT USING HYDRATED LIMESTONE OR WOOD ASH. (0.5 POUNDS OF HYDRATED LIMESTONE EVERY TEN SQUARE FOOT WILL INCREASE pH BY APPROXIMATELY ONE POINT.)"
  39.     END IF
  40. ELSEIF p >= 4.5 AND p <= 8.4 THEN
  41.     'p >= 4.5 AND p <= 8.4 AND  <-- seems the same
  42.     IF T > 113 AND T < 134 THEN
  43.         PRINT "TEMPERATURE IS TOO HIGH."
  44.     ELSEIF T < 32 THEN
  45.         PRINT "TEMPERATURE IS TOO LOW."
  46.     END IF
  47.     'ELSEIF p < 1 OR p > 14 AND T > 134 THEN   <-- redundant
  48.     '    PRINT "PLEASE ENTER VALID VALUES."    <-- redundant
  49. ELSEIF T > 134 THEN
  50.     PRINT "ENTER VALID TEMPERATURE VALUE."
  51. ELSEIF p < 1 OR p > 14 THEN
  52.     PRINT "ENTER VALID pH VALUE."
  53. ELSEIF T >= 32 AND T <= 50 AND p >= 4.5 AND p <= 5 THEN ' this appears to be a subrange of the last range
  54.     PRINT "PLANTS THAT WILL GROW BEST IN THESE CONDITIONS:"
  55.     PRINT "1.ENGLISH OAK (TREE):"
  56.     PRINT "WATER: SEEDLING:KEEP SOIL WET. YOUNG:1.5 GALLONS A DAY. MATURE:CAN DRAW 50 GALLONS."
  57.     PRINT "FERTILIZER: DON'T USE TILL 2 YEARS OLD. WHEN MATURE, USE 12-6-6 OR 12-4-8 FERTILIZER ANNUALLY (16.6 POUNDS EVERY 1000 SQUARE FEET.)"
  58.     PRINT "DISTANCE: PLANT 25 FEET APART. TEMPERATURE: 32-92 F. pH:4.5-5.0."
  59.     PRINT "SUNLIGHT:HIGH(6-8 HOURS A DAY). MOISTURE PERCENT: MODERATE (21-40%)"
  60.     PRINT
  61.     PRINT "2.PAPER BIRCH (TREE):"
  62.     PRINT "WATER: YOUNG: LET WATER RUN FROM HOSE FOR 30 SEC EVERY 2 WEEKS. MATURE:KEEP SOIL WET 10INCH DEEP."
  63.     PRINT "FERTILIZER: USE 11-22-22 FERTILIZER ANNUALLY AND COVER SOIL WELL. WHEN MATURE, FERTILIZE ONLY WHEN DEFFIECENCY NOTED."
  64.     PRINT "DISTANCE:PLANT 25 FT APART. TEMPERATURE:32-113 F pH:4.5-8.4"
  65.     PRINT "SUNLIGHT: HIGH (6-8 HOURS A DAY). MOISTURE PERCENT: MODERATE (21-40%)"
  66.     PRINT
  67.     PRINT "3.AZALEAS (FLOWERS):"
  68.     PRINT "WATER:4 GALLONS PER SQUARE METRE EVERY 2 WEEKS."
  69.     PRINT "FERTILIZER:USE 10-10-10 FERTILIZER 2-3 TIMES A YEAR."
  70.     PRINT "DISTANCE:PLANT 2 FEET APART. TEMPERATURE:32-76 F. pH:4.5-5.0."
  71.     PRINT "SUNLIGHT: SUNNY TO PARTIAL (HIGH-MED). MOISTURE PERCENT: OPTIMUM 41-60%"
  72.     PRINT
  73.     PRINT "NOTE 1. FERTILIZER FORMULAS STATED SHOW THE PROPORTION OF NITROGEN-PHOSPHORUS-POTASSIUM RESPECTIVELY."
  74.     PRINT "NOTE 2:PLANTS NEED WELL DRAINING AND NOURISHED SOIL AND BEST CO2 AMOUNT FOR THEM IS 1000-1500 PPM (PARTS PER MILLION)"
  75.     PRINT "NOTE 3:INSTEAD OF NPK FERTILIZER YOU CAN USE THESE IN THE PROPORTION YOU REQUIRE:"
  76.     PRINT "COFFEE GROUNDS,BLOOD MEAL, AND COTTON SEED MEAL FOR NITROGEN"
  77.     PRINT "FISH BONE MEAL, STEAMED BONE MEAL, AND ROCK DUST FOR PHOSPHORUS"
  78.     PRINT "KELP MEAL, HARDWOOD ASH, AND GREEN ORGANIC MATERIAL FOR POTASSIUM"

For scrolling
you must load all strings to scroll into an array and pass it to the SUB/Function of scrolling!
Good Luck
Programming isn't difficult, only it's  consuming time and coffee