Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Live Q&A, Using $DEBUG
#1
Bug 
Let us once and for all demystify $DEBUG, so you guys can use the IDE to the fullest. I'll be hosting a live Q&A tonight so we can go through whatever's still confusing for anyone who's interested in the debugging features.

$DEBUG in QB64: Live Q&A  Heart
Google Meet Link: https://meet.google.com/zfe-gssm-puy
Date/time: today, April 8th 2025, 8pm (GMT-3)
Easier way to know the time if timezones are an issue:  Event Time Announcer - Live Q&A: $Debug in QB64

If you're not able to attend, leave your question below and I'll address them to the best of my ability.

Meeting will be recorded and I'll post the resulting video here when it's available.

[Image: Whats-App-Image-2025-04-08-at-14-56-46.jpg]
Reply
#2
It's nice to see our 'Junior Members' getting so involved!

+2 for putting up with that comment.

Pete Big Grin
Reply
#3
OK I announced Debug Session at that other place with link to here. Smile
b = b + ...
Reply
#4
Thanks for spreading the word! Hope you guys can join me tonight, too.
Reply
#5
I see it's just past 9:00PM in Brazil, and the event has ended. Hope all went well and very much looking forward to viewing the video.

Pete
Reply
#6
I had a blast. As soon as google spits out the video I’ll post it here.
Reply
#7
Hope this is useful to y'all.


https://youtu.be/Yw0F3SOoD5A
Reply
#8
BTW, here's the code for the circles demo in the video: 

Code: (Select All)
Option_Explicit

Screen _NewImage(800, 600, 32)

Type Circle
    x As Single
    y As Single
    dx As Single
    dy As Single
    radius As Integer
    color As _Unsigned Long
    lastBumpedAgainstEdges As Single
End Type

' $Dynamic
Dim Shared circles(0) As Circle, quit As _Byte

' Initialize with 5 circles
Randomize Timer
InitializeCircles (5)

Do
    Cls
    UpdateCircles
    DrawCircles
    HandleInput

    _Display
    _Limit 60
Loop Until quit ' ESC key to exit

System

Sub InitializeCircles (numCircles As Integer)
    Dim i As Integer
    For i = 1 To numCircles
        AddCircle
    Next i
End Sub

Sub InitializeCircle (c As Circle)
    Dim j As Integer, i As Integer
    Dim oops As _Byte

    Do
        'loop until we create a circle that doesn't spawn in a collision
        c.x = Rnd * _Width
        c.y = Rnd * _Height
        c.dx = (Rnd - 0.5) * 10
        c.dy = (Rnd - 0.5) * 10
        c.radius = 10 + Rnd * 20
        c.color = _RGB32(Rnd * 255, Rnd * 255, Rnd * 255)

        ' Check collision with other circles
        oops = 0
        For j = 1 To UBound(circles) - 1
            oops = CheckCollision(c, circles(j))
            If oops Then Exit For
        Next j
    Loop While oops

    ' Bounce off edges - prevents newborn circles from getting stuck to the edges
    i = UBound(circles)
    If circles(i).x - circles(i).radius <= 5 Or circles(i).x + circles(i).radius >= _Width - 5 Then
        circles(i).dx = -circles(i).dx
        circles(i).lastBumpedAgainstEdges = Timer
    End If

    If circles(i).y - circles(i).radius <= 5 Or circles(i).y + circles(i).radius >= _Height - 5 Then
        circles(i).dy = -circles(i).dy
        circles(i).lastBumpedAgainstEdges = Timer
    End If
End Sub

Function timeElapsedSince! (startTime!)
    If startTime! > Timer Then startTime! = startTime! - 86400
    timeElapsedSince! = Timer - startTime!
End Function

