How to Restart a Bogged Down Program
#7
Without seeing the code itself, my initial guess would be probable corruption via a passed parameter.

Let's say we have some simple code like this:

Code: (Select All)
delay = 10 'we start with a limit of 10 loops per second as a manual/visable pause

Do
    For pause = 1 To delay 'just a pause for 1 second
        _Limit 10 'we'll run this loop 10 times per second, which is how we get a 1 second pause.
    Next
    k = _KeyHit
    Select Case k
        Case 32 'call the sub and watch what happens
            SlowDown delay
        Case 27
            System
    End Select

    Print count, "We had to run the pause loop "; delay; "times, which took "; delay / 10; "seconds."
    count = count + 1

Loop


Sub SlowDown (l)
    l = l * 2
End Sub


Compile and run the above.  You'll see that we start out printing text to the screen every second.  Hit the spacebar however, and trigger our SUB, and we double the delay in printing.   Our SUB is passing values back and forth via the parameters, and that's changing how the main program works afterwards,

IF this corruption via parameter is your issue, the simple solution is to pass a value and then assign it to a different variable inside the sub afterwards, preserving the original completely.

Code: (Select All)
Sub SlowDown (templ)
    l = templ 'assign the passed value to a different variable so its value won't change when leaving the sub or function.
    l = l * 2
End Sub
Reply


Messages In This Thread
RE: How to Restart a Bogged Down Program - by SMcNeill - 04-21-2023, 08:23 PM
RE: How to Restart a Bogged Down Program - by jcm - 04-23-2023, 03:00 AM



Users browsing this thread: 4 Guest(s)