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

0 Members and 1 Guest are viewing this topic.

FellippeHeitor

  • Guest
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: 364
    • View Profile
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: 3972
    • View Profile
    • 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!

FellippeHeitor

  • Guest
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: 364
    • View Profile
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).



  [ You are not allowed to view this attachment ]  

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
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
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

FellippeHeitor

  • Guest
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: 3972
    • View Profile
    • 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!

FellippeHeitor

  • Guest
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: 26
    • View Profile
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




FellippeHeitor

  • Guest
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.

FellippeHeitor

  • Guest
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

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • 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.
Shuwatch!

Offline mpgcan

  • Newbie
  • Posts: 26
    • View Profile
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.

FellippeHeitor

  • Guest
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:
 [ You are not allowed to view this attachment ]
- 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.
 [ You are not allowed to view this attachment ]
- 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:
 [ You are not allowed to view this attachment ]
- 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 »