Sub UpdateCircles
    Dim i As Integer, j As Integer, oops As _Byte

    For i = 1 To UBound(circles)
        circles(i).x = circles(i).x + circles(i).dx
        circles(i).y = circles(i).y + circles(i).dy

        ' Bounce off edges
        If timeElapsedSince(circles(i).lastBumpedAgainstEdges) > 1 Then
            If circles(i).x - circles(i).radius <= 5 Or circles(i).x + circles(i).radius >= _Width - 5 Then circles(i).dx = -circles(i).dx
            If circles(i).y - circles(i).radius <= 5 Or circles(i).y + circles(i).radius >= _Height - 5 Then circles(i).dy = -circles(i).dy
        End If

        If circles(i).x - circles(i).radius <= 0 Or circles(i).x + circles(i).radius >= _Width Or circles(i).y - circles(i).radius <= 0 Or circles(i).y + circles(i).radius >= _Height Then
            'brother's lost
            Dim c As Circle
            c.x = Rnd * _Width
            c.y = Rnd * _Height
            c.dx = (Rnd - 0.5) * 10
            c.dy = (Rnd - 0.5) * 10
            c.radius = 10 + Rnd * 20
            c.color = _RGB32(Rnd * 255, Rnd * 255, Rnd * 255)
            circles(i) = c
        End If


        ' Check collision with other circles
        For j = 1 To UBound(circles)
            If j = i Then _Continue
            oops = CheckCollision(circles(i), circles(j))
            If oops Then
                ' Collision detected, swap velocities
                Swap circles(i).dx, circles(j).dx
                Swap circles(i).dy, circles(j).dy
            End If
        Next j
    Next i
End Sub

Function CheckCollision%% (c1 As Circle, c2 As Circle)
    Dim dx As Single, dy As Single, distance As Single
    dx = c1.x - c2.x
    dy = c1.y - c2.y
    distance = Sqr(dx * dx + dy * dy)

    CheckCollision%% = (distance <= c1.radius + c2.radius)
End Function

Sub DrawCircles
    Dim i As Integer

    For i = 1 To UBound(circles)
        Circle (circles(i).x, circles(i).y), circles(i).radius, circles(i).color
        Paint (circles(i).x, circles(i).y), circles(i).color, circles(i).color
    Next i
End Sub

Sub HandleInput
    Dim k As Long
    k = _KeyHit

    Select Case k
        Case 27
            quit = -1
        Case 32 ' Spacebar adds a circle.
            AddCircle
        Case 82, 114 ' 'R' or 'r' removes a circle.
            RemoveCircle
    End Select
End Sub

Sub AddCircle
    Dim n As Integer

    n = UBound(circles) + 1
    ReDim _Preserve circles(1 To n) As Circle
    InitializeCircle circles(n)
End Sub

Sub RemoveCircle
    Dim n As Integer

    n = UBound(circles)
    If n > 1 Then ReDim _Preserve circles(1 To n - 1) As Circle
End Sub
Reply
#9
Can you stay in thread while I run it? That way, I can say I run circles around you.

Hey I got 1/2 way through the vid. Good stuff. Hope to finish it off by tomorrow, and see if I can remember everything.

Pete Big Grin
Reply
#10
@Fellippe
here the track points

you can refine it 
Quote:0-10 $Debug by menu or typed as first line of code
activating Debug  with F4 key (list of Watch) with F7 and with F8
Executing program line by line using F7 key
observe index of line in execution (triangle and highlighted line of code)
F8 step over for running one loop step (running once all the instructions in a loop)
F6 step out (sub/Function) for running until flow runs out of sub/function
F5 flow the code to debug loops and I/O with user

14.40 breakpoints to stop flow of code and observe status of application (output and variables)

23.30 use debug to find bottlenecks in the code

26.40 Adding watches for inspecting variables
      watching UDT made by TYPE...END TYPE, chosing elements to be observed
      whatching Arrays, chose elements of array to be observed

41.03 changing value of variables to test specific conditions

43.40 set next line to be executed

45.15 see the variables of a specific subprocedure

49.10 F7 runs a Whole line of code also if it has many commands separated by colon

49.30 Observe a variable setting a condition of its value or range of value

58.50 remove a condition of watching about a variable
I like this explaining moment that increases the knowledge of IDE.
Reply




Users browsing this thread: 1 Guest(s)