Author Topic: Scroll Bar  (Read 8383 times)

0 Members and 1 Guest are viewing this topic.

Offline Erum

  • Newbie
  • Posts: 10
Scroll Bar
« on: September 16, 2019, 03:28:05 pm »
Respected QB64 team,
I have created a software on QB64 that will analyse temperature and pH of soil and tell which plants can be grown there, along with conditions they need for a national science fair. (I used QB64 as I am a ninth grader and this software is easy to use.) Even though I managed to increase screen size but I need a scroll bar so all my data can fit neatly.
I also want to add colours, for example if I write like this:
English oak:
Water: ABC
Fertiliser:DEF
Distance:GHI  Temperature:XYZ and so on....
For this, I want the heading to be a different colour and each line to be a different colour. How can I do this?
P.S: I am not very advanced in all this but I am deeply interested to know. If any one can help me, I will be infinitely obliged.
Regards.
« Last Edit: September 16, 2019, 03:30:24 pm by Erum »

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
Re: Scroll Bar
« Reply #1 on: September 16, 2019, 05:16:09 pm »
Maybe this help you. Use A/Z/Enter.

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(500, 600, 256)
  2. DIM Text(20) AS STRING * 15
  3. FOR N = 0 TO 20
  4.     Text(N) = "Value: " + STR$(N)
  5.  
  6.  
  7. height = 5 'list to 5 rows
  8.  
  9.     i$ = UCASE$(INKEY$)
  10.     IF i$ = "A" THEN b = b - 1: ch = ch - 1
  11.     IF i$ = "Z" THEN b = b + 1: ch = ch + 1
  12.  
  13.     IF b > UBOUND(Text) THEN b = UBOUND(Text)
  14.     IF b < LBOUND(Text) THEN b = LBOUND(Text)
  15.     e = b + height '1 row height
  16.     IF e > UBOUND(Text) THEN e = UBOUND(Text): b = e - height
  17.     IF e < LBOUND(text) THEN e = LBOUND(Text)
  18.  
  19.     IF ch < LBOUND(text) THEN ch = LBOUND(text)
  20.     IF ch > UBOUND(text) THEN ch = UBOUND(text)
  21.  
  22.     R = 10 'list start on row 10
  23.     FOR scroll = b TO e
  24.         LOCATE R, 30: PRINT Text(scroll)
  25.         IF scroll = ch THEN LOCATE R, 5: PRINT "->" ELSE LOCATE R, 5: PRINT "  "
  26.         COLOR R, 0 'set foreground color    , 0 for background color (black)
  27.         R = R + 1
  28.     NEXT
  29.     IF i$ = CHR$(13) THEN PRINT "Choice:"; ch: END
  30.  

It just depends on how you organize the items in the text box. Color set using COLOR foreground, background. Be aware of the screen mode used. Use RGBA32 unsigned long colors for 32-bit displays and standard COLOR 0 to 255 for 8-bit displays. Also try _PRINTMODE _KEEPBACKGROUND and _PRINTMODE _FILLBACKGROUND.

I'm going to sleep, me look at your answer tomorrow.
« Last Edit: September 16, 2019, 05:24:10 pm by Petr »

Offline Bert22306

  • Forum Regular
  • Posts: 206
Re: Scroll Bar
« Reply #2 on: September 16, 2019, 05:20:44 pm »
Welcome, Erum. I'm not sure if you are asking simply how to change the color of the type or of the background, or something more complicated. The code here creates initially a screen with dull white background, and types different lines with different colors on that screen.

Then, it creates separate background colors, for each line of type.

You can play around with the effects in many ways. But for example, when the pH comes out with a certain value, to can create an IF statement that sets the type or the background colors, to different values?

