Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Pete

Pages: [1] 2 3 ... 9
1
QB64 Discussion / [fixed] Forum link needs updating...
« on: October 29, 2021, 08:32:42 pm »
QB64 V 2.0.1 Out Now
Click here to get it

That link goes to: V 1.4 https://github.com/QB64Team/qb64/releases/tag/v1.4

Correct link should be: https://github.com/QB64Team/qb64/releases/tag/v2.0.1

The link under the "The Team is on FIRE!" redirects properly to version 2.0.1. Could someone please put out the burning team member long enough to have the header link corrected?

Pete 😲🧯

2
QB64 Discussion / Inspired by bplus...
« on: October 25, 2021, 07:06:15 pm »
I don't often do graphics, but when I do... I really , really hate to do the grunt work. I had a lot of that with my Wheel of Fortune spoof, and then I participated in the thread where bplus was discussing a _FONT incompatibility issue in past QB64 versions. I've seen enough of Mark's apps to know he makes use of algorithms, often, to do the grunt work. Anyway, versions aside, I decided if I want to do any more graphics applications, I want to start with some algorithms like the one I wrote for this demo. It automatically determines where to draw boxes around letters, rather than trying to estimate or map them out.

Requires version 1.5 or above.

Code: QB64: [Select]
  1. DIM SHARED overlay
  2.  
  3. Screen0 = _NEWIMAGE(80, 25, 0)
  4. SCREEN Screen0
  5.  
  6. font = _LOADFONT("lucon.ttf", 60, "monospace")
  7. IF font <= 0 THEN font = 16
  8.  
  9. _DEST overlay
  10. _FONT font
  11. COLOR _RGB(255, 102, 0), 0
  12.  
  13. row = 2: col = 2: r1% = 255: r2% = 0: r3% = 0
  14. COLOR _RGB(255, 255, 255)
  15. text$ = "I'd like to solve the puzzle, please!"
  16. y = row: x = col
  17. FOR i = 1 TO LEN(text$)
  18.     IF (x + LEN(MID$(text$, i, INSTR(i, text$, " ") - i))) * _FONTWIDTH > _WIDTH THEN BEEP: x = 2: y = y + 2
  19.     t$ = MID$(text$, i, 1)
  20.     PSL y, x, t$, r1%, r2%, r3%
  21.     x = x + 1
  22.  
  23. _FREEIMAGE overlay
  24.  
  25. _DELAY .66
  26.  
  27.  
  28. SUB PSL (y, x, t$, r1%, r2%, r3%)
  29.     IF t$ <> CHR$(32) THEN CALL box(y, x, r1%, r2%, r3%)
  30.     _PRINTSTRING ((x - 1) * _FONTWIDTH, (y - 1) * _FONTHEIGHT), t$
  31.     overlay_hardware = _COPYIMAGE(overlay, 33)
  32.     _PUTIMAGE (0, 0), overlay_hardware
  33.     _DISPLAY
  34.  
  35. SUB box (y, x, r1%, r2%, r3%)
  36.     LINE ((x - 1) * _FONTWIDTH, ((y - 1) * _FONTHEIGHT))-((x - 1) * _FONTWIDTH + _FONTWIDTH, ((y - 1) * _FONTHEIGHT) + _FONTHEIGHT), _RGB(r1%, r2%, r3%), B , 255
  37.     overlay_hardware = _COPYIMAGE(overlay, 33)
  38.     _PUTIMAGE (0, 0), overlay_hardware
  39.     _DISPLAY

Pete

3
QB64 Discussion / Let's PLAY(0) Wheel of Fortune...
« on: October 21, 2021, 10:24:13 pm »

Code: QB64: [Select]
  1. DIM SHARED overlay
  2.  
  3. Screen0 = _NEWIMAGE(80, 25, 0)
  4. SCREEN Screen0
  5.  
  6. COLOR 8, 0
  7. FOR i = 1 TO 25
  8.     LOCATE i, 1: PRINT STRING$(80, 176);
  9.  
  10. font = _LOADFONT("lucon.ttf", 60, "monospace")
  11. IF font <= 0 THEN font = 16
  12.  
  13. _DEST overlay
  14. _FONT font
  15. COLOR _RGB(255, 102, 0), 0
  16.  
  17. b = 73
  18.  
  19. FOR i = 0 TO 7
  20.     IF i <> 4 THEN LINE (25 + i * b + 18, 55)-(76 + i * b + 18, 125 - 10), _RGB(255, 255, 255), B , 255
  21.  
  22. FOR i = 1 TO 5
  23.     LINE (25 + i * b + 54, 175)-(76 + i * b + 54, 245 - 10), _RGB(255, 255, 255), B , 255
  24.  
  25. Overlay_Hardware = _COPYIMAGE(overlay, 33)
  26. _PUTIMAGE (0, 0), Overlay_Hardware
  27.  
  28.  
  29. FOR i = 1 TO 8
  30.     READ z$, q, w
  31.     t$(i) = z$: q(i) = q: w(i) = w
  32.  
  33. FOR i = 1 TO 8
  34.     FOR j = 1 TO 8
  35.         IF i <> j THEN
  36.             IF q(i) < q(j) THEN SWAP t$(i), t$(j): SWAP q(i), q(j): SWAP w(i), w(j)
  37.         END IF
  38.     NEXT
  39.  
  40. FOR h = 1 TO 8
  41.     IF w(h) < 10 THEN
  42.         t$ = t$(h)
  43.         x = 2.5 + (w(h) - 1) * 2: y = 2
  44.         PSL y, x, t$
  45.     ELSE
  46.         t$ = t$(h)
  47.         x = 3.5 + (w(h) - 9) * 2: y = 4
  48.         PSL y, x, t$
  49.     END IF
  50.     IF h <> 2 THEN _DELAY 3
  51.  
  52. y = 20: x = 23
  53. COLOR _RGB(255, 255, 255)
  54. t$ = "I'd like to solve the puzzle, please!"
  55. PSL y, x, t$
  56.  
  57.  
  58.  
  59. _DEST overlay
  60.  
  61. COLOR _RGB(255, 102, 0), 0
  62.  
  63. x = 0: y = 0: t$ = ""
  64. font = _LOADFONT("lucon.ttf", 60, "monospace")
  65. IF font <= 0 THEN font = 16
  66. _FONT font
  67.  
  68. a$ = CHR$(76) + CHR$(101) + CHR$(116) + "'" + CHR$(115) + CHR$(32) + CHR$(71) + CHR$(111) + CHR$(32) + CHR$(66) + CHR$(114) + CHR$(97) + CHR$(110) + CHR$(100) + CHR$(111) + CHR$(110) + "!"
  69. m$ = "MBn29L3n24L3n33L3n29L4"
  70.  
  71.     IF seed% = 0 THEN PLAY m$
  72.     y = 150: x = 8 + x + LEN(t$) * 36
  73.     t$ = MID$(a$ + " ", seed%, INSTR(seed%, a$ + " ", " ") - seed% + 1)
  74.     _PRINTSTRING (x, y), RTRIM$(t$)
  75.     Overlay_Hardware = _COPYIMAGE(overlay, 33)
  76.     _PUTIMAGE (0, 0), Overlay_Hardware
  77.     _DISPLAY
  78.     IF seed% < LEN(a$) THEN
  79.         seed% = INSTR(seed%, a$ + " ", " ") + 1
  80.         _DELAY .66
  81.     ELSE
  82.         _DELAY .66: CLS: _DISPLAY: seed% = 0: x = 0: _DELAY 1.33
  83.     END IF
  84. _FREEIMAGE overlay
  85.  
  86. _DELAY .66
  87.  
  88.  
  89. DATA C,8,3
  90. DATA K,4,4
  91. DATA B,7,10
  92. DATA J,5,6
  93. DATA F,1,1
  94. DATA E,2,8
  95. DATA N,6,14
  96. DATA E,3,13
  97.  
  98. SUB PSL (y, x, t$)
  99.     _PRINTSTRING ((x - 1) * _FONTWIDTH, (y - 1) * _FONTHEIGHT), t$
  100.     overlay_hardware = _COPYIMAGE(overlay, 33)
  101.     _PUTIMAGE (0, 0), overlay_hardware
  102.     _DISPLAY

