Output from WAIT(-1)
|
01-06-2021, 09:57 PM
Post: #1
|
|||
|
|||
Output from WAIT(-1)
Hi all,
In a program I am making, I use the command WAIT (-1) to register both keystrokes and screen touch. In the documentation I have it says that when I touch the screen I get the following output: {type, [x, y], [dx, dy]}. An example of this is {#3h;#B0:-16h;#96:-16h}. How should I interpret this output? The '#3h' is of course the 'type', and indicates what kind of movement has been recorded. The '#B0' and the '#96' are the x and y coordinates where the screen is touched, but what should I do with those '-16h', and how can I remove it? To make those x and y coordinates usable, it will probably be necessary to convert them to decimal integers. I would like to hear how I can best process this information. Thanks in advance! Sincerely, Karel. I use HP-16C, WP-34S emulator, HP-35s, HP-48GX, HP-50g, and HP Prime G2. |
|||
01-07-2021, 04:54 AM
(This post was last modified: 01-07-2021 04:56 AM by Joe Horn.)
Post: #2
|
|||
|
|||
RE: Output from WAIT(-1)
When Prime displays a binary integer in Home in this form:
#123:16h the trailing part :16h means that it's a 16-bit word, which is different from the current Home Setting for the default word size of binary integers. Try this: type #123 and press Enter. You'll see #123h by itself. Now go into Home Settings and change the default Integers word size to 16, and go back into Home. The result that previously looked like "#123h" now shows its wordsize, because it's now different from the default. Type #123 Enter, and reset the default word size to 32 (or 64 or whatever you prefer). Once again the previous results will look different, with their word size being displayed after a colon unless their word size is the same as the current default. EDIT: If the word size is displayed as negative, it means that the binary integer was created as a signed number, not an unsigned number (settable at the end of the Integers line in Home Settings). Hope that made sense! <0|ɸ|0> -Joe- |
|||
01-08-2021, 04:55 PM
Post: #3
|
|||
|
|||
RE: Output from WAIT(-1)
Dear Mr. Horn,
The explanation you have given is very clear. What I can't understand is why the x and y values are returned as a signed number when it is set in home settings that no signed numbers should be used. There are no negative values themselves in the x and y values. And how can I get rid of that word size, if I only need the binary values of x and y? Sincerely, Karel. I use HP-16C, WP-34S emulator, HP-35s, HP-48GX, HP-50g, and HP Prime G2. |
|||
01-08-2021, 10:20 PM
Post: #4
|
|||
|
|||
RE: Output from WAIT(-1)
(01-08-2021 04:55 PM)cahlucas Wrote: Dear Mr. Horn, Question #1: Your Home Setting does NOT mean that no signed numbers should be used; it means that when you ENTER binary integers from the keyboard, or when you obtain binary integers as the result of a calculation, THEN what you get are unsigned. That's different from the binary integers you obtain from some functions which always return them with a specific word size and/or signed/unsigned. For example, type TOff or TDim in Home (be sure to type the letters exactly as shown, with the first two letters uppercase and the next two letters lowercase). You'll always obtain unsigned 30-bit numbers, no matter what your Home Settings are for binary integers. Question #2: You ask how to get rid of that word size. The answer is simple: Don't. There is no need to get rid of it. Just use the result as-is, or convert it to a real number using the B→R function. What appears after the colon is merely information for you. If you don't need that information, ignore it. <0|ɸ|0> -Joe- |
|||
01-09-2021, 06:14 PM
(This post was last modified: 01-09-2021 06:16 PM by cahlucas.)
Post: #5
|
|||
|
|||
RE: Output from WAIT(-1)
Dear Mr. Horn,
So code as shown below should work fine. Please let me know if anything is wrong or if something needs to be inserted. I hope to hear from you soon. Sincerely, Karel. Code:
I use HP-16C, WP-34S emulator, HP-35s, HP-48GX, HP-50g, and HP Prime G2. |
|||
01-09-2021, 08:48 PM
Post: #6
|
|||
|
|||
RE: Output from WAIT(-1)
This code, derived from yours, works fine.
Are you having problems with your code? Code:
|
|||
01-09-2021, 09:36 PM
Post: #7
|
|||
|
|||
RE: Output from WAIT(-1)
(01-09-2021 08:48 PM)john gustaf stebbins Wrote: Are you having problems with your code? Dear Mr. Stebbins, The code in this thread apparently works fine, the problem is in another part of my program, which I have created a new thread for. In your code, a circle is drawn where the screen is touched, and I don't need a circle in my program. Sincerely, Karel. I use HP-16C, WP-34S emulator, HP-35s, HP-48GX, HP-50g, and HP Prime G2. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)