Code: [Select]
SCREEN _NEWIMAGE(120, 43, 0)
COLOR 7, 7
CLS
COLOR 0, 7
PRINT "This is black."
COLOR 4, 7
PRINT "This is red."
COLOR 1, 7
PRINT "This is blue."
COLOR 14, 7
PRINT "This is bright yellow."
PRINT
COLOR 15, 0
PRINT "This has bright white type over a black background."
COLOR 7, 0
PRINT "This has dull white type on a black bachground."
COLOR 1, 4
PRINT "This has blue type on a red background."
END

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Scroll Bar
« Reply #3 on: September 17, 2019, 12:02:51 am »
Use mouse wheel to scroll through an array of colored strings::
Code: QB64: [Select]
  1. _TITLE "Colored Lines scroller" 'B+ 2019-09-17
  2. TYPE ColoredLines
  3.     s AS STRING
  4.     c AS INTEGER
  5.  
  6. DIM cl(1 TO 100) AS ColoredLines
  7.  
  8. 'This is just a quick fill of an array of strings with random colors
  9. 'to have something to show, insert your real text and colors into an array.
  10. FOR i = 1 TO 100
  11.     cl(i).c = INT(RND * 15) + 1
  12.     cl(i).s = "This is line number" + STR$(i)
  13.  
  14. show cl()
  15.  
  16.  
  17. SUB show (arr() AS ColoredLines)
  18.     DIM lb AS LONG, ub AS LONG, top AS LONG, i AS LONG, row AS LONG, prevrow AS LONG, n AS LONG
  19.     lb = LBOUND(arr): ub = UBOUND(arr)
  20.     IF ub - lb + 1 < 21 THEN top = ub ELSE top = lb + 19
  21.     CLS
  22.     COLOR 0, 15
  23.     PRINT "press any key to quit scroller..."
  24.     COLOR 15, 0
  25.     LOCATE 2, 1
  26.     FOR i = lb TO top
  27.         COLOR arr(i).c
  28.         PRINT arr(i).s
  29.     NEXT
  30.     DO
  31.         IF ub - lb + 1 > 20 THEN
  32.             DO WHILE _MOUSEINPUT
  33.                 IF row >= lb THEN row = row + _MOUSEWHEEL ELSE row = lb 'prevent under scrolling
  34.                 IF row > ub - 19 THEN row = ub - 19 'prevent over scrolling
  35.                 IF prevrow <> row THEN 'look for a change in row value
  36.                     IF row >= lb AND row <= ub - 19 THEN
  37.  
  38.                         CLS
  39.                         COLOR 0, 15: PRINT "press any key to quit scroller..."
  40.                         COLOR 15, 0
  41.                         LOCATE 2, 1
  42.                         FOR n = row TO row + 19
  43.                             COLOR arr(n).c
  44.                             PRINT arr(n).s
  45.                         NEXT
  46.                     END IF
  47.                 END IF
  48.                 prevrow = row 'store previous row value
  49.             LOOP
  50.         END IF
  51.     LOOP UNTIL INKEY$ > ""
  52.  
  53.  
