Beep On/Off

Windows specific forum
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Beep On/Off

Post by Flype »

Sometimes, the hardware beep might be very annoying in some apps.
Just 2 handy macros:

Code: Select all

Macro BeepOn()
  RunProgram("net","start beep","")
EndMacro
Macro BeepOff()
  RunProgram("net","stop beep","")
EndMacro
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Beep On/Off

Post by PB »

A question for Fred: what's the difference between doing the above, or doing
it with a procedure like so? Is one more optimized than the other in this case,
or in all cases?

Code: Select all

Procedure BeepOn()
  RunProgram("net","start beep","")
EndProcedure
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

@Pb:

Read up on macro's ;) Dont you know what they do?

If you use a macro, the code inside the macro you declare will be written at the calling point. With procedures, it CALLS the procedure.

If you use the above code 2000 times, macro's will produce the FASTEST code, but the largest filesize.
Using procedures will produce the slowest code, but smallest size. Besides you can do various trics with procedures that you cant do with macro's. (addresses. Eg self modification)
Last edited by thefool on Fri Feb 24, 2006 2:48 pm, edited 1 time in total.
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

Macro is faster but the executable is bigger.
Procedure is slower but the executable is smaller.
:wink:
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
DarkDragon
Addict
Addict
Posts: 2347
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post by DarkDragon »

Flype wrote:Macro is faster but the executable is bigger.
Procedure is slower but the executable is smaller.
:wink:
No, can't be true, Procedure has another Jumpmark, Macro is replaced while compiling, so Macro = slower and faster, but has no local variables and you can do other things with it, what you can't when using Procedure.
bye,
Daniel
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

i wanted to say faster/slower at run-time
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
DarkDragon
Addict
Addict
Posts: 2347
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post by DarkDragon »

Flype wrote:i wanted to say faster/slower at run-time
I told you just something about the size, not about the faster/slowerness. The thing about macros are faster is true.
bye,
Daniel
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> Dont you know what they do?

Yes, I know they replaced the code, which is great, but I didn't think a procedure
calling the same code would be slower. Now I know! :) Thanks to all.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Post Reply