Author Topic: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩  (Read 2745 times)

0 Members and 1 Guest are viewing this topic.

Offline FellippeHeitor

  • QB64 Developer
  • Forum Resident
  • Posts: 3077
  • Let it go, this too shall pass.
    • QB64.org
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩
« Reply #90 on: September 14, 2021, 12:36:50 PM »
Color schemes are now individually configurable per running instance of IDE, just like it was already for window size and position. You will find separate sections for each instance in the new config file.

Offline Richard

  • Seasoned Forum Regular
  • Posts: 344
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩
« Reply #91 on: September 14, 2021, 08:23:30 PM »
@FellippeHeitor

Thanks - thinking about it - it is a very useful feature for me as I use multiple instances of QB64 a lot.

Although many will "frown" upon it - for convenience with massive re-editing of a particular program I am currently working on - I will have set up different colored backgrounds (say red instead of black) to remind me which instance "not to edit" of the exact same file (Rather than using say notebook for the "reference copy" or rather than using a number of Alt ^ bookmarks etc).

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3709
    • Steve’s QB64 Archive Forum
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩
« Reply #92 on: September 14, 2021, 08:46:09 PM »
What’s the hotkey to add $DEBUG into the code?

I was doing something on the  laptop today and had a mysterious popup appear on the screen saying “Do you want to insert $DEBUG here…”  What’s the combo for that, and is there a way to alter it? 

Seems like it’s probably something like a SHIFT+Right Click (or similar), as it’s not a common combo action, but was something that appeared when I was trying to copy/paste a large code segment into the  IDE. 

My normal workflow is usually something like:
Shift+Arrow Keys to select a code block. (Or sometimes CTRL+arrow keys)
Right click to open copy/paste dialog.

And it was some combo in that process that popped up an insert dialog, rather than the normal copy/paste routine.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline FellippeHeitor

  • QB64 Developer
  • Forum Resident
  • Posts: 3077
  • Let it go, this too shall pass.
    • QB64.org
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩
« Reply #93 on: September 14, 2021, 09:19:03 PM »
Any function key/key combo that has a function associated to it during $Debug mode will trigger the prompt. That includes - but is not limited to - F4, F7, F8, F9, Ctrl+P.

Offline Richard

  • Seasoned Forum Regular
  • Posts: 344
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩
« Reply #94 on: September 14, 2021, 09:30:44 PM »
@SMcNeill

Although not answering your question....