Well, on a serious "note," It's a shame QB64 was not able to get the PLAY(0) function implemented. PLAY(0) was a QB / QuickBASIC function that tracked the number notes (up to 36) in the buffer if the MB handle was used to tell PLAY to play the notes in the background. You could use it to figure out where you were in a music loop, or when the last note ended. Very useful.

So my question is probably to @SpriggsySpriggs

Is there a Windows API method to track the sound buffer, or at least to tell us when sound playing sound / music in the background has completed? 

Pete

4
QB64 Discussion / Really? Does _PRINTSTRING have lag issues? [SOLVED]
« on: October 19, 2021, 02:16:41 pm »
This is just for testing. I'm using _PRINTSTRING to write to a hardware overlay. Now in SCREEN 0, this type of letter printing works properly, but _PRINTSTRING seems to have lag, which throws off the timer.

If you try the code, you will need to hold down alt, and it will start printing the alphabet. The problem... what comes after J? O_ay, I'm just _idding. The problem is this: It should print each character with a .4 sec delay between characters. On my machine, it seems to lag around "M" "N" or "P" and then some buffer effect causes it to print two letters together. Now if you use this to print one letter over the other, instead of in a line, that makes it appear like it misses a letter. In other words A-M appears one letter at a time, but N and O get buffered together, so the user sees O as the next letter, instead of N. This is why, for this example, I put the display in a line, so you could see the lag/buffering issue more clearly. Do a REPLACE: [nxt + i] to: [nxt] if you want to see the letters print over themselves.

So, is there a way around this lag issue? 

Code: QB64: [Select]
  1. Screen0 = _NEWIMAGE(80, 25, 0)
  2. SCREEN Screen0
  3. swidth = _WIDTH
  4.  
  5. DIM SHARED Overlay
  6.  
  7. DIM SHARED lmargin%, rmargin%, topmargin%, screenwidth%, level, ibk, ileadingrow
  8. DIM SHARED irow, icol, inextrnd, imaxalienmissiles, alienforce%, ileadingmax, imaxalienforce, ihits, score$
  9.  
  10.  
  11.  
  12. _DEST Overlay
  13.  
  14. font = _LOADFONT("lucon.ttf", 20, "monospace")
  15. IF font <= 0 THEN font = 16
  16. _FONT font
  17.  
  18. bxy% = 3.5
  19. bxx% = 13 '27
  20. COLOR DarkOrange, 0
  21. t$ = " " + CHR$(218) + STRING$(27, CHR$(196)) + CHR$(191) + " "
  22. PSL bxy%, bxx% - 1, t$
  23. FOR i = 1 TO 11
  24.     t$ = " " + CHR$(179) + STRING$(27, CHR$(32)) + CHR$(179) + " "
  25.     PSL bxy% + i, bxx% - 1, t$
  26. t$ = " " + CHR$(192) + STRING$(27, CHR$(196)) + CHR$(217) + " "
  27. PSL bxy% + i, bxx% - 1, t$
  28.  
  29. COLOR Black, DarkOrange
  30. t$ = "    NAME   SCORE    DATE   "
  31. PSL bxy% + 1, bxx% + 1, t$
  32.  
  33. COLOR DarkOrange, 0
  34. FOR i = 1 TO 5
  35.     t$ = hsdata$(i)
  36.     PSL bxy% + 1 + i * 2, bxx% + 1, t$
  37.  
  38.  
  39. DEF SEG = 0
  40. initials$ = "": delay = .4
  41. i = 0
  42. bar$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + CHR$(27) + CHR$(27) + CHR$(27)
  43. lscr = 14
  44.     IF PEEK(1047) MOD 16 = 7 OR PEEK(1047) MOD 16 = 8 THEN
  45.         DO
  46.             i = i + 1
  47.             COLOR , Black: t$ = " "
  48.             PSL 6 + rank * 2, lscr + nxt, t$
  49.             IF MID$(bar$, i, 1) = CHR$(27) AND LEN(initials$) = 0 THEN i = 1 ' No go back symbol shown on first initial.
  50.             IF i > LEN(bar$) THEN i = 1
  51.             COLOR DarkOrange: t$ = MID$(bar$, i, 1)
  52.             PSL 6 + rank * 2, lscr + nxt + i, t$
  53.             z1 = TIMER
  54.             IF LEN(initials$) = 3 THEN
  55.                 bar$ = CHR$(27) + CHR$(26) + CHR$(26) + CHR$(26) + CHR$(27)
  56.             END IF
  57.             DO UNTIL ABS(TIMER - z1) > delay
  58.                 IF PEEK(1047) MOD 16 <> 7 AND PEEK(1047) MOD 16 <> 8 THEN
  59.                     IF MID$(bar$, i, 1) = CHR$(26) THEN
  60.                         ''''''''PRINT " ";
  61.                         COLOR , Black: t$ = " "
  62.                         PSL 6 + rank * 2, lscr + nxt, t$
  63.                         COLOR DarkOrange
  64.                         flag = -999
  65.                         EXIT DO
  66.                     END IF
  67.                     IF MID$(bar$, i, 1) = CHR$(27) THEN
  68.                         IF LEN(initials$) THEN
  69.                             i = ASC(RIGHT$(initials$, 1)) - 66: IF i < 0 THEN i = 0
  70.                             initials$ = MID$(initials$, 1, LEN(initials$) - 1)
  71.                             COLOR , Black: t$ = " "
  72.                             PSL 6 + rank * 2, lscr + nxt, t$
  73.                             COLOR DarkOrange
  74.                             nxt = nxt - 1
  75.  
  76.                             flag = -2
  77.                         END IF
  78.                     ELSE
  79.                         initials$ = initials$ + MID$(bar$, i, 1)
  80.                         bar$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + CHR$(27) + CHR$(27) + CHR$(27)
  81.                         i = 26
  82.                         flag = -1
  83.                     END IF
  84.                     EXIT DO
  85.                 END IF
  86.             LOOP
  87.             IF flag THEN EXIT DO
  88.         LOOP
  89.         IF flag = -999 THEN flag = 0: EXIT DO
  90.         IF flag <> -2 THEN
  91.             IF MID$(bar$, i, 1) <> CHR$(27) THEN nxt = nxt + 1 ELSE i = 0
  92.         END IF
  93.     ELSE
  94.         _DELAY .5
  95.     END IF
  96.     flag = 0
  97.  
  98. SUB PSL (y, x, t$)
  99.     _PRINTSTRING ((x - 1) * _FONTWIDTH, (y - 1) * _FONTHEIGHT), t$
  100.     Overlay_Hardware = _COPYIMAGE(Overlay, 33)
  101.  
  102.     _PUTIMAGE (0, 0), Overlay_Hardware
  103.     _DISPLAY
  104.  
  105.  