« Last Edit: September 17, 2019, 12:07:40 am by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Scroll Bar
« Reply #4 on: September 17, 2019, 01:02:42 am »
A mod of last reply:
Code: QB64: [Select]
  1. _TITLE "Colored Lines scroller Ink and Paper Mod" 'B+ 2019-09-17
  2. TYPE ColoredLines
  3.     s AS STRING
  4.     ink AS INTEGER
  5.     paper AS INTEGER
  6.  
  7. DIM cl(1 TO 100) AS ColoredLines
  8.  
  9. FOR i = 1 TO 100
  10.     cl(i).ink = INT(RND * 16)
  11.     r = INT(RND * 8)
  12.     WHILE r = cl(i).ink
  13.         r = INT(RND * 8)
  14.     WEND
  15.     cl(i).paper = r
  16.     cl(i).s = LEFT$("Line #" + STR$(i) + ", This is " + sayColor$(cl(i).ink) + " ink on " + sayColor$(cl(i).paper) + " paper." + SPACE$(_WIDTH), _WIDTH)
  17. show cl()
  18.  
  19. FUNCTION sayColor$ (n)
  20.     SELECT CASE n
  21.         CASE 0: sayColor$ = "Black"
  22.         CASE 1: sayColor$ = "Dark Blue"
  23.         CASE 2: sayColor$ = "Dark Green"
  24.         CASE 3: sayColor$ = "Dark Cyan"
  25.         CASE 4: sayColor$ = "Dark Red"
  26.         CASE 5: sayColor$ = "Dark Purple"
  27.         CASE 6: sayColor$ = "Dirty Dark Yellow"
  28.         CASE 7: sayColor$ = "Dark White"
  29.         CASE 8: sayColor$ = "Light Black"
  30.         CASE 9: sayColor$ = "Blue"
  31.         CASE 10: sayColor$ = "Green"
  32.         CASE 11: sayColor$ = "Cyan"
  33.         CASE 12: sayColor$ = "Red"
  34.         CASE 13: sayColor$ = "Purple"
  35.         CASE 14: sayColor$ = "Yellow"
  36.         CASE 15: sayColor$ = "White"
  37.     END SELECT
  38.  
  39. SUB show (arr() AS ColoredLines)
  40.     DIM lb AS LONG, ub AS LONG, top AS LONG, i AS LONG, row AS LONG, prevrow AS LONG, n AS LONG
  41.     lb = LBOUND(arr): ub = UBOUND(arr)
  42.     IF ub - lb + 1 < 21 THEN top = ub ELSE top = lb + 19
  43.     COLOR 15, 0
  44.     CLS
  45.     COLOR 0, 15
  46.     PRINT "press any key to quit scroller..."
  47.     COLOR 15, 0
  48.     LOCATE 2, 1
  49.     FOR i = lb TO top
  50.         COLOR arr(i).ink, arr(i).paper
  51.         PRINT arr(i).s
  52.     NEXT
  53.     DO
  54.         IF ub - lb + 1 > 20 THEN
  55.             DO WHILE _MOUSEINPUT
  56.                 IF row >= lb THEN row = row + _MOUSEWHEEL ELSE row = lb 'prevent under scrolling
  57.                 IF row > ub - 19 THEN row = ub - 19 'prevent over scrolling
  58.                 IF prevrow <> row THEN 'look for a change in row value
  59.                     IF row >= lb AND row <= ub - 19 THEN
  60.                         COLOR 15, 0
  61.                         CLS
  62.                         COLOR 0, 15: PRINT "press any key to quit scroller..."
  63.                         COLOR 15, 0
  64.                         LOCATE 2, 1
  65.                         FOR n = row TO row + 19
  66.                             COLOR arr(n).ink, arr(n).paper
  67.                             PRINT arr(n).s
  68.                         NEXT
  69.                     END IF
  70.                 END IF
  71.                 prevrow = row 'store previous row value
  72.             LOOP
  73.         END IF
  74.     LOOP UNTIL INKEY$ > ""
  75.  

  [ You are not allowed to view this attachment ]  
« Last Edit: September 17, 2019, 01:10:58 am by bplus »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • Steve’s QB64 Archive Forum
Re: Scroll Bar
« Reply #5 on: September 17, 2019, 02:12:57 am »
And here's a rather fancy example which does everything you mentioned, and more!

