LoginLogin

SYSBEEP Discussion

Root / General / [.]

12Me21Created:
When you turn off SYSBEEP, please turn it on again reset it after. It's really annoying when you don't. Thank you. EDIT: Use
VAR TMP_BEEP = SYSBEEP
SYSBEEP = 0
(some code here)
SYSBEEP = TMP_BEEP
or
IF SYSBEEP THEN
  SYSBEEP = 0
  GOSUB @CODE
  SYSBEEP = 1
ELSE
  GOSUB @CODE
ENDIF
(longer but doesn't use any variables) This also applys to things like FONTDEF, BGMPLAY, anything that persists past the end of a program, and isn't cleared at the beginning. Note: SYSBEEP is NOT reset when you return to the menu.

This might be a dumb question, but is it possible to ensure that a piece of code gets run on program exit when a user presses start?

Unfortunately, no However, you can do something like:
SYSBEEP = 0
(whatever code requires sysbeep to be off)
SYSBEEP = 1
of course, this can still be interupted by pressing SELECT/START, but I think the only reason people turn SYSBEEP off is when saving, and you can't exit the program then.

Oh I see what you mean

Actually, when you turn off SYSBEEP, please return it to the state it was in before. Otherwise, it'd be really annoying. EDIT: This post made more sense when the OP was "When you turn off SYSBEEP, please turn it on again ...".

Actually, when you turn off SYSBEEP, please return it to the state it was in before. Otherwise, it'd be really annoying.
Like:
VAR TMP_BEEP = SYSBEEP
SYSBEEP = 0
(some code here)
SYSBEEP = TMP_BEEP

Actually, when you turn off SYSBEEP, please return it to the state it was in before. Otherwise, it'd be really annoying.
Like:
VAR TMP_BEEP = SYSBEEP
SYSBEEP = 0
(some code here)
SYSBEEP = TMP_BEEP
Yes, that is much better. You could also do something like
IF SYSBEEP THEN
  SYSBEEP = 0
  GOSUB @CODE
  SYSBEEP = 1
ELSE
  GOSUB @CODE
ENDIF
Which is longer but doesn't use any variables I'm not sure why you would want SYSBEEP off, though Isn't it easier to type if the keys give some feedback?

When does this matter? If I'm making a game where there is no keyboard input at all, but there's a lot of loading files, then I would want to keep SYSBEEP off. I'm the developer, and if my program/game doesn't benefit from having it on then why should I turn it on? Same goes for font and BGM. As long as these things don't interfere during normal use of the program or game, then the dev shouldn't have to worry about it. If you're doing weird things with other people's code, or you're modifying it or learning how it works, and this kind of stuff bothers you, you should just take care of it on your end and save it for your own personal future use/reference. It's actually a bit rude to ask every single other developer to adhere to one obscure and arguably problematic practice just to save yourself a minor effort when you use the same code for anything other than executing it. Am I missing something? Do these settings stick after you return to the main menu?

They do not stick around when you return to the main menu. They do stick around when you return to Direct Mode.

If I'm making a game where there is no keyboard input at all, but there's a lot of loading files, then I would want to keep SYSBEEP off. I'm the developer, and if my program/game doesn't benefit from having it on then why should I turn it on?
The load sound doesn't play if you disable the load dialog this time around.

If I'm making a game where there is no keyboard input at all, but there's a lot of loading files, then I would want to keep SYSBEEP off. I'm the developer, and if my program/game doesn't benefit from having it on then why should I turn it on?
The load sound doesn't play if you disable the load dialog this time around.
Good to know. What does SYSBEEP prevent then? Edit: besides keyboard sounds

I think it's just keyboard sounds and warning sounds (an error will beep once). As I always return to the main menu before I run someone else's program, I felt no need to clean up for something this minor in my opinion (and I didn't for my Ogiri entry). If it's only a matter of adding "SYSBEEP = 1" at the end, I might do it. But the VAR and IF...THEN method just confuses me and sorry, I honestly don't care. I suggest resetting everything by returning to the main menu.

it's as simple as this VAR SBOLD%=SYSBEEP at your program's init routine, and SYSBEEP=SBOLD% at your program's exit routine. This puts SYSBEEP at whatever state it was before the user started the program, assuming the user exits properly (without using START or a crash).

it's as simple as this VAR SBOLD%=SYSBEEP at your program's init routine, and SYSBEEP=SBOLD% at your program's exit routine. This puts SYSBEEP at whatever state it was before the user started the program, assuming the user exits properly (without using START or a crash).
The problem is that that is pretty common. It's safer to have SYSBEEP changed for the shortest amount of time.

Just thinking on the fly here... how about
DEF QUIETLY COMMAND$
VAR OLDSYSBEEP%=SYSBEEP
CALL COMMAND$
SYSBEEP=OLDSYSBEEP%
END
to be invoked like QUIETLY "SAVEGAME" with, elsewhere, DEF SAVEGAME. Wrap the sysbeepy components in their own DEFs, then use them QUIETLY. Then, SYSBEEP will, almost all the time, be the value it was when the program started, without too much intrusion into the code. If parameters are necessary, maybe something like
DEF QUIETLY COMMAND$,FILENAME$ OUT RESULT$
VAR OLDSYSBEEP%=SYSBEEP
CALL COMMAND$,FILENAME$ OUT RESULT$
SYSBEEP=OLDSYSBEEP%
END
This could be used with the system command LOAD, for instance (not even needing a DEF wrapper): QUIETLY "LOAD","TXT:TXTFILE"+STR$(I%) OUT ARRAY$[I%]

IF SYSBEEP THEN
  SYSBEEP = 0
  GOSUB @CODE
  SYSBEEP = 1
ELSE
  GOSUB @CODE
ENDIF
ELSE can't be used in that context. ELSE can only be used in one line IF statements. Instead use ELSEIF 1 THEN

IF SYSBEEP THEN
  SYSBEEP = 0
  GOSUB @CODE
  SYSBEEP = 1
ELSE
  GOSUB @CODE
ENDIF
ELSE can't be used in that context. ELSE can only be used in one line IF statements. Instead use ELSEIF 1 THEN
You're wrong, by the way. Test it and it works totally fine :P

Ugh! I thought it was only the load sound that bothered me so I removed SYSBEEP=0 and just set LOAD FALSE in my Ogiri program and publicly released it, but now I'm in deep regrets - it beeps every time a dialog pops up! I should have just kept what I did - turn off SYSBEEP and not turn it back on/return state. I just don't... I'm sorry, care. I need that beep OFF at all times, it's ruining my game :( Maybe I'll reupload it (either put SYSBEEP=0 at the beginning and SYSBEEP=1 at the end, or nothing at the end) and change my key. I wanted to use post #13's method, but #14 seems to be telling me there's a problem with that code. #15 looks too pro to a beginner like me, #7-#16-#17 looks contradicting... I just don't know what to believe anymore. #stopyourstupidrantlohad

IF SYSBEEP THEN
  SYSBEEP = 0
  GOSUB @CODE
  SYSBEEP = 1
ELSE
  GOSUB @CODE
ENDIF
ELSE can't be used in that context. ELSE can only be used in one line IF statements. Instead use ELSEIF 1 THEN
I'm not sure what even made you think that. It's even used in the example for ELSE in the reference: http://smilebasic.com/en/reference/#control

I hate typing with SYSBEEP off.