Pete

EDIT SOLVED!

Code: QB64: [Select]
  1. Screen0 = _NEWIMAGE(80, 25, 0)
  2. SCREEN Screen0
  3. swidth = _WIDTH
  4.  
  5. DIM SHARED Overlay
  6.  
  7. DIM SHARED lmargin%, rmargin%, topmargin%, screenwidth%, level, ibk, ileadingrow
  8. DIM SHARED irow, icol, inextrnd, imaxalienmissiles, alienforce%, ileadingmax, imaxalienforce, ihits, score$
  9.  
  10.  
  11.  
  12. _DEST Overlay
  13.  
  14. font = _LOADFONT("lucon.ttf", 20, "monospace")
  15. IF font <= 0 THEN font = 16
  16. _FONT font
  17.  
  18. bxy% = 3.5
  19. bxx% = 13 '27
  20. COLOR DarkOrange, 0
  21. t$ = " " + CHR$(218) + STRING$(27, CHR$(196)) + CHR$(191) + " "
  22. PSL bxy%, bxx% - 1, t$
  23. FOR i = 1 TO 11
  24.     t$ = " " + CHR$(179) + STRING$(27, CHR$(32)) + CHR$(179) + " "
  25.     PSL bxy% + i, bxx% - 1, t$
  26. t$ = " " + CHR$(192) + STRING$(27, CHR$(196)) + CHR$(217) + " "
  27. PSL bxy% + i, bxx% - 1, t$
  28.  
  29. COLOR Black, DarkOrange
  30. t$ = "    NAME   SCORE    DATE   "
  31. PSL bxy% + 1, bxx% + 1, t$
  32.  
  33. COLOR DarkOrange, 0
  34. FOR i = 1 TO 5
  35.     t$ = hsdata$(i)
  36.     PSL bxy% + 1 + i * 2, bxx% + 1, t$
  37.  
  38.  
  39. DEF SEG = 0
  40. initials$ = "": delay = .4
  41. i = 0
  42. bar$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + CHR$(27) + CHR$(27) + CHR$(27)
  43. lscr = 14
  44.     IF PEEK(1047) MOD 16 = 7 OR PEEK(1047) MOD 16 = 8 THEN
  45.         DO
  46.             i = i + 1
  47.             COLOR , Black: t$ = " "
  48.             PSL 6 + rank * 2, lscr + nxt, t$
  49.             IF MID$(bar$, i, 1) = CHR$(27) AND LEN(initials$) = 0 THEN i = 1 ' No go back symbol shown on first initial.
  50.             IF i > LEN(bar$) THEN i = 1
  51.             COLOR DarkOrange: t$ = MID$(bar$, i, 1)
  52.             PSL 6 + rank * 2, lscr + nxt + i, t$
  53.             z1 = TIMER
  54.             IF LEN(initials$) = 3 THEN
  55.                 bar$ = CHR$(27) + CHR$(26) + CHR$(26) + CHR$(26) + CHR$(27)
  56.             END IF
  57.             _DISPLAY ' <-------------------------Moved it here from the sub.
  58.             DO UNTIL ABS(TIMER - z1) > delay
  59.                 IF PEEK(1047) MOD 16 <> 7 AND PEEK(1047) MOD 16 <> 8 THEN
  60.                     IF MID$(bar$, i, 1) = CHR$(26) THEN
  61.                         ''''''''PRINT " ";
  62.                         COLOR , Black: t$ = " "
  63.                         PSL 6 + rank * 2, lscr + nxt, t$
  64.                         COLOR DarkOrange
  65.                         flag = -999
  66.                         EXIT DO
  67.                     END IF
  68.                     IF MID$(bar$, i, 1) = CHR$(27) THEN
  69.                         IF LEN(initials$) THEN
  70.                             i = ASC(RIGHT$(initials$, 1)) - 66: IF i < 0 THEN i = 0
  71.                             initials$ = MID$(initials$, 1, LEN(initials$) - 1)
  72.                             COLOR , Black: t$ = " "
  73.                             PSL 6 + rank * 2, lscr + nxt, t$
  74.                             COLOR DarkOrange
  75.                             nxt = nxt - 1
  76.  
  77.                             flag = -2
  78.                         END IF
  79.                     ELSE
  80.                         initials$ = initials$ + MID$(bar$, i, 1)
  81.                         bar$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + CHR$(27) + CHR$(27) + CHR$(27)
  82.                         i = 26
  83.                         flag = -1
  84.                     END IF
  85.                     EXIT DO
  86.                 END IF
  87.             LOOP
  88.             IF flag THEN EXIT DO
  89.         LOOP
  90.  
  91.         IF flag = -999 THEN flag = 0: EXIT DO
  92.         IF flag <> -2 THEN
  93.             IF MID$(bar$, i, 1) <> CHR$(27) THEN nxt = nxt + 1 ELSE i = 0
  94.         END IF
  95.     ELSE
  96.         _DELAY .5
  97.     END IF
  98.     flag = 0
  99.  
  100. SUB PSL (y, x, t$)
  101.     _PRINTSTRING ((x - 1) * _FONTWIDTH, (y - 1) * _FONTHEIGHT), t$
  102.     Overlay_Hardware = _COPYIMAGE(Overlay, 33)
  103.  
  104.     _PUTIMAGE (0, 0), Overlay_Hardware
  105.  
  106.     ' --------------> Moved this out of sub and into main: _DISPLAY
  107.  

I had to move the _DISPLAY out of the sub, for some reason I still haven't figured out. I just took a shot at it. Bullet casings everywhere!

Edit: Well moving did cut the number of _DISPLAY calls in half, if that was the issue. Now it prints the blank space and then the next letter before it cycles to _DISPLAY again. Before, it printed the blank character, displayed it, and then the next character, and displayed it. Weird. Graphics stuff is just weird. SCREEN 0 up Mr. Sulu, and phasers on _FULLSCREEN.

Pete out

5
QB64 Discussion / If I posted it once, I posted it a thousand times...
« on: October 18, 2021, 01:05:39 pm »
Ad - Tired of seeing yet another thread about string math? Tired of waking up in the morning and saying, "Where in the hell is the the last thread this discussion was posted in? Well, now you don't have to worry ever again thanks to the newest forum feature, Post Away! Post Away is a quantum age bot that automatically dissolves even the toughest most persistent duplicate posts; leaving us with a clean single-subject thread, with no clutter, or off-topic interference. So pick up a zip file of Post-Away today, and you'll be on your way to cleaner, brighter forum threads in no time!

Man, I knew Fell was looking for ways to raise cash, but since when did he start allowing ads on the forum? Anyway, kidding aside, here's how we handled this on the QBasic Forum...

1) Created a F.A.Q. sub-forum: This sub-forum could include a question followed by copies of various coding solutions posted from various threads. I would not recommend using links because posts could be modified by authors and it's just about as fast to cut and paste the code, and it's easier for the user to have it all presented on the same page, anyway. [I would say our LEARNING sub-forum is similar.]