Code: QB64: [Select]
  1. DIM SHARED WorkScreen AS LONG, DisplayScreen AS LONG
  2.  
  3. WorkScreen = _NEWIMAGE(3600, 2400, 32) ' a nice large screen so we can scroll like crazy
  4. DisplayScreen = _NEWIMAGE(640, 480, 32) 'a nice small display screen
  5.  
  6. SCREEN DisplayScreen
  7. _DEST WorkScreen
  8. PRINT "Let's print all sorts of stuff on our workscreen, and make certain that it's more than long enough so that it'll scroll quite a ways across from the normal screen."
  9. LINE (400, 400)-(3000, 1200), &HFFFFFF00, BF
  10. FOR i = 1 TO 145
  11.     COLOR _RGB32(RND * 256, RND * 256, RND * 256), 0 'various colors for each line
  12.     PRINT "LINE #"; i; ".  This is just a bunch of junk for testing purposes only.  As you can see, if you want to read all the text from this line, you're going to have to scroll to see it all."
  13.  
  14.  
  15.  
  16.  
  17.  
  18. StartX = 0: StartY = 0: W = _WIDTH(DisplayScreen): H = _HEIGHT(DisplayScreen)
  19. _DEST DisplayScreen
  20.         temp = _NEWIMAGE(_RESIZEWIDTH, _RESIZEHEIGHT, 32)
  21.         SCREEN temp
  22.         _FREEIMAGE DisplayScreen
  23.         DisplayScreen = temp
  24.         W = _WIDTH(DisplayScreen): H = _HEIGHT(DisplayScreen)
  25.         _DELAY .25
  26.         junk = _RESIZE 'clear the resize flag after manually setting the screen to the size we specified.
  27.     END IF
  28.     _LIMIT 30
  29.     CLS
  30.     PRINT StartX, StartY
  31.     ScrollBar StartX, 2
  32.     ScrollBar StartY, 1
  33.  
  34.     k = _KEYHIT
  35.     SELECT CASE k
  36.         CASE ASC("A"), ASC("a"): StartX = StartX - 10: IF StartX < 0 THEN StartX = 0
  37.         CASE ASC("S"), ASC("s"): StartY = StartY + 10: IF StartY > _HEIGHT(WorkScreen) - H THEN StartY = _HEIGHT(WorkScreen) - H
  38.         CASE ASC("D"), ASC("d"): StartX = StartX + 10: IF StartX > _WIDTH(WorkScreen) - W THEN StartX = _WIDTH(WorkScreen) - W
  39.         CASE ASC("W"), ASC("w"): StartY = StartY - 10: IF StartY < 0 THEN StartY = 0
  40.     END SELECT
  41.     _PUTIMAGE (0, 0)-(W - 20, H - 20), WorkScreen, DisplayScreen, (StartX, StartY)-STEP(W, H)
  42.     _DISPLAY
  43.  
  44.  
  45.  
  46.  
  47.  
  48. SUB ScrollBar (Start, Direction)
  49.     D = _DEST: _DEST DisplayScreen 'our scrollbars show on the display
  50.     Min = 0
  51.     MaxH = _HEIGHT(DisplayScreen)
  52.     MaxW = _WIDTH(DisplayScreen)
  53.     H = _HEIGHT(WorkScreen)
  54.     W = _WIDTH(WorkScreen)
  55.     IF Direction = 1 THEN 'up/down bar
  56.         Box MaxW - 20, 0, 20, MaxH - 20, &HFF777777, &HFFFFFFFF
  57.         Box MaxW - 19, Start / H * MaxH, 18, MaxH / H * MaxH - 20, &HFFFF0000, 0 'Red with transparent
  58.     ELSE 'left/right bar
  59.         Box Min, MaxH - 20, MaxW - 20, 20, &HFF777777, &HFFFFFFFF 'Gray with white border
  60.         Box Start / W * MaxW, MaxH - 19, MaxW / W * MaxW - 20, 18, &HFFFF0000, 0 'Red with transparent
  61.     END IF
  62.     _DEST D
  63.  
  64.  
  65. SUB Box (x, y, wide, high, kolor AS _UNSIGNED LONG, border AS _UNSIGNED LONG)
  66.     LINE (x, y)-STEP(wide, high), kolor, BF
  67.     LINE (x, y)-STEP(wide, high), border, B
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Erum

  • Newbie
  • Posts: 10
