Author Topic: Drag-drop  (Read 5361 times)

0 Members and 1 Guest are viewing this topic.

Offline Mercurio

  • Newbie
  • Posts: 2
    • View Profile
Drag-drop
« on: August 25, 2019, 12:15:31 pm »
Hello!
Here one simple example for drag one object on the screen and drop it in another place.
From one old programmer in Qbasic.
* Drag-drop.txt (Filesize: 3.38 KB, Downloads: 265)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Drag-drop
« Reply #1 on: August 25, 2019, 01:54:06 pm »
Hi Mercurio,

Works for me, nice demo!

Welcome to the forum. :)

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Drag-drop
« Reply #2 on: August 25, 2019, 06:01:54 pm »
Yes
fine demo.
Welcome to QB64 world!
An amazing new world for Old Qbasic /QB  codes and with more, more suited functions to manage so  many aspects that are not in Qbasic and need so different PEEK/POKE and CALL ABSOLUTE/CALL INTERRUPT.
Moreover you type one code and you can run it in 3 different OSes.

Waiting more demo.
Programming isn't difficult, only it's  consuming time and coffee

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Drag-drop
« Reply #3 on: August 26, 2019, 06:57:00 am »
Mercurio, you are very welcome to our site.  Our site leader is Odin, and I see that you are Messenger to our god! (with slight mixing of mythologies!).

For the great length of time that I have been with this site, I still have  difficulties with mouse codings (when is a mouse permanently down or just clicked?) and I see that you have mastered such techniques already.

I see that you have used an _unsigned BIT type for your Boolean variable.  This is perfectly acceptable* and of course works completely as expected.  However, our QB64 Expert-in-all-Things, Steve McNeill, discourages use of _BIT type variables except in some special cases.  He would promote use of the _BYTE type variable for any Boolean.  This is just an advisory guide.

* As a matter of fact, using the _Unsigned BIT type means that it can have value 0 or 1.  The "convention" for True in QB64 is -1.  As you derive bott1~` from _MOUSEBUTTON(1) value, I shall be interested to hear the experts' comments.


Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Drag-drop
« Reply #4 on: August 26, 2019, 10:23:10 am »
Mercurio, you are very welcome to our site.  Our site leader is Odin, and I see that you are Messenger to our god! (with slight mixing of mythologies!).

For the great length of time that I have been with this site, I still have  difficulties with mouse codings (when is a mouse permanently down or just clicked?) and I see that you have mastered such techniques already.

I see that you have used an _unsigned BIT type for your Boolean variable.  This is perfectly acceptable* and of course works completely as expected.  However, our QB64 Expert-in-all-Things, Steve McNeill, discourages use of _BIT type variables except in some special cases.  He would promote use of the _BYTE type variable for any Boolean.  This is just an advisory guide.

* As a matter of fact, using the _Unsigned BIT type means that it can have value 0 or 1.  The "convention" for True in QB64 is -1.  As you derive bott1~` from _MOUSEBUTTON(1) value, I shall be interested to hear the experts' comments.

The biggest restriction of _BIT that I know of is that it can't be used with user defined types. Ha, I just learned you can have multiple bits option in a Type definition.

Steve might say you are not saving room in memory by using _BITs.

Offline Mercurio

  • Newbie
  • Posts: 2
    • View Profile
Re: Drag-drop
« Reply #5 on: September 08, 2019, 01:32:51 pm »
Thank you for Welcome
I'm one old programmer, for me not 1 is 0, not 0 is 1.

The Qbasic not have the boolean variables, boolean signed worst. The drag-drop example is one outgrowth of one
my old software of '90 years. If somebody is interested, i attach in this post one little txt of my old
subroutines for manage the mouse. Is possible it is useful for old hardware with MSDOS until Windows XP.
Naturally the variable bott% is integer.
My big surprise, is when i developped one recent videogame with the mouse subroutines with integer: something not go.
Fortunatly, some time after, i discover that is possible write the boolean variables.

For clear my mind, i conceive this experiment:

Code: QB64: [Select]
  1. bott% = 1 'The experiment can be repeated with bott% = 0 or -1 if want, or other, or other type variables, signed or unsigned.
  2.     bott% = NOT bott%
  3.     a% = a% + 1       'One check for see how many cicles does.
  4. LOOP UNTIL bott% > 1 OR bott% < 0 'The unexpected result go out. The parameters can be changed.
  5. COLOR 3: PRINT ; a%, bott%

One bug?
Best regards at allbody, and excuse for my delay (I have always a lot of things to do), and for my not advanced english.
* Old subroutines for mouse.txt (Filesize: 1.46 KB, Downloads: 196)

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Drag-drop
« Reply #6 on: September 08, 2019, 01:46:11 pm »
Thank you for Welcome
I'm one old programmer, for me not 1 is 0, not 0 is 1.

The Qbasic not have the boolean variables, boolean signed worst. The drag-drop example is one outgrowth of one
my old software of '90 years. If somebody is interested, i attach in this post one little txt of my old
subroutines for manage the mouse. Is possible it is useful for old hardware with MSDOS until Windows XP.
Naturally the variable bott% is integer.
My big surprise, is when i developped one recent videogame with the mouse subroutines with integer: something not go.
Fortunatly, some time after, i discover that is possible write the boolean variables.

For clear my mind, i conceive this experiment:

Code: QB64: [Select]
  1. bott% = 1 'The experiment can be repeated with bott% = 0 or -1 if want, or other, or other type variables, signed or unsigned.
  2.     bott% = NOT bott%
  3.     a% = a% + 1       'One check for see how many cicles does.
  4. LOOP UNTIL bott% > 1 OR bott% < 0 'The unexpected result go out. The parameters can be changed.
  5. COLOR 3: PRINT ; a%, bott%

One bug?
Best regards at allbody, and excuse for my delay (I have always a lot of things to do), and for my not advanced english.

NOT is a Boolean operator which swaps bits in a value.

In binary, 1 is 00000001.  Swap those 0s to 1s and that 1 to a 0, and it becomes 11111110 — which is what represents either 254, or -2 (depending on if it’s a SIGNED BYTE or UNSIGNED BYTE).

0, in binary, is 00000000.  Swap the 0s to 1, and you get 11111111 — which represents either 255 or -1 (again, depending on the difference between signed or unsigned byte).

So NOT zero is either 255, or its -1, depending on if you store the result in a signed or unsigned integer.

And, by inverse, NOT -1 is 0 (for signed integers)...



NOT 1 = -2
NOT 0 = -1
NOT -1 = 0

If you’re looking for TRUE/FALSE type values for not, use -1 and 0, with 0 being false and -1 being true.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Drag-drop
« Reply #7 on: September 08, 2019, 01:51:44 pm »
Hi Mercurio

I find interesting the use of interrupt and in QB64 also MouseMove is implemented but
for be clear  see here http://qb64.org/wiki/INTERRUPT or read this
Quote
Syntax
CALL INTERRUPT(intNum, inRegs, outRegs)

Parameters
Registers are emulated in QB64 and there is no support for intNum 33h mouse functions above 3 or intNum requests other than 33.
inRegs are the values placed into the call and outRegs are the register return values.

so if you want can use call interrupt emulated in your program or the internal functions of QB64 about mouse that you can find here
http://qb64.org/wiki/Keyword_Reference_-_Alphabetical#uM
moreover in QB64 mouse can be accessed as DEVICE http://qb64.org/wiki/Keyword_Reference_-_Alphabetical#uD

Moreover about assembler called by CALL ABSOLUTE read herehttp://qb64.org/wiki/CALL_ABSOLUTE

The goal of QB64 is to expand the Qbasic/QB45 limits in managing device of input and new hardwares like graphic card and sound card and image files and music files.

Welcome in the modern BASIC with high compatibility with QB!
I'll wait some your code (old and new) if you like share here in forum.
Programming isn't difficult, only it's  consuming time and coffee