2) Created a Programs I am Proud of sub-forum. This forum gave privileges to forum regulars to showcase their finest work by both author and subject. Now Fell and the Librarians (sounds like a rock group I'd listen too) have already created the SAMPLES sub-forum, and it's really good.  I especially like how it links to the discussions that were involved in the development of the project, thereby preserving the history, but the addition of a "Proud of" sub-forum would give active members a place to showcase their finest works, and a sub-forum visitors could pointed to for working solutions and code snippets and samples. [I would say our SAMPLES sub-forum is similar.]

The one thing I would not recommend would be what I call "Mac's Dream." Mac hated clutter, but he was wise enough to realize the organic nature of members and if he had run the forum that way, he would have also ran off the talent providing most of the content. In other words when admins or owners make it to uptight of a place to post, members leave. So it's really always a balancing act. I mean you go too far in the other direction,  you get so much irrelevance in a post that newcomers don't see a point in staying.

Anyway, since a Librarian mentioned this topic in an unrelated thread, which would have him banned for life on that nightmare of a "Dream Forum" I mentioned, I'd thought I open it up for a discussion here.  Sorry Google! Oh, and in regard to search engines, using <strong> tags and h1, h2 headings is probably enough to help bump up the search results on a more organized sub-forum board, which would take the pressure off to move or delete repeated posts through out the other sub-forums.

Pete 

This message was brought to you by Post Away. Now available in MicroSoft stores, everywhere.


6
I've never had this happen before. I've had to set the IDE colors every time I open a new instance of the V2.0 IDE. For whatever reason, I can't get the changes I make and save to load on the next instance. The changes do take effect while the IDE is open, but get this...

I open an IDE instance called untitled(4) and it is in the default color scheme. I change the color scheme and save it. Now I cut the text and close the IDE. Now I open the IDE and it opens AS CHANGED, so far, so good, and I paste the text back in. Oh, but now I click my desktop shortcut, to open untitled(5) and guess what? It opens up back in that default dark blue background with all the other default options, ignoring all the changes I previously made. Nothing I saved is being applied. Am I somehow missing a new hoop I need to jump through to make these changes on every IDE instance? If so, I can't find it.

Pete

7
QB64 Discussion / Is this at all possible in SCREEN 0?
« on: October 15, 2021, 10:49:43 pm »
Is there anyway in SCREEN 0 to make a screen overlay, and I'll attempt to explain.

A program has a window with a black background and multi-colored ascii images on it. Next step, make the characters on the screen grey, that's the easy part.... Next somehow make this grey on black screen a background image. Final step, write on top of that scree with translucent lettering, so the background bleeds through. This is easy to accomplish in HTML. Any chance it can be done in QB64?

Note: This is different than using two screens to make a popup window, although if that popup window could have a translucent background, I don't know, maybe that would work. But as a solid background, it's just a popup window that obliterates everything behind it. That I could do, but I'd rather have the overlay effect, if possible.

Pete

8
QB64 Discussion / Welcome DeltaOscarSierra
« on: October 08, 2021, 12:03:50 pm »
I had to post a welcome, because I love the handle... DOS.

Pete

9
QB64 allows this to run...

Code: QB64: [Select]
  1. DIM a$(100)
  2. a$(11) = "x"
  3. PRINT a$(11)
  4. PRINT a$(11)

QB does not, throwing a subscript out of range error at line 5.

Note that both QB64 and QB throw that error if REDIM is used instead of DIM...

Code: QB64: [Select]
  1. ]REDIM a$(100)
  2. a$(11) = "x"
  3. PRINT a$(11)
  4. PRINT a$(11)

Pete

Edit: It turned out I made some sort of error. I retyped the code in QuickBASIC, and the DIM example worked the same as QB64.

10
QB64 Discussion / Mighty Menu?
« on: October 06, 2021, 06:22:00 pm »
I bet Steve is getting mighty tired of these menu titles, but since we are on the subject of menus...