Re: Scroll Bar
« Reply #6 on: September 17, 2019, 07:09:30 am »
Thank you all so much for the helpful and quick responses,
You all really helped me out. I will try each of the methods you mentioned and see which one works best for me.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
Re: Scroll Bar
« Reply #7 on: September 20, 2019, 08:04:14 am »
very fine Steve
at start I was stucked, no mouse, no arrow then I read code and I found ASDW
and I got this

  [ You are not allowed to view this attachment ]  

sorry Steve
I have added mouse (Left click to move left, right click to move right, upwheel to move up, downwheel to move down) and arrow keys

Code: QB64: [Select]
  1.     k = _KEYHIT
  2.         IF _MOUSEBUTTON(1) THEN k = ASC("A")
  3.         IF _MOUSEBUTTON(2) THEN k = ASC("d")
  4.         IF _MOUSEWHEEL < 0 THEN k = ASC("w") ELSE IF _MOUSEWHEEL > 0 THEN k = ASC("s")
  5.     WEND
  6.     SELECT CASE k
  7.         CASE ASC("A"), ASC("a"), 19200: StartX = StartX - 10: IF StartX < 0 THEN StartX = 0
  8.         CASE ASC("S"), ASC("s"), 20480: StartY = StartY + 10: IF StartY > _HEIGHT(WorkScreen) - H THEN StartY = _HEIGHT(WorkScreen) - H
  9.         CASE ASC("D"), ASC("d"), 19712: StartX = StartX + 10: IF StartX > _WIDTH(WorkScreen) - W THEN StartX = _WIDTH(WorkScreen) - W
  10.         CASE ASC("W"), ASC("w"), 18432: StartY = StartY - 10: IF StartY < 0 THEN StartY = 0
  11.     END SELECT
Programming isn't difficult, only it's  consuming time and coffee

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
Re: Scroll Bar
« Reply #8 on: September 20, 2019, 08:08:48 am »
Hi Bplus
 do you like manage only mouse wheel into your example!

  [ You are not allowed to view this attachment ]  
no keys no horizonthal scrolling... but so many colors!
Programming isn't difficult, only it's  consuming time and coffee

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
Re: Scroll Bar
« Reply #9 on: September 20, 2019, 08:18:21 am »
Hi Petr

I find you idea very interesting but I need to make a question...

  [ You are not allowed to view this attachment ]  

why do you choose to move cursor (pointer to item of list) when you reach the end of the list and not at first? I find more often this last behaviour of cursor.
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 #10 on: September 20, 2019, 09:05:51 am »
Hi Bplus
 do you like manage only mouse wheel into your example!

 (attachment=1,msg109613)
no keys no horizonthal scrolling... but so many colors!

Yes, just the mouse wheel for just displaying information, is what I like, who likes having to deal with horizontal scroll for reading a presentation?

Of course this is just a demo and all those colors and line numbers would be far too gaudy for a presentation of information. But color coding is a fine idea for the displaying of information and why I played off Bert22306's idea of testing fore and back colors to give a range of what is possible.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
Re: Scroll Bar
« Reply #11 on: September 20, 2019, 11:30:31 am »
Quote
TempodiBasic wrote:

why do you choose to move cursor (pointer to item of list) when you reach the end of the list and not at first? I find more often this last behaviour of cursor.


Hi Tempo, it was just a fast-paced program. Yeah you're right. You know what? I'll do the upgrade!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
Re: Scroll Bar
« Reply #12 on: September 20, 2019, 12:50:22 pm »
TempodiBasic,

Here it is. Notice the possibility of using the mouse wheel or a specific item with the mouse if you move the mouse into the item column. Keyboard control has been retained + added arrows, PgUp, PgDn, Home and End controls. The program has been redesigned as a function for better usability.

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

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Scroll Bar
« Reply #13 on: September 20, 2019, 01:43:57 pm »
Petr, that looks like great code for item selection from an array.

I would say perfect if it had easy method to color lines.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
Re: Scroll Bar
« Reply #14 on: September 20, 2019, 02:58:17 pm »
Hm, yes. This is solution for standard 2 colored scroll bar:

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