Welcome, Guest |
You have to register before you can post on our site.
|
Latest Threads |
The QB64 IDE shell
Forum: Utilities
Last Post: JasonPag
09-16-2024, 05:37 PM
» Replies: 9
» Views: 762
|
Importance regarding Ches...
Forum: Utilities
Last Post: JasonPag
09-01-2024, 06:34 PM
» Replies: 0
» Views: 31
|
Chess and Analysis and En...
Forum: Utilities
Last Post: JasonPag
08-28-2024, 02:37 PM
» Replies: 0
» Views: 32
|
DAY 009:_PutImage
Forum: Keyword of the Day!
Last Post: grymmjack
09-02-2023, 02:57 PM
» Replies: 54
» Views: 2,034
|
Fall Banner Contest?
Forum: Site Suggestions
Last Post: grymmjack
08-31-2023, 11:50 PM
» Replies: 36
» Views: 1,261
|
ColorPicker - Function th...
Forum: Dav
Last Post: Dav
08-31-2023, 11:04 PM
» Replies: 3
» Views: 315
|
Goals(1) = New Tile()
Forum: Works in Progress
Last Post: RhoSigma
08-31-2023, 09:45 PM
» Replies: 3
» Views: 127
|
micro(A)v11
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:14 PM
» Replies: 90
» Views: 3,589
|
Updating The Single Most ...
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:13 PM
» Replies: 7
» Views: 254
|
QBJS Image Question
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 05:49 PM
» Replies: 5
» Views: 155
|
|
|
Having screen blinking issue using Hardware Images |
Posted by: Dav - 12-14-2022, 03:01 PM - Forum: Help Me!
- Replies (4)
|
|
I started working on the QB64 video+audio format maker I shared at the old forum, adding playback controls, etc. I want to load images as Hardware images because they seem to display much faster, will allow better frame rates, but when doing that the screen blanks horrible. Not sure why and what can fix the blinking. Hoping to discover a solution or I will have to stick when the slower regular way.
I've attached the code and a test QBV file. As is the video displays ok, but if you comment out line #53 and use #54 instead (hardware images) the screen will blink very badly. The video is a low resolution one for testing purposes, me playing a short Christmas song on the piano.
Thanks for any help.
- Dav
[attachment=1221]
|
|
|
DAY 034: WIDTH (SUB) |
Posted by: SMcNeill - 12-14-2022, 02:48 PM - Forum: Keyword of the Day!
- Replies (4)
|
|
I thought I'd be nice and post a word today, to give Pete a break for a bit. (Also, someone asked me about this, and it's just as easy to write an answer here as it is elsewhere. )
WIDTH -- One of those simple little commands that has been in the language forever and ever. Going back to the days of GWBASIC, one could always use WIDTH to set the character height and width of a SCREEN 0 screen. You can see our wiki article on it here: https://qb64phoenix.com/qb64wiki/index.php/WIDTH
Usage has always been rather simple: WIDTH columns, rows
One keyword, two parameters to set how many columns and how many characters you wanted to print to the screen. Can't get much simpler than that, now can it??
So, someone asked me, "WHAT THE HECK ARE THE EXTRA TWO PARAMETERS THAT QB64PE ACCEPTS AFTER THAT???" (And yes, I was asked in all caps, so you know this is a serious question!)
Let me answer this in two parts:
For our Linux and Mac users: Those two parameters are nothing for you. They do nothing. Change nothing. They're not implemented in either Linux nor Mac. Set them to whatever you like, nothing is ever going to change. (At least, not until someone goes in and makes them multi-platform compatible. At the moment, they only apply for Windows.)
Sorry guys.
For our Windows users, those two parameters are used FOR THE CONSOLE ONLY. Unless you use $CONSOLE in your program, they're not going to change anything at all for you either. You might as well be using a Linux PC, as far as WIDTH and the 3rd and 4th parameter are concerned.
So... You're a windows user. Your program uses $CONSOLE. What the heck does those last 2 parameters do for you?
They set the total width and height of your available console.
For example, let's try the following program:
Code: (Select All) $Console:Only
Width 50, 50, 500, 500
ten$ = "0123456789"
For i = 1 To 50
Print ten$;
Next
sleep
Now, if you look, you'll see that I'm printing 10 characters to the screen 50 times -- and they're all printed on the same line. (semicolon at the end of the print keeps continuous printing without a new line, remember?)
The Width 50, (who cares), (who cares), (who cares) says that my console is only going to be 50 columns in width. That's the most characters that it can display on the screen at a single time. Look at the console we created, count the number of ten$ you see on the screen -- it's exactly 5 of them. First parameter is the number of visible characters.
BUT, if you look down at the bottom of the console, you'll see a scroll bar. Go ahead and scroll it to the right. If you took time to scroll and count, you'd see that the total width of our console is actually 500 characters! We set that with the 3rd parameter: Width (who cares), (who cares), 500, (who cares)
It's the same with our height and total height as well. The second parameter says that we're only going to display 50 rows of text on the screen at any given time, but the 4th parameter says that we're going to have 500 rows total, before we start scrolling up the bottom and losing information off the page.
WIDTH, with its 4 parameters, in Windows Console is:
WIDTH columns visible, rows visible, total columns, total rows.
If you set the 3rd and 4th parameters to be the same as your 1st and 2nd, you can create a console with NO scroll bars -- everything that you're displaying is instantly viewable for your user.
And that's what those two new "secret" little parameters do for us, in a nutshell.
|
|
|
Storing stuff |
Posted by: NasaCow - 12-14-2022, 10:42 AM - Forum: Help Me!
- Replies (12)
|
|
Every time in the past, when I need to store something to file, I always used a user-defined type and wrote and read the contents to a file using INPUT and OUTPUT. Now starting to design the actual gradebook, I am a little stumped. Naturally, an array sounds useful for something like this. My initial thought is assigning every student a unique ID (UID), unknown to the user but used by me, so if the name changes or something of the sort, we still can line the grades with the proper name.
So, the thinking is UID, Grade or mark, and notes. I am not overly experienced using multi-dimensional arrays. Is there any issues resizing them using REDIM PRESERVE. Is there a better idea for keeping and using this information or storing it with INPUT/OUTPUT won't be overly taxing since I would have to overwrite the file every time I make an update? Using RANDOM sounds like I have to make all these decision on the front-end... I guess I am just looking for a nudge in the right direction since I am kinda inexperinced with this type of programming
Thanks y'all
|
|
|
DAY 033: COMMAND$ |
Posted by: Pete - 12-13-2022, 06:48 PM - Forum: Keyword of the Day!
- Replies (9)
|
|
Ever wish we could travel the world on a transporter beam? Well, we can't, so for now, let's stay home and play with COMMAND$...
SYNTAX: cmd$ = COMMAND$[(count%)]
USE: Passing arguments to other apps and drag and drop applications.
And as a bonus, if you act now, we'll throw in _COMMANDCOUNT to evaluate that count% variable.
Okay, let's get our demo of the day going...
Works for Windows, untested for Linux or Mac...
Code: (Select All) WIDTH 120, 25
_SCREENMOVE 0, 0
PRINT
cmd$ = COMMAND$(0) ' Gets the complete path and name of your current running program.
j = _INSTRREV(cmd$, "\")
program$ = MID$(cmd$, j + 1) ' Parse to just the program name.
IF j THEN
DrivePath$ = MID$(cmd$, 1, LEN(cmd$) - LEN(program$))
j = 1
ELSE
DrivePath$ = COMMAND$(1)
j = 2
END IF
PRINT "Drive and path of program passing arguments... "; DrivePath$: PRINT
PRINT "Program name passing the arguments............ "; program$: PRINT
IF LEN(COMMAND$(1)) THEN
' Parse and add back spaces because command$ needs passing spaces enclosed in quotes to preserve them.
k = _COMMANDCOUNT ' The number of arguments passed.
FOR i = j TO k
cmd$ = COMMAND$(i) ' Parse out an argument.
msg$ = msg$ + cmd$ + " " ' Concatenate string and add space back into string.
NEXT
msg$ = MID$(msg$, 1, LEN(msg$) - 1) ' Cut off the trailing space we added.
COLOR 14: PRINT msg$: PRINT: COLOR 7
END IF
PRINT "[1] Pete is a genius!": PRINT
PRINT "[2] Steve is a genius!": PRINT
PRINT "[3] Pete and Steve are both idiots, and I wore out my [3] key!": PRINT
PRINT
DO
INPUT "1-3: ", ans%: PRINT
IF ans% = 0 THEN SYSTEM
IF ans% > 0 AND ans% < 4 THEN EXIT DO
LOOP
' RUN and pass our sentences as a command$() parameter.
' Note we need a space between each argument we are going to be passing.
format$ = " " + CHR$(34) + _CWD$ + CHR$(34) + "\ "
SELECT CASE ans%
CASE 1: RUN program$ + format$ + "Pete is a genius!"
CASE 2: RUN program$ + format$ + "Steve is a genius!"
CASE 3: RUN program$ + format$ + "Pete and Steve are both idiots, and I wore out my [3] key!"
END SELECT
So the example above is a self-contained program. You don't have to name it or save it, just run it. Well how in the hell is that possible, you ask? Well, let's get into that, pronto...
COMMAND$(0): This is a special parameter of COMMAND$() that retrieves the current drive, path, and name of the running app. Pretty cool, right?
Edit: Steve caught the fact COMMAND$(0) doesn't grab the drive and path of the passing app, it grabs where it is being started from along with the name, of course. (See posts below for more info.) So I adjusted the code above to also include a way to pass the drive and path with _CWD$. Our example only needs the name, but it's nice to know the drive and path, if needed, could be passed as well.
Now that our example program knows its name, it let's you pick a selection then runs itself. It passes the choice you made through COMMAND$() and parses it out in the first conditional block statement... IF LEN(COMMAND$(1)) THEN
The (1) of COMMAND$(1) is string we passed in the RUN statement. So COMMAND$(0) got us or drive, path, and program name, and COMMAND$(1) got us the string argument we passed in the RUN statement.
Note: A difference between QB64 and QuickBASIC is QB made the arguments uppercase. QB64 maintains the case of the passed string.
_COMMANDCOUNT then kicks in and tells us how many parameters. COMMAND$() separates our text message by spaces. In other words a space acts as a string delimiter. So if the message was: "Call me Betty" we would have three arguments: Call, me, Betty. By knowing we have 3, we can save a little coding parsing those arguments out as COMMAND$(1), COMMAND$(2), and COMMAND$(3) by using our FOR/NEXT loop routine.
So even though we posted just one elf-contained program, for ease of use, keep in mind we will primarily use COMMAND$() when RUNning or SHELLing to another application, which needs info passed to it from the previous or calling program.
Note: Other methods of accomplishing for RUN and/or SHELL would be CHAIN, but not used in SHELL statements, Piping, used in SHELL statements, _CLIPBOARD$, usable in both, database sharing, used in both, TCP/IP, usable in both, and SCREEN writing and reading, used in both.
Oh, and here is a fun little shortcut example you can make to view files from Explorer in Notepad...
Instructions: name it anything you want. Make exe only. Find exe and make Desktop shortcut.
Code: (Select All) cmd$ = COMMAND$(0) ' Gets the complete path and name of your current running program.
IF LEN(COMMAND$(1)) THEN
' Parse and add back spaces because command$ needs passing spaces enclosed in quotes to preserve them.
j = _COMMANDCOUNT ' The number of arguments passed.
FOR i = 1 TO j
cmd$ = COMMAND$(i) ' Parse out an argument.
msg$ = msg$ + cmd$ + " " ' Concatenate string and add space back into string.
NEXT
msg$ = MID$(msg$, 1, LEN(msg$) - 1) ' Cut off the trailing space we added.
COLOR 14: PRINT msg$: PRINT: COLOR 7
PRINT: PRINT "SHELL notepad " + cmd$
SHELL _HIDE _DONTWAIT "notepad " + cmd$
END IF
So what now? Open Explorer and find a text file. Drag it into the desktop icon you just created. It will open that dragged file in Notepad.
...And if you want to make it stealth, code it as...
Code: (Select All) ' Make a desktop shortcut to this and drag files into it.
_SCREENHIDE
cmd$ = COMMAND$(0) ' Gets the complete path and name of your current running program.
REM PRINT cmd$: PRINT
IF LEN(COMMAND$(1)) THEN
' Parse and add back spaces because command$ needs passing spaces enclosed in quotes to preserve them.
j = _COMMANDCOUNT ' The number of arguments passed.
FOR i = 1 TO j
cmd$ = COMMAND$(i) ' Parse out an argument.
msg$ = msg$ + cmd$ + " " ' Concatenate string and add space back into string.
NEXT
msg$ = MID$(msg$, 1, LEN(msg$) - 1) ' Cut off the trailing space we added.
REM COLOR 14: PRINT msg$: PRINT: COLOR 7
REM PRINT: PRINT "SHELL notepad " + cmd$
SHELL _HIDE _DONTWAIT "start notepad " + cmd$
END IF
SYSTEM
Now imagine what other drag and drop apps you could use this for. Paint.net is one I use this on. I use SENDKEYS WIn32 API routines in my COMMAND$() desktop app to control PAINT.net after it opens and loads the image I dragged into the file. That saves me several steps. I can even resize photos without touching the keyboard once!
If you guys have other uses or programs of a similar nature to share, please feel free to either add them here as examples, or add the link to the forum page.
Thanks, an now back to work on my transporter beam. I think I just sent my CapsLock toe to the South of France.
Pete
|
|
|
NOT OOO |
Posted by: SMcNeill - 12-13-2022, 03:10 PM - Forum: General Discussion
- Replies (1)
|
|
From the thread here, I had a couple of people message me about NOT and why I mentioned it was an oddball in the Order Of Operations (OOO). Let me see if I can explain this simply, without confounding the issue..
Exponents are one of the first things we solve in our OOO. Right?
And NOT is down near the end of our OOO. Right?
So following those rules, write a program to parse and solve: 1 ^ NOT 2 ^ 3 AND 4
??? <-- Now how the heck DOES it calculate that???
The odd secret is NOT is both calculated FIRST, and near the LAST of our OOO.
Here's the trick I learned: Put a beginning parentheses BEFORE your NOT, and the ending parentheses before any binary operators like AND, OR, EQV...
1 ^ NOT 2 ^ 3 AND 4 gets solved as: 1 ^ (NOT 2 ^ 3) AND 4
1 ^ (NOT 2 ^ 3) AND 4 makes sense to us. Do the parentheses FIRST, even if NOT might be evaluated down low on the OOO.
You can't just say, "Solve it last," as sometimes, such as in this case, you have to solve it first before you can do the other operations. 1 raised to the WHAT power? The (NOT 2 ^ 3)rd power!
Put a beginning parentheses BEFORE your NOT, and the ending parentheses before any binary operators like AND, OR, EQV. <-- That's the rule for parsing and solving NOT properly.
|
|
|
DAY 032: _INSTRREV |
Posted by: Pete - 12-12-2022, 08:58 PM - Forum: Keyword of the Day!
- Replies (11)
|
|
_INSTRREV is an INSTR function, but in reverse! Instead of searching left to right, it searches from right to left.
SYNTAX _INSTRREV(seed%, string$, search$)
Where:
seed% is starting point in the string to begin the search.
string$ is the string to be searched.
search$ is the search term.
Note: The first parameter, seed%, is optional. We can also code it as: _INSTRREV(string$, search$)
Use: Parsing function.
So if we can already search a string forward with INSTR(), what's the benefit of using _INSTRREV()?
Glad you asked...
Let's say we have a page margin of 40 spaces wide. Here is our first string for that document...
a$ = "Pete and Steve walk into a bar. Steve blames Pete for not raising the bar higher."
Oops, that's longer than 40-characters? What do we do now Batman?
Well, simple "Stevey-boy" Wonder, we use the Bat-o-axe and chop it! (I have an old bat-o-axe around the house... Ouch! Hit by the bat-pan again!)
Well while I recover from being being badly bat-tered, let's take a short commercial break and see INSTR() vs _INSTRREV() in action.
Code: (Select All) WIDTH 82, 25
LOCATE 10, 1: PRINT " Okay, here is our string to chop to the page width of 40... "
a$ = "Pete and Steve walk into a bar. Steve blames Pete for not raising the bar higher."
LOCATE 20, 1: PRINT a$; ''PRINT MID$(a$, 1, _WIDTH - 2): PRINT " "; MID$(a$, _WIDTH - 1)
mr = 40 ' Right margin limit
LOCATE 1, mr + 1: PRINT "|";
SLEEP
LOCATE 10, 1: PRINT "First we chopped the string to the page width: a$ = MID$(a$, 1, mr) "
a$ = MID$(a$, 1, mr)
LOCATE 1, 1
PRINT a$;
SLEEP
LOCATE 10, 1: PRINT "Okay, we need to get rid of the "; CHR$(34); "bl"; CHR$(34); " part of blames on our first line... "
LOCATE 12, 1: PRINT "So let's try doing that with INSTR() with a nice long loop function..."; ""
SLEEP
LOCATE 10, 1: PRINT "Well that's working, but it's taking several parsing loops. "
LOCATE 12, 1: PRINT SPACE$(_WIDTH);
LOCATE 1, 1: PRINT SPACE$(mr);
LOCATE 1, 1
seed% = 0: j = 0
DO
chop = j
j = INSTR(seed%, a$, " ")
COLOR 8: PRINT MID$(a$, seed%, j - seed% + 1);: _DELAY .66 ' For fun, we will time delay print each parse.
seed% = j + 1 ' Move forward in our string - character past the last space.
LOOP UNTIL j = 0
COLOR 7
LOCATE 1, 1
PRINT MID$(a$, 1, chop);
SLEEP
LOCATE 10, 1: PRINT "Okay, let's do that with a 1-line _INSTRREV(): chop = _INSTRREV(a$, "; CHR$(34); " "; CHR$(34); ") "
LOCATE 1, 1: PRINT SPACE$(mr);
SLEEP 5
chop = _INSTRREV(a$, " ")
LOCATE 1, 1
PRINT MID$(a$, 1, chop);
LOCATE 10, 1: PRINT "Well that was easy! "
Now the seed% part in _INSTRREV is used a bit differently than INSTR() in that it is read right to left, instead of left to right. So instead of stating your seed% at zero, you start it at the last space - 1 in your string to be chopped.
Code: (Select All) a$ = "Pete and Steve walk into a bar. Steve bl"
LOCATE 1, 41: PRINT "|";
_DELAY 1
DO
seed% = _INSTRREV(a$, " ") - 1: j = 0
DO
chop = j
j = _INSTRREV(seed%, a$, " ")
LOCATE , j + 1: PRINT MID$(a$, j + 1, seed% - j + 1);: _DELAY .5
REM PRINT seed%, j
seed% = j - 1 ' Move backwards in our string - character past the previous space.
LOOP UNTIL j = 0
LOCATE 1, 1: PRINT SPACE$(40);: _DELAY 1: LOCATE 1, 1
seed% = 0: j = 0
DO
chop = j
j = INSTR(seed%, a$ + " ", " ")
PRINT MID$(a$, seed%, j - seed% + 1);: _DELAY .5 ' For fun, we will time delay print each parse.
seed% = j + 1 ' Move forward in our string - character past the last space.
LOOP UNTIL j = 0
LOCATE 1, 1: PRINT SPACE$(40);: _DELAY 1: LOCATE 1, 1
LOOP
Well one practical application I wish we could do with this keyword is seed it find a term in a list of terms, separated with a delimiter. Well, we can build a function and use our key INSTRREV() and I'll throw in _INSTR() for no extra charge.
First input if you are searching forwards or backwards and then input the what number term to find, 1 - 10.
Code: (Select All) DO
DO
CLS
a$ = "dog cat rabbit cow mule pig elephant tiger bear Steve"
PRINT a$: PRINT
INPUT "Pick From the Left [1] or the Right [-1]: ", tmp%: PRINT
INPUT "From 1 - 10, What Term #", tnum%
IF tnum% >= 1 AND tnum% <= 10 AND tmp% >= -1 AND tmp% <= 2 AND tmp% <> 0 THEN EXIT DO
LOOP
tnum% = tnum% * tmp%
PRINT
PRINT " You chose: "; parse(a$, tnum%)
PRINT: PRINT "Press any key to continue or Esc to quit..."
_KEYCLEAR
SLEEP
IF INKEY$ = CHR$(27) THEN SYSTEM
LOOP
FUNCTION parse$ (a$, tnum%)
IF tnum% < 0 THEN
seed% = _INSTRREV(a$ + " ", " ") - 1: j = 0
FOR i = 1 TO ABS(tnum%)
chop = j
j = _INSTRREV(seed%, a$ + " ", " ")
IF i <> ABS(tnum%) THEN seed% = j - 1
NEXT
parse$ = MID$(a$, j + 1, seed% - j + 1)
ELSE
seed% = 0: j = 0
FOR i = 1 TO tnum%
chop = j
j = INSTR(seed%, a$ + " ", " ")
IF i <> tnum% THEN seed% = j + 1
NEXT
parse$ = MID$(a$, seed%, j - seed% + 1)
END IF
END FUNCTION
Other uses are parsing off a file path to show just the directory:
From the Wiki...
Code: (Select All) fullPath$ = "C:\Documents and Settings\Administrator\Desktop\qb64\internal\c\libqb\os\win\libqb_1_2_000000000000.o"
file$ = MID$(fullPath$, _INSTRREV(fullPath$, "\") + 1)
PRINT file$
One last thing, which also applies to INSTR(). Both will return zero if the search term, or aka sub-string, isn't found. So if you are using it with mid$() be aware that zero will give you the full string in the output, instead of a null string. You will need to write a conditional statement to handle this behavior...
Code: (Select All) a$ = "123456789" ' No space(s).
x$ = "" ' Make x$ a null string just in case x$ was assigned someplace else.
substring$ = " "
j = _INSTRREV(a$, substring$)
IF j THEN x$ = MID$(a$, j) ' Only change null x$ if j is non-zero.
PRINT "x$ = "; x$ ' Nothing will print here now that we put in the above condition.
SLEEP
PRINT: PRINT MID$(a$, _INSTRREV(a$, substring$)) ' This would have printed the whole string without the condition.
Tune in tomorrow. Same Bat time, same Bat channel.
Pete
|
|
|
Windows Magnifier |
Posted by: SMcNeill - 12-12-2022, 09:24 AM - Forum: Utilities
- Replies (10)
|
|
Code: (Select All) Type POINTAPI
X As Long
Y As Long
End Type
Dim WinMse As POINTAPI
Declare Dynamic Library "Gdi32"
Function CreateEllipticRgn%& (ByVal x1&, Byval y1&, Byval x2&, Byval y2&)
End Declare
Declare Dynamic Library "User32"
Function GetWindowLongA& (ByVal hwnd As Long, Byval nIndex As Long)
Function SetWindowLongA& (ByVal hwnd As Long, Byval nIndex As Long, Byval dwNewLong As Long)
Function SetWindowPos& (ByVal hwnd As Long, Byval hWndInsertAfter As Long, Byval x As Long, Byval y As Long, Byval cx As Long, Byval cy As Long, Byval wFlags As Long)
Function SetWindowRgn (ByVal windowhandle%&, Byval region%&, Byval redraw%%)
Function GetCursorPos (lpPoint As POINTAPI)
Function GetKeyState% (ByVal nVirtKey As Long) 'reads Windows key presses independently
End Declare
GWL_STYLE = -16
WS_VISIBLE = &H10000000
Screen _NewImage(720, 720, 32)
_ScreenHide
hwnd& = _WindowHandle
winstyle& = GetWindowLongA&(hwnd&, GWL_STYLE)
a& = SetWindowLongA&(hwnd&, GWL_STYLE, winstyle& And WS_VISIBLE)
a& = SetWindowPos&(hwnd&, -2, 0, 0, 0, 0, 39)
rgn%& = CreateEllipticRgn(0, 0, _Width - 1, _Height - 1)
result = SetWindowRgn(hwnd&, rgn%&, -1)
magnify = -1
_ScreenShow
zoom = 5
Do
update = (update + 1) Mod 6
Cls , 0
m = GetCursorPos(WinMse)
If GetKeyState(17) < 0 Then 'CTRL +
If GetKeyState(&HBD) < 0 Then zoom = zoom + .2
If GetKeyState(&HBB) < 0 Then zoom = zoom - .2
If GetKeyState(Asc("M")) < 0 Then 'M for MAGNIFY
magnify = Not magnify
If magnify Then _ScreenShow Else _ScreenHide
_Delay .2 'give the user time to get their fat fingers off the CTRL-M keys so we don't have multi on/off events instantly.
End If
If GetKeyState(Asc("Q")) < 0 Then System 'Q for QUIT
If GetKeyState(Asc("P")) < 0 Then _ScreenMove WinMse.X - 320, WinMse.Y - 320 'P for POSITION
End If
If zoom < .2 Then zoom = .2
If zoom > 10 Then zoom = 10
If update = 1 Then
If DTI Then _FreeImage DTI
DTI = _ScreenImage
End If
_PutImage , DTI, 0, (WinMse.X - 50 * zoom, WinMse.Y - 50 * zoom)-(WinMse.X + 50 * zoom, WinMse.Y + 50 * zoom)
_Limit 30
oldx = WinMse.X: oldy = WinMse.Y
_Display
Loop
Ever have a screen where everything is just too small to read? Or maybe it's one where you wish you could easily zoom out on so you could see how it'd look on a higher resolution device? Ever wish QB64-PE could solve the problem for you?
WELL, NOW IT CAN!!
Presenting the one and only, limited time offer, for only three easy payments of $49.97, Windows Magnifier!
IT MAKES THINGS BIGGER! it can make things smaller. It can make your wife yell, "WOWZERS!!", when you step out of the shower and she sees you on your bathroom security cam! Just buy now and pay later, and you can have the power of CONTRL-M in the palm of your hands!!
and what's control-m, you ask?
WHY IT'S NOTHING LESS THAN THE MARVELOUS, AMAZING, STUPENDIOUS, ASTOUNDING HOTKEY TO YOUR OWN WINDOWS MAGNIFIER!! Written completely in QB64-PE!
Zoom in with CONTROL-PLUS. Zoom out with CONTROL-MINUS. Position it wherever you want with CONTROL-P, and then when you're done, you can CTRL-Q to QUIT it!
I'm the Ghost of Milly Hay Bayes, and I approve this product 100%!!!
|
|
|
DAY 031: BYVAL |
Posted by: Pete - 12-12-2022, 02:37 AM - Forum: Keyword of the Day!
- Replies (8)
|
|
SYNTAX
For us Rednecks... I like ta BYVAL, Pat. I'd like a P.
For everyone else...
BYVAL
So all this really is is a way to tell the system we will be passing a variable in a library variable list by value rather than by reference. We are basically defining the passing mechanism.
So what's the difference you ask?
In short, passing by value passes the actual value of the variable to the sub-procedure, and back.
Passing by reference means we can mess with the variable name from the call list to the library, sub, or function, and modify the programming element underlying the argument in the calling code. The position in the list is all that matters.
Here is a sub example of passing two variables by reference...
Code: (Select All) CALL Pete(smart, ascii) ' But not on weekends and not past 5pm M-F.
PRINT smart, ascii
SUB Pete (dumb, ascii)
dumb = -1
ascii = 1
END SUB
Output -1, 1
So in this reference example, we see the variable value of dumb got passed by reference to the variable, "smart".
On the other hand, passing by value would mean the value of the variable assigned to the name of the variable would remain the same. So the code would need to be changed from dumb =-1 to smart = -1 to get the same output, but...
Sorry, I can't demo BYVAL in a sub or function, because this keyword is only available for use in DECLARE LIBRARY statements.
So here is a Windows example to minimize and maximize the window using BYVAL in a DECLARE Library statement...
Code: (Select All) DECLARE DYNAMIC LIBRARY "user32"
FUNCTION ShowWindow& (BYVAL hwnd AS LONG, BYVAL nCmdShow AS LONG) 'maximize process
END DECLARE
hWnd& = _WINDOWHANDLE
_KEYCLEAR
PRINT "Press a key to minimize this window and then press a key again to restore it..."
SLEEP
y& = ShowWindow&(hWnd&, 2) ' Minimize
_KEYCLEAR
SLEEP
PRINT: PRINT "We're back!"
y& = ShowWindow&(hWnd&, 9) ' Restore
If anyone has any example(s) that work in Linux, or Mac; or any additional info to post, feel free.
Right now, I have to solve the puzzle...
_ _ c k J _ _ B _ d _ n
Let's Go Brandon!
|
|
|
|