Code: QB64: [Select]
  1. REM mydemo% = -1
  2. DIM UI AS UserInput
  3. REDIM Menu$(100)
  4.  
  5. TYPE UserInput
  6.     KeyPress AS STRING
  7.     KeyCombos AS INTEGER
  8.     MbStatus AS INTEGER
  9.     MbEnvoked AS INTEGER
  10.     drag AS INTEGER
  11.     DoubleClick AS INTEGER
  12.     MbLeftx AS INTEGER
  13.     MbLefty AS INTEGER
  14.     mx AS INTEGER
  15.     oldmx AS INTEGER
  16.     my AS INTEGER
  17.     oldmy AS INTEGER
  18.  
  19. IF demo% THEN PRINT "Press keys or use mouse for demo.";
  20.     MenuSetup = MenuSetup + 1: GOSUB MenuSetup
  21.     DO
  22.         CALL keyboard_mouse(UI, mydemo%)
  23.         IF UI.MbStatus < 0 AND UI.MbEnvoked = 0 THEN
  24.             SOUND 1000, .1
  25.             UI.MbEnvoked = -1
  26.         END IF
  27.  
  28.         SELECT CASE UI.MbStatus
  29.             CASE -1
  30.                 GOSUB FindMenu
  31.  
  32.                 SELECT CASE x$
  33.                     CASE Menu$(1)
  34.                         LOCATE 1, 1: PRINT Menu$(1); "                  ";
  35.                         _DELAY 2
  36.                         EXIT DO
  37.                     CASE Menu$(2)
  38.                         LOCATE 1, 1: PRINT Menu$(2); "                  ";
  39.                     CASE Menu$(3)
  40.                         LOCATE 1, 1: PRINT Menu$(3); "                  ";
  41.                     CASE Menu$(4)
  42.                         LOCATE 1, 1: PRINT Menu$(4); "                  ";
  43.                     CASE Menu$(5)
  44.                         END
  45.                 END SELECT
  46.  
  47.         END SELECT
  48.     LOOP
  49. LOOP UNTIL MenuSetup = 2
  50.  
  51. MenuSetup:
  52. SELECT CASE MenuSetup
  53.     CASE 1
  54.         MenuType% = 1
  55.         DrawBox% = -1
  56.         MenuX = 0 ' Auto-Center
  57.         MenuY = 0 ' Auto-Center
  58.         Menu$(1) = "[Enter] Next Menu"
  59.         Menu$(2) = "[F1] Help"
  60.         Menu$(3) = "[F5] Save"
  61.         Menu$(4) = "[F12] Run Demo"
  62.         Menu$(5) = "[Esc] End"
  63.         Menu$(6) = ""
  64.         Menu$(7) = ""
  65.         Menu$(8) = ""
  66.         Menu$(9) = ""
  67.         Menu$(10) = ""
  68.     CASE 2
  69.         MenuType% = 2
  70.         DrawBox% = 0
  71.         MenuX = 0 ' Auto-Center
  72.         MenuY = 0 ' Auto-Center
  73.         Menu$(1) = "[Enter] Next Menu"
  74.         Menu$(2) = "[F1] Help"
  75.         Menu$(3) = "[F5] Save"
  76.         Menu$(4) = "[F12] Run Demo"
  77.         Menu$(5) = "[Esc] End"
  78.         Menu$(6) = ""
  79.         Menu$(7) = ""
  80.         Menu$(8) = ""
  81.         Menu$(9) = ""
  82.         Menu$(10) = ""
  83.  
  84. FOR noe = UBOUND(Menu$) TO 1 STEP -1
  85.     IF LEN(Menu$(noe)) THEN EXIT FOR
  86.  
  87. SELECT CASE MenuType%
  88.     CASE 1
  89.         x = 0
  90.         FOR i = 1 TO noe
  91.             IF LEN(Menu$(i)) > x THEN x = LEN(Menu$(i))
  92.         NEXT
  93.  
  94.         IF MenuX = 0 THEN MenuX = INT(_WIDTH / 2 + 1 - (x / 2))
  95.         IF MenuY = 0 THEN MenuY = INT(_HEIGHT / 2 - (noe / 2) - 1)
  96.  
  97.         IF DrawBox% THEN GOSUB DrawBox
  98.  
  99.         FOR i = 1 TO noe
  100.             LOCATE MenuY + i - 1, MenuX
  101.             PRINT Menu$(i);
  102.         NEXT
  103.     CASE 2
  104.         Menu$ = "": x$ = "": k = 0
  105.         FOR i = 1 TO noe
  106.             IF LEN(Menu$(i)) THEN
  107.                 k = k + 1: Menu$ = Menu$ + CHR$(255) + Menu$(i)
  108.             END IF
  109.         NEXT
  110.         j = (_WIDTH - LEN(Menu$)) \ k
  111.         IF j > 5 THEN j = 5
  112.         Menu$ = MID$(Menu$, 2) + CHR$(255)
  113.         DO UNTIL INSTR(Menu$, CHR$(255)) = 0
  114.             a$ = CHR$(255) + MID$(Menu$, 1, INSTR(Menu$, CHR$(255)) - 1) 'SPACE$(j)
  115.             Menu$ = MID$(Menu$, INSTR(Menu$, CHR$(255)) + 1)
  116.             x$ = x$ + a$ + SPACE$(j)
  117.         LOOP
  118.         Menu$ = _TRIM$(x$)
  119.         CLS
  120.         LOCATE _HEIGHT, _WIDTH \ 2 - LEN(Menu$) \ 2
  121.         PRINT Menu$;
  122.  
  123. DrawBox:
  124. LOCATE MenuY - 1, MenuX - 2
  125. PRINT CHR$(218) + STRING$(x + 2, 196) + CHR$(191)
  126. FOR i = 1 TO noe
  127.     LOCATE , MenuX - 2
  128.     PRINT CHR$(179);: LOCATE , POS(0) + x + 2: PRINT CHR$(179)
  129. LOCATE , MenuX - 2
  130. PRINT CHR$(192) + STRING$(x + 2, 196) + CHR$(217);
  131.  
  132. FindMenu:
  133. SELECT CASE MenuType%
  134.     CASE 0
  135.         CLS: PRINT "You did not assign a value to the variable: MenuType": END '''
  136.     CASE 1 ' Vertical
  137.         IF UI.my >= MenuY AND UI.my <= MenuY + noe - 1 THEN
  138.             x$ = ""
  139.             FOR i = MenuX TO MenuX + x
  140.                 a$ = CHR$(SCREEN(UI.my, i))
  141.                 x$ = x$ + a$
  142.                 IF flag = 0 THEN IF a$ <> " " THEN flag = i
  143.             NEXT
  144.             x$ = _TRIM$(x$)
  145.             IF UI.mx >= flag AND UI.mx <= flag + LEN(x$) THEN
  146.                 IF VAL(x$) THEN x$ = LTRIM$(STR$(VAL(x$)))
  147.             END IF
  148.             flag = 0
  149.         END IF
  150.     CASE 2 ' Horizontal
  151.         x$ = ""
  152.         FOR i = 1 TO _WIDTH
  153.             a$ = CHR$(SCREEN(UI.my, i))
  154.             x$ = x$ + a$
  155.         NEXT
  156.         x$ = CHR$(255) + x$ + CHR$(255)
  157.         x$ = _TRIM$(MID$(x$, 1, INSTR(UI.mx + 1, x$, CHR$(255)) - 1))
  158.         IF LEN(x$) <= UI.mx THEN
  159.             x$ = "" ' Mouse is not on a menu item.
  160.         ELSE
  161.             x$ = _TRIM$(MID$(x$, _INSTRREV(x$, CHR$(255)) + 1))
  162.         END IF
  163.     CASE ELSE
  164.         CLS: PRINT "You assigned a value to MenuType that was out-of-range.": END '''
  165.  
  166. SUB keyboard_mouse (UI AS UserInput, mydemo%)
  167.     STATIC z1, lclick
  168.  
  169.     _LIMIT 30
  170.  
  171.     DEF SEG = 0
  172.     IF PEEK(1047) MOD 16 = 1 OR PEEK(1047) MOD 16 = 2 THEN
  173.         UI.KeyCombos = 1 ' Shift  % = -1 ELSE shift% = 0
  174.     ELSEIF PEEK(1047) MOD 16 = 3 OR PEEK(1047) MOD 16 = 4 THEN
  175.         UI.KeyCombos = 2 ' Ctrl  % = -1 ELSE ctrl% = 0
  176.     ELSEIF PEEK(1047) MOD 16 = 7 OR PEEK(1047) MOD 16 = 8 THEN
  177.         UI.KeyCombos = 3 ' Alt  % = -1
  178.     ELSEIF PEEK(1047) MOD 16 = 5 OR PEEK(1047) MOD 16 = 6 THEN
  179.         UI.KeyCombos = 4 ' Ctrl+Shift  % = -1 ELSE ctrlshift% = 0
  180.     ELSE
  181.         UI.KeyCombos = 0
  182.     END IF
  183.     DEF SEG
  184.  
  185.     IF mydemo% THEN GOSUB check_UI.KeyCombos
  186.  
  187.     UI.KeyPress = INKEY$
  188.     IF LEN(UI.KeyPress) THEN ' A key was pressed.
  189.         UI.MbEnvoked = 0: UI.MbLeftx = 0
  190.         SELECT CASE LEN(UI.KeyPress)
  191.             CASE 1 ' 1-byte key A-Z, etc.
  192.                 IF mydemo% THEN mydemo% = 1: GOSUB mydemo
  193.                 SELECT CASE UI.KeyPress
  194.                     ' Place key selection routine here...
  195.                     CASE CHR$(27): SYSTEM
  196.                 END SELECT
  197.             CASE 2 '2-byte key F1-F12, etc.
  198.                 IF mydemo% THEN mydemo% = 2: GOSUB mydemo
  199.                 SELECT CASE RIGHT$(UI.KeyPress, 1)
  200.                     ' Place key selection routine here...
  201.                 END SELECT
  202.         END SELECT
  203.     ELSE ' Check for mouse input since no keyboard input was detected.
  204.  
  205.         IF lclick THEN ' Check timer for double-clicks.
  206.             IF TIMER < z1 THEN z1 = z1 - 86400 ' Midnight adjustment.
  207.             IF TIMER - z1 > .33 THEN lclick = 0 ' Too much time ellapsed for a double click.
  208.         END IF
  209.  
  210.         WHILE _MOUSEINPUT
  211.             mw = mw + _MOUSEWHEEL ' Check for mouse wheel use.
  212.         WEND
  213.  
  214.         ' Get mouse status.
  215.         UI.mx = _MOUSEX
  216.         UI.my = _MOUSEY
  217.         lb = _MOUSEBUTTON(1)
  218.         rb = _MOUSEBUTTON(2)
  219.         mb = _MOUSEBUTTON(3)
  220.  
  221.         SELECT CASE UI.MbEnvoked
  222.             CASE 0
  223.                 IF lb OR rb OR mb THEN
  224.  
  225.                 END IF
  226.             CASE 1
  227.                 IF lb OR rb OR mb THEN UI.MbEnvoked = 0
  228.             CASE -1
  229.                 IF lb = 0 AND rb = 0 AND mb = 0 THEN UI.MbEnvoked = 0
  230.         END SELECT
  231.  
  232.         IF UI.MbStatus < 0 THEN ' Mouse button pressed. UI.MbStatus identity is by number. -1=left, -2=right, -3=middle.
  233.             SELECT CASE UI.MbStatus
  234.                 CASE -1 ' Left button was pressed.
  235.                     IF lb = 0 THEN ' Left button released.
  236.                         SELECT CASE lclick ' Single or double click analysis.
  237.                             CASE 0
  238.                                 IF mydemo% THEN mydemo% = 3: GOSUB mydemo
  239.                                 lclick = lclick + 1
  240.                             CASE ELSE ' Double click. Completed upon 2nd left button release.
  241.                                 IF mydemo% THEN mydemo% = 11: GOSUB mydemo
  242.                                 UI.DoubleClick = -1
  243.                                 lclick = 0
  244.                         END SELECT
  245.                         UI.MbStatus = 1
  246.  
  247.                         IF UI.MbLeftx THEN
  248.                             IF UI.mx <> UI.MbLeftx OR UI.my <> UI.MbLefty THEN UI.MbStatus = 0: lclick = 0
  249.                             UI.MbLeftx = 0: UI.MbLefty = 0
  250.                         END IF
  251.  
  252.                         IF UI.drag THEN UI.drag = 0
  253.                     ELSE ' Left button is being held down. Check for UI.drag.
  254.                         IF UI.mx <> UI.oldmx OR UI.my <> UI.oldmy THEN ' Mouse cursor has moved. UI.drag.
  255.                             IF mydemo% THEN mydemo% = 12: GOSUB mydemo
  256.                             UI.drag = -1
  257.                         END IF
  258.                     END IF
  259.                 CASE -2 ' Right button was pressed.
  260.                     IF rb = 0 THEN ' Right button was relased.
  261.                         IF mydemo% THEN mydemo% = 4: GOSUB mydemo
  262.                         UI.MbStatus = 2
  263.                     END IF
  264.                 CASE -3 ' Middle button was pressed
  265.                     IF mb = 0 THEN ' Middle button was released.
  266.                         IF mydemo% THEN mydemo% = 5: GOSUB mydemo
  267.                         UI.MbStatus = 3
  268.                     END IF
  269.             END SELECT
  270.         ELSE
  271.             IF lb THEN ' Left button just pressed.
  272.                 IF mydemo% THEN mydemo% = 6: GOSUB mydemo
  273.                 UI.MbStatus = -1
  274.                 IF UI.MbLeftx = 0 THEN UI.MbLeftx = UI.mx: UI.MbLefty = UI.my
  275.                 z1 = TIMER
  276.             ELSEIF rb THEN ' Right button just pressed.
  277.                 IF mydemo% THEN mydemo% = 7: GOSUB mydemo
  278.                 IF UI.MbLeftx = 0 THEN UI.MbLeftx = UI.mx: UI.MbLefty = UI.my
  279.                 UI.MbStatus = -2
  280.             ELSEIF mb THEN ' Middle button just pressed.
  281.                 IF mydemo% THEN mydemo% = 8: GOSUB mydemo
  282.                 IF UI.MbLeftx = 0 THEN UI.MbLeftx = UI.mx: UI.MbLefty = UI.my
  283.                 UI.MbStatus = -3
  284.             ELSEIF mw THEN ' Mouse wheel just moved.
  285.                 SELECT CASE mw
  286.                     CASE IS > 0 ' Scroll down.
  287.                         IF mydemo% THEN mydemo% = 9: GOSUB mydemo
  288.                     CASE IS < 0 ' Scroll up.
  289.                         IF mydemo% THEN mydemo% = 10: GOSUB mydemo
  290.                 END SELECT
  291.             END IF
  292.         END IF
  293.  
  294.         UI.oldmx = UI.mx: UI.oldmy = UI.my: mw = 0 ' Mouse position past and present.
  295.     END IF
  296.     EXIT SUB
  297.  
  298.     mydemo:
  299.     LOCATE 1, 1: PRINT "Last User Status:                                    ";
  300.     LOCATE , 19
  301.     SELECT CASE mydemo%
  302.         CASE 1
  303.             PRINT "1-byte Key = "; UI.KeyPress
  304.         CASE 2
  305.             PRINT "2-byte Key = "; UI.KeyPress
  306.         CASE 3
  307.             PRINT "Left button released."
  308.         CASE 4
  309.             PRINT "Right button released."
  310.         CASE 5
  311.             PRINT "Middle button released."
  312.         CASE 6
  313.             PRINT "Left button down."
  314.         CASE 7
  315.             PRINT "Right button down."
  316.         CASE 8
  317.             PRINT "Middle button down."
  318.         CASE 9
  319.             PRINT "Wheel scroll down."
  320.         CASE 10
  321.             PRINT "Wheel scroll up."
  322.         CASE 11
  323.             PRINT "Left button double click."
  324.         CASE 12
  325.             PRINT "Drag..."
  326.     END SELECT
  327.     mydemo% = -1
  328.     RETURN
  329.  
  330.     check_UI.KeyCombos:
  331.     IF UI.KeyCombos THEN
  332.         LOCATE 1, 50
  333.         SELECT CASE UI.KeyCombos
  334.             CASE 1
  335.                 PRINT "Shift key down.        ";
  336.             CASE 2
  337.                 PRINT "Ctrl key down.         ";
  338.             CASE 3
  339.                 PRINT "Alt key down.          ";
  340.             CASE 4
  341.                 PRINT "Ctrl + Shift key down. ";
  342.         END SELECT
  343.     ELSE
  344.         LOCATE 1, 50: PRINT SPACE$(29);
  345.     END IF
  346.     RETURN

