Page 1 of 1
Simple "Interupts"
Posted: Fri Sep 12, 2003 4:06 pm
by Dr.Delirium Tremens
My request is for a kind of interupt that can be set up in the program to momentarily jump to another section of code and then when that code is finished the interupt RETURNs control back to the program where it left off.
Interupts can be set for certain events. For example a timer.
//Warning!! Bad pseudo code ahead//
InteruptID = CreateInteruptTimer(60) ; Creates Interupt type, in this case
; a timer. Interupt every 60 sec.
SetInterupt(InteruptID,CheckEscape) ; Tells where InteruptID# will branch
; AND makes this interupt active
...
...
...
InteruptProcedure CheckEscape()
If KeyPressed = Escape then End
InteruptReturn
This could be useful when we (read: "I") write crappy code and accidently send the program in a endless loop.
Another example could be a KeyBoard Interupt. Press a particular key or combination of keys (ALT-F12).
:roll: Probally a silly request, so flame on.. wait don't flame PureBasic users have a rep for generally being nice.

Posted: Fri Sep 12, 2003 4:51 pm
by Paul
Just create a thread in your program to do this.
Posted: Fri Sep 12, 2003 5:09 pm
by Dr.Delirium Tremens
Threads... I will look this up. Thanks. I am *very* new to PureBasic and very eager to work some magic. 600+ commands is a lot of tools to grasp, but I will try to be more patient with request as not to waste Freds time.
Thanks again Paul... just feeling a little silly at the moment for not seeing this one. DOH!

Posted: Fri Sep 12, 2003 5:44 pm
by freedimension
Get Danilo's PureTools, there you got a Timer library which does just that. Very easy to use.
Posted: Fri Sep 12, 2003 7:29 pm
by Karbon
Windows gives you a timer too -
viewtopic.php?t=7460
Re: Simple "Interupts"
Posted: Sat Sep 13, 2003 2:03 am
by PB
I was going to suggest threads/timers too but then noted that he wants to
return to the place where the interrupt started -- and threads/timers don't
do that. An interrupt is not the same thing. An interrupt is like a timed
Gosub/Return routine (which a thread/timer isn't).
Re: Simple "Interupts"
Posted: Sun Sep 14, 2003 4:56 pm
by PB
> This could be useful when we (read: "I") write crappy code and
> accidently send the program in a endless loop.
Why not just click the "Quit" button in the debugger window if you
get into an endless loop? You have enabled the debugger, right?
Posted: Mon Sep 15, 2003 5:23 pm
by Dr.Delirium Tremens
Ah, PB you hit the nail on the head in your previous statment before last. The crappy code scenerio was just that, an example for a possible use and to explain what I meant. It was just an example. Tho, I have many a time sent my computer into the cycle of sleepless death. Who hasn't ? You don't program for 20 years without doing that a few times.
And I do know about the debugger. I am new to PureBasic and I made a couple fruitless request, but I am not stupid
Speaking of stupid and debugger...
Some years back, I had ran into a problem where a program I had written starting giving poor speeds at runtime. I rewrote code to speed things up and still had slow results. I streamlined more and unrolled loops, and... Darn it, I left the degugger on! I got upset with all the time I wasted and in the heat of the moment I deleted the highly modified program and much like remembering you left your keys in the car the second the car door leaves your hand to SLAM shut, I remembered not only was I complete idiot for not disabling debug and wasting all that time, I discovered I was also I utter moron as I did not save any backup(s).
Anyways, like I said: I am NOT stupid. I can only dream of being 'stupid'.
I HAVE progressed beyond idiot and moron. I'm an imbicile at the moment, but hey- I AM evolving.
All right y'all, help some other newbie. I do appreciate EVERYONE's suggestions/help.
I am no longer requesting this feature, as it's really unneeded (at the moment).

Posted: Tue Sep 16, 2003 2:54 am
by PB
> Anyways, like I said: I am NOT stupid.
Relax, nobody said that you were.
Posted: Tue Sep 16, 2003 7:42 pm
by Dr.Delirium Tremens
I guess I should have put more smileys in my message.
I'm fine, PB.
>Relax, nobody said that you were.
Relax? RELAX?! DON'T TELL Me to.. . . r e l a x. (Zzzzz...)
Honestly though guy, I am not mad or upset. Very relaxed. Really.
Posted: Wed Sep 17, 2003 2:47 am
by PB
Posted: Wed Sep 17, 2003 6:28 pm
by Karbon
Judging from your name you're far from fine! DTs are a bit crazy!
Posted: Wed Sep 17, 2003 10:30 pm
by Dr.Delirium Tremens
<big grin>
Posted: Fri Sep 19, 2003 10:59 am
by PolyVector
Maybe I'm a little late with this but...
I was going to suggest threads/timers too but then noted that he wants to
return to the place where the interrupt started -- and threads/timers don't
do that.
couldn't you just have a timer thread call an "interrupt" function... then it would return where it left off... if that makes sense...i'm just tired...it's 3 in the morning
*sleeps*