Simple "Interupts"

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Dr.Delirium Tremens
New User
New User
Posts: 7
Joined: Wed Sep 10, 2003 1:34 am

Simple "Interupts"

Post 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. :wink:
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1282
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

Just create a thread in your program to do this.
Image Image
Dr.Delirium Tremens
New User
New User
Posts: 7
Joined: Wed Sep 10, 2003 1:34 am

Post 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! :oops:
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

Post by freedimension »

Get Danilo's PureTools, there you got a Timer library which does just that. Very easy to use.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Windows gives you a timer too -

viewtopic.php?t=7460
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Simple "Interupts"

Post 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).
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Simple "Interupts"

Post 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?
Dr.Delirium Tremens
New User
New User
Posts: 7
Joined: Wed Sep 10, 2003 1:34 am

Post 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. :wink:

And I do know about the debugger. I am new to PureBasic and I made a couple fruitless request, but I am not stupid :P

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. :D


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). :wink:
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> Anyways, like I said: I am NOT stupid.

Relax, nobody said that you were.
Dr.Delirium Tremens
New User
New User
Posts: 7
Joined: Wed Sep 10, 2003 1:34 am

Post by Dr.Delirium Tremens »

I guess I should have put more smileys in my message.

I'm fine, PB. :D :) :lol: :o :wink:


>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.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> I'm fine, PB. :D :) :lol: :o :wink:

LOL!
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Judging from your name you're far from fine! DTs are a bit crazy!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Dr.Delirium Tremens
New User
New User
Posts: 7
Joined: Wed Sep 10, 2003 1:34 am

Post by Dr.Delirium Tremens »

<big grin>
PolyVector
Enthusiast
Enthusiast
Posts: 499
Joined: Wed Sep 17, 2003 9:17 pm
Location: Southern California
Contact:

Post 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*
Post Reply