So in time, I will reinvent one of my many wheels again, and much like the mouse routine, that this routine uses, I will have a universal menu routine. The next stage is to put the horizontal menu in. Ah, did I mention how much I love that edit post feature restored? I think I did.

So if this goes well, all that would be needed is for the user to decide on a couple of options, like the box around the vertical menu, and then just fill in as many of the menu$() arrays. Skip every-other one to space the entries. Of course, it will get more complicated. Scrolling menu for more than the height of the program window will allow, etc.

Anyway, I'd just thought I'd post what I have so far. I wish I was more comfortable with _PRINTSTRING. It would be fun to be working on a graphics clone.
 
Pete

EDIT: Added the horizontal menu option.

11
QB64 Discussion / Mighty Mouse?
« on: October 05, 2021, 02:16:59 pm »
I'll let you guys decide...

Code: QB64: [Select]
  1. mydemo% = -1
  2. DIM UI AS UserInput
  3.  
  4. TYPE UserInput
  5.     KeyPress AS STRING
  6.     KeyCombos AS INTEGER
  7.     MbStatus AS INTEGER
  8.     MbEnvoked AS INTEGER
  9.     drag AS INTEGER
  10.     DoubleClick AS INTEGER
  11.     MbLeftx AS INTEGER
  12.     MbLefty AS INTEGER
  13.     mx AS INTEGER
  14.     oldmx AS INTEGER
  15.     my AS INTEGER
  16.     oldmy AS INTEGER
  17.  
  18. PRINT "Press keys or use mouse for demo.";
  19.     CALL keyboard_mouse(UI, mydemo%)
  20.     IF UI.MbStatus < 0 AND UI.MbEnvoked = 0 THEN
  21.         SOUND 1000, .3: UI.MbEnvoked = -1
  22.     END IF
  23.     IF UI.KeyPress = CHR$(13) THEN BEEP: EXIT DO
  24.  
  25.     CALL keyboard_mouse(UI, mydemo%)
  26.     IF UI.MbStatus > 0 AND UI.MbEnvoked = 0 THEN
  27.         SOUND 300, .3: UI.MbEnvoked = 1
  28.     END IF
  29.  
  30.  
  31. SUB keyboard_mouse (UI AS UserInput, mydemo%)
  32.     STATIC z1, lclick
  33.  
  34.     _LIMIT 30
  35.  
  36.     DEF SEG = 0
  37.     IF PEEK(1047) MOD 16 = 1 OR PEEK(1047) MOD 16 = 2 THEN
  38.         UI.KeyCombos = 1 ' Shift  % = -1 ELSE shift% = 0
  39.     ELSEIF PEEK(1047) MOD 16 = 3 OR PEEK(1047) MOD 16 = 4 THEN
  40.         UI.KeyCombos = 2 ' Ctrl  % = -1 ELSE ctrl% = 0
  41.     ELSEIF PEEK(1047) MOD 16 = 7 OR PEEK(1047) MOD 16 = 8 THEN
  42.         UI.KeyCombos = 3 ' Alt  % = -1
  43.     ELSEIF PEEK(1047) MOD 16 = 5 OR PEEK(1047) MOD 16 = 6 THEN
  44.         UI.KeyCombos = 4 ' Ctrl+Shift  % = -1 ELSE ctrlshift% = 0
  45.     ELSE
  46.         UI.KeyCombos = 0
  47.     END IF
  48.     DEF SEG
  49.  
  50.     IF mydemo% THEN GOSUB check_UI.KeyCombos
  51.  
  52.     UI.KeyPress = INKEY$
  53.     IF LEN(UI.KeyPress) THEN ' A key was pressed.
  54.         UI.MbEnvoked = 0: UI.MbLeftx = 0
  55.         SELECT CASE LEN(UI.KeyPress)
  56.             CASE 1 ' 1-byte key A-Z, etc.
  57.                 IF mydemo% THEN mydemo% = 1: GOSUB mydemo
  58.                 SELECT CASE UI.KeyPress
  59.                     ' Place key selection routine here...
  60.                     CASE CHR$(27): SYSTEM
  61.                 END SELECT
  62.             CASE 2 '2-byte key F1-F12, etc.
  63.                 IF mydemo% THEN mydemo% = 2: GOSUB mydemo
  64.                 SELECT CASE RIGHT$(UI.KeyPress, 1)
  65.                     ' Place key selection routine here...
  66.                 END SELECT
  67.         END SELECT
  68.     ELSE ' Check for mouse input since no keyboard input was detected.
  69.  
  70.         IF lclick THEN ' Check timer for double-clicks.
  71.             IF TIMER < z1 THEN z1 = z1 - 86400 ' Midnight adjustment.
  72.             IF TIMER - z1 > .33 THEN lclick = 0 ' Too much time ellapsed for a double click.
  73.         END IF
  74.  
  75.         WHILE _MOUSEINPUT
  76.             mw = mw + _MOUSEWHEEL ' Check for mouse wheel use.
  77.         WEND
  78.  
  79.         ' Get mouse status.
  80.         UI.mx = _MOUSEX
  81.         UI.my = _MOUSEY
  82.         lb = _MOUSEBUTTON(1)
  83.         rb = _MOUSEBUTTON(2)
  84.         mb = _MOUSEBUTTON(3)
  85.  
  86.         SELECT CASE UI.MbEnvoked
  87.             CASE 0
  88.                 IF lb OR rb OR mb THEN
  89.  
  90.                 END IF
  91.             CASE 1
  92.                 IF lb OR rb OR mb THEN UI.MbEnvoked = 0
  93.             CASE -1
  94.                 IF lb = 0 AND rb = 0 AND mb = 0 THEN UI.MbEnvoked = 0
  95.         END SELECT
  96.  
  97.         ' Check for mouse movement.
  98.         IF UI.mx <> UI.oldmx OR UI.my <> UI.oldmy THEN
  99.             oldcsrlin = CSRLIN: oldpos = POS(0)
  100.             LOCATE 3, 1: PRINT "Mouse row/col ="; UI.my; UI.mx; "     ";: LOCATE oldcsrlin, oldpos
  101.         END IF
  102.  
  103.         IF UI.MbStatus < 0 THEN ' Mouse button pressed. UI.MbStatus identity is by number. -1=left, -2=right, -3=middle.
  104.             SELECT CASE UI.MbStatus
  105.                 CASE -1 ' Left button was pressed.
  106.                     IF lb = 0 THEN ' Left button released.
  107.                         SELECT CASE lclick ' Single or double click analysis.
  108.                             CASE 0
  109.                                 IF mydemo% THEN mydemo% = 3: GOSUB mydemo
  110.                                 lclick = lclick + 1
  111.                             CASE ELSE ' Double click. Completed upon 2nd left button release.
  112.                                 IF mydemo% THEN mydemo% = 11: GOSUB mydemo
  113.                                 UI.DoubleClick = -1
  114.                                 lclick = 0
  115.                         END SELECT
  116.                         UI.MbStatus = 1
  117.  
  118.                         IF UI.MbLeftx THEN
  119.                             IF UI.mx <> UI.MbLeftx OR UI.my <> UI.MbLefty THEN UI.MbStatus = 0: lclick = 0
  120.                             UI.MbLeftx = 0: UI.MbLefty = 0
  121.                         END IF
  122.  
  123.                         IF UI.drag THEN UI.drag = 0
  124.                     ELSE ' Left button is being held down. Check for UI.drag.
  125.                         IF UI.mx <> UI.oldmx OR UI.my <> UI.oldmy THEN ' Mouse cursor has moved. UI.drag.
  126.                             IF mydemo% THEN mydemo% = 12: GOSUB mydemo
  127.                             UI.drag = -1
  128.                         END IF
  129.                     END IF
  130.                 CASE -2 ' Right button was pressed.
  131.                     IF rb = 0 THEN ' Right button was relased.
  132.                         IF mydemo% THEN mydemo% = 4: GOSUB mydemo
  133.                         UI.MbStatus = 2
  134.                     END IF
  135.                 CASE -3 ' Middle button was pressed
  136.                     IF mb = 0 THEN ' Middle button was released.
  137.                         IF mydemo% THEN mydemo% = 5: GOSUB mydemo
  138.                         UI.MbStatus = 3
  139.                     END IF
  140.             END SELECT
  141.         ELSE
  142.             IF lb THEN ' Left button just pressed.
  143.                 IF mydemo% THEN mydemo% = 6: GOSUB mydemo
  144.                 UI.MbStatus = -1
  145.                 IF UI.MbLeftx = 0 THEN UI.MbLeftx = UI.mx: UI.MbLefty = UI.my
  146.                 z1 = TIMER
  147.             ELSEIF rb THEN ' Right button just pressed.
  148.                 IF mydemo% THEN mydemo% = 7: GOSUB mydemo
  149.                 IF UI.MbLeftx = 0 THEN UI.MbLeftx = UI.mx: UI.MbLefty = UI.my
  150.                 UI.MbStatus = -2
  151.             ELSEIF mb THEN ' Middle button just pressed.
  152.                 IF mydemo% THEN mydemo% = 8: GOSUB mydemo
  153.                 IF UI.MbLeftx = 0 THEN UI.MbLeftx = UI.mx: UI.MbLefty = UI.my
  154.                 UI.MbStatus = -3
  155.             ELSEIF mw THEN ' Mouse wheel just moved.
  156.                 SELECT CASE mw
  157.                     CASE IS > 0 ' Scroll down.
  158.                         IF mydemo% THEN mydemo% = 9: GOSUB mydemo
  159.                     CASE IS < 0 ' Scroll up.
  160.                         IF mydemo% THEN mydemo% = 10: GOSUB mydemo
  161.                 END SELECT
  162.             END IF
  163.         END IF
  164.  
  165.         UI.oldmx = UI.mx: UI.oldmy = UI.my: mw = 0 ' Mouse position past and present.
  166.     END IF
  167.     EXIT SUB
  168.  
  169.     mydemo:
  170.     LOCATE 1, 1: PRINT "Last User Status:                                    ";
  171.     LOCATE , 19
  172.     SELECT CASE mydemo%
  173.         CASE 1
  174.             PRINT "1-byte Key = "; UI.KeyPress
  175.         CASE 2
  176.             PRINT "2-byte Key = "; UI.KeyPress
  177.         CASE 3
  178.             PRINT "Left button released."
  179.         CASE 4
  180.             PRINT "Right button released."
  181.         CASE 5
  182.             PRINT "Middle button released."
  183.         CASE 6
  184.             PRINT "Left button down."
  185.         CASE 7
  186.             PRINT "Right button down."
  187.         CASE 8
  188.             PRINT "Middle button down."
  189.         CASE 9
  190.             PRINT "Wheel scroll down."
  191.         CASE 10
  192.             PRINT "Wheel scroll up."
  193.         CASE 11
  194.             PRINT "Left button double click."
  195.         CASE 12
  196.             PRINT "Drag..."
  197.     END SELECT
  198.     mydemo% = -1
  199.     RETURN
  200.  
  201.     check_UI.KeyCombos:
  202.     IF UI.KeyCombos THEN
  203.         LOCATE 1, 50
  204.         SELECT CASE UI.KeyCombos
  205.             CASE 1
  206.                 PRINT "Shift key down.        ";
  207.             CASE 2
  208.                 PRINT "Ctrl key down.         ";
  209.             CASE 3
  210.                 PRINT "Alt key down.          ";
  211.             CASE 4
  212.                 PRINT "Ctrl + Shift key down. ";
  213.         END SELECT
  214.     ELSE
  215.         LOCATE 1, 50: PRINT SPACE$(29);
  216.     END IF
  217.     RETURN