I have often been "caught" by where the cursor is - refer screenshot (the green cross-hairs illustrate the extreme right position where the "insert Debug Metacommand? is triggered (accurate to a pixel position for me).



 

Offline Pete

  • Forum Resident
  • Posts: 2668
  • Cuz I sez so, varmint!
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩
« Reply #95 on: September 14, 2021, 09:41:11 PM »
What’s the hotkey to add $DEBUG into the code?

After hours of trial an error, I finally figured it out. It's an overly complicated key combination, but it works...

$+D+E+B+U+G

Pete

Offline FellippeHeitor

  • QB64 Developer
  • Forum Resident
  • Posts: 3077
  • Let it go, this too shall pass.
    • QB64.org
You may also have clicked the line numbers, which is used to set a breakpoint (or to skip a line, if in conjunction with Shift). - That's also what Richard means to say happens in his screen shot above.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3709
    • Steve’s QB64 Archive Forum
You may also have clicked the line numbers, which is used to set a breakpoint (or to skip a line, if in conjunction with Shift). - That's also what Richard means to say happens in his screen shot above.

This is probably what happened. 

Do you think you could add an option to the menu fora toggle to disable $DEBUG interactions, much like the toggle for warnings and syntax checking?  It’d be nice to stop those accidental interactions until one wanted them explicitly.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline FellippeHeitor

  • QB64 Developer
  • Forum Resident
  • Posts: 3077
  • Let it go, this too shall pass.
    • QB64.org
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩
« Reply #98 on: September 14, 2021, 11:26:28 PM »
Sure.

Offline mpgcan

  • Newbie
  • Posts: 15
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩
« Reply #99 on: September 15, 2021, 09:22:08 AM »
The following code compiles and runs on both 32 and 64 dev versions (Note no $Debug  meta command).
Code: QB64: [Select]
  1. 'Desktop Size
  2. 'Returns the Left, Top, Right and Bottom coordinates of the current desktop area.
  3. 'https://www.qb64.org/wiki/Windows_Libraries
  4.  
  5.     FUNCTION SystemParametersInfoW& (BYVAL uiAction~&, BYVAL uiParam~&, BYVAL pvParam%&, BYVAL fWinlni~&)
  6.  
  7. CONST SPI_GETWORKAREA = &H30
  8.  
  9. TYPE RECT
  10.     left AS LONG
  11.     top AS LONG
  12.     right AS LONG
  13.     bottom AS LONG
  14. DIM Rec AS RECT
  15.  
  16. IF 0 = SystemParametersInfoW(SPI_GETWORKAREA, 0, _OFFSET(Rec), 0) THEN
  17.     'function failed. You may call kernel32's GetLastError for more info.
  18.     PRINT "failed."
  19.  
  20. PRINT Rec.left
  21. PRINT Rec.top
  22. PRINT Rec.right
  23. PRINT Rec.bottom
  24.  
After adding the $Debug meta command both dev versions fail to compile above code. Error message from compilelog.txt
Code: QB64: [Select]
  1. In file included from qbx.cpp:1099:
  2. ..\\temp\\regsf.txt:5:11: ERROR: redefinition of 'HINSTANCE__* DLL_user32'
  3.  HINSTANCE DLL_user32=NULL;
  4.            ^~~~~~~~~~
  5. compilation terminated due TO -Wfatal-errors.
  6.  
Simple solution replace Declare Dynamic Library "user32" with Declare CustomType Library
However that's not a real solution it just masks the problem.

QB64 Development Builds:
QB64x32 1.6 75939af
QB64x64 1.6 75939af

PC spec as follows:
 Windows 8.1
 Processor Intel(R) Core(TM) i3-3217U CPU 1.8 GHz
 Installed memory RAM 4GB
 System type: 64-bit Operating System, x64-based processor




Offline FellippeHeitor

  • QB64 Developer
  • Forum Resident
  • Posts: 3077
  • Let it go, this too shall pass.
    • QB64.org
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩
« Reply #100 on: September 15, 2021, 09:31:34 AM »
$Debug needs "user32" in Windows.

Offline FellippeHeitor

  • QB64 Developer
  • Forum Resident
  • Posts: 3077
  • Let it go, this too shall pass.
    • QB64.org
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩
« Reply #101 on: September 15, 2021, 04:40:34 PM »
Although many will "frown" upon it - for convenience with massive re-editing of a particular program I am currently working on - I will have set up different colored backgrounds (say red instead of black) to remind me which instance "not to edit" of the exact same file (Rather than using say notebook for the "reference copy" or rather than using a number of Alt ^ bookmarks etc).

That's precisely how I've been using it.

Offline SpriggsySpriggs

  • QB64 Developer
  • Forum Resident
  • Posts: 1109
  • If you're API and you know it clap your hands
    • My GitHub
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩
« Reply #102 on: September 15, 2021, 05:03:23 PM »
@mpgcan I'm working with Fellippe on getting that fixed. I've tested a fix for it. It's super minor. Fellippe is going to test as well. Should make the User32 error disappear completely and allow you to use the function. However, I do recommend going ahead and using Declare CustomType Library instead of Declare Dynamic Library when the function allows for it. Most User32 functions can be put in a CustomType block rather than Dynamic. Let me know if you need any help or come across any further compilation errors when using external functions.
If you're API and you know it clap your hands
My GitHub

Offline mpgcan

  • Newbie
  • Posts: 15
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩
« Reply #103 on: September 16, 2021, 04:05:59 AM »
Hi Spriggsy and Fellippe thank you both  for the feedback.  Spriggsy I do understand it is preferential to use  Declare CustomType Library instead of  Declare Dynamic Library.
That said your solution if successful will only add to the flexibility of QB64. I cant wait to test the proposed solution.

"Let me know if you need any help or come across any further compilation errors when using external functions." offer most appreciated I am sure  at a latter date will be required thank you.

Marked as best answer/most recent update by odin on September 19, 2021, 02:27:31 AM

Offline FellippeHeitor

  • QB64 Developer
  • Forum Resident
  • Posts: 3077
  • Let it go, this too shall pass.
    • QB64.org
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! ✨🤩
« Reply #104 on: September 18, 2021, 11:18:50 PM »
New dev build available, get it from https://www.qb64.org/portal/development-build/
This is what to look for:

- Issue reported above by mpgcan regarding declaring user32.dll procedures in Windows has been addressed.
- Can now set values of _BIT variables.
- Option in Debug menu to disable auto-insertion of $DEBUG meta command as suggested by Steve.

✨ **NEW** ✨
- Watchpoints: you can now set watchpoints, which are like breakpoints but for variable values. You can, for example, create a watchpoint for variable x&, with condition "= 1000" and hit F5 so your program will run until x& = 1000.

Here's how it works:
- Start your $Debug-enabled program in pause mode (either with F7 or F8).
- Hit F4 to show the "Add Watch" dialog.
- Here, you can double click variables to add them to the Watch Panel, or you can select a variable and click the "Add Watchpoint" button.
- A new dialog will pop asking for a condition:

- The valid operators are =, <=, >=, and <>. You must compare a variable's contents with a literal value (no other variables, no math, no scientific notation).
- If you also add the variable to the watchlist, it will show in the Watch Panel, as usual, and an extra red bullet will be placed right next to its name, so you know there's a watchpoint set.

- Now you can hit F5 and let your program run until the variable has the target value. If the condition is ever met, execution is paused and you get this dialog:

- From here you can click "OK" to continue in the IDE so you can look around the line that set the variable's value as you expected, or you can click "Clear Watchpoint" to remove the watchpoint so execution can continue.
- If you don't clear the watchpoint from the dialog, you can go back to the F4 dialog later and delete the watchpoint condition manually.

Let me know how it works in your tests. 🥰
« Last Edit: September 18, 2021, 11:28:51 PM by odin »