Page 1 of 1

Beep On/Off

Posted: Fri Feb 24, 2006 2:33 pm
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

Re: Beep On/Off

Posted: Fri Feb 24, 2006 2:38 pm
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

Posted: Fri Feb 24, 2006 2:47 pm
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)

Posted: Fri Feb 24, 2006 2:48 pm
by Flype
Macro is faster but the executable is bigger.
Procedure is slower but the executable is smaller.
:wink:

Posted: Fri Feb 24, 2006 2:50 pm
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.

Posted: Fri Feb 24, 2006 2:57 pm
by Flype
i wanted to say faster/slower at run-time

Posted: Fri Feb 24, 2006 3:04 pm
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.

Posted: Fri Feb 24, 2006 3:12 pm
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.