Anyway, this is just something I threw together for another member to consider. I usually write these routines from scratch each time I need one, but for fun, I thought I take a shot at one I could save as a library and use as a universal routine for future apps. I need to add some more stuff from my other routines, like my PEEK / POKE routine for detecting Shift + arrow keys, alt, ctrl, etc. I also want to add another variable to let the user decide if the mouse action should take place upon button press or release. I'll probably update this post, occasionally, if and when I make these additions. Fun stuff.

Pete

Edited: Worked in V 1.3, but not the more recent versions. Reason was as bplus pointed out, I had two IF THEN statements following a SELECT CASE statement. Both statements were moved one line up, and now work in the later versions. Thanks for catching that, Mark!

Edited: Added a method and demo for mouse action either on button press or release. The first loop signals a high tone when a mouse click is made with button down. It then shuts off more mouse input until the button is released. Press [ENTER] to exit to the next loop, which issues a low tone when a depressed mouse button is released. Now the user can decide on each mouse event if the program should respond upon mouse button press or release.

Edited: Added my PEEK / POKE routine to detect Shift, Ctrl, Alt, and Ctrl+Shift.

Editd: Added a prevent click initiation on button release if mouse cursor is moved while button is held down. So if the user decides to use the activate mouse command on button release option, this addition allows the user to abort the click, by moving the mouse cursor before the button is released.

Edited: Did some renaming and changed variables to TYPE variables.

Edited: Added mouse row and column indicator.

12
QB64 Discussion / Modify Post Permissions
« on: October 01, 2021, 03:15:21 pm »
I have read the previous thread about Modify Post permissions being limited to 5-minutes, in order to avoid some sort of abuse. As of the past couple of days, I thought it was returned to it's "forever" status, but today, Mark, Steve, and I noticed it's apparently back to the 5-minute limit. My hunch is that when the forum went down a couple of days ago, it was reset when the glitch was corrected. My second hunch is it was not noticed until today, and then it got switched to the 5-minute limit again.

As a long time QB forum owner, I just don't see any benefit in this 5-minute editing limit. I do see tremendous use, without abuse, and benefit to most all of our members by permitting a much longer editing limit, maybe a month for programs and a day for all other boards. It's far better for updating code in the Programs board. It's far better at keeping posts more relevant in all other boards. It helps members avoid embarrassment when they make some typo, or when there is a need to correct or clarify what was posted upon further reflection, which often occurs well past a 5-minute time limit.

At N54 and Tapatalk, I would simply remove or limit permissions just for the member who abused the feature. I'd highly be in favor of taking that approach here, provided it is available on Simple Machines forums. I simply cannot imagine what abuse would be so great and used so frequently it would far outweigh the benefits of longer time limits for editing in the community.

Pete

13
QB64 Discussion / I just had this amazing brainstorm!
« on: October 01, 2021, 01:42:29 pm »
Fortunately, that guy who sells Flex Tape came along and sealed things up before a lot of good info got through, but I did come away with this from the thread I stared about organization...

Why not add a TAGS option to the QB64 IDE?

So SAVE and SAVE AS now have a box to check [ ] Add Tags

Now I know this opens up a can of worms on indexing. What happens if the file name gets changed, how to keep the same tags on builds, etc. so you have to weigh the work load with the benefits. The OPEN routine would also have to include an option to sort by tags.

The internet has used this for ages, and it is a proven and useful form of organization. I think it would be great to have it as part of the QB64 IDE, but again, unless there is some simple way to create it, and there may be, I would think finding out the percentage of user usage would be warranted before trying to implement file tagging.

Thoughts?

Pete

14
QB64 Discussion / How organized are you guys?
« on: October 01, 2021, 12:33:41 pm »
Organization is my middle, no first, no wait, I can't remember what part of my name it is. Well, that's about the truth. I started a little cat herding project to round up all the various aps, utilities, algorithms, etc., I've made in QB over the years, and what I'm finding is hundreds of files with hard to apps, many with hard to deduce old MS-DOS 8.3 names. It's reminding me of the Indiana Jones Arc of the Covenant lost in the government warehouse scene, only in my case, it's more of the "wherehouse." I mean I did start making build folders, about 8 years ago, but before that, I didn't even sort out builds.

So how about you guys? Anyone develop a system of tagging files or other methods so you have a good idea of what you programmed in your past?

Pete

15
QB64 Discussion / Need help finishing my HELLO WORLD program.
« on: September 30, 2021, 11:28:23 pm »
The "O" is out on my keyboard and so far, it's just been HELL

Pete

Pages: [1] 2 3 ... 9