Page 1 of 1

Bullet-proof way to check if a Screen is open?

Posted: Sun Feb 02, 2014 6:36 pm
by Alex777
Anybody know a bullet-proof way to determine if a Screen is open? The Help file says that if I call ScreenDepth(), it "Returns the current screen depth, or zero if no screen is opened." But if I call ScreenDepth() when a screen is not open, I get a fatal error.

Re: Bullet-proof way to check if a Screen is open?

Posted: Sun Feb 02, 2014 9:37 pm
by luis
Alex777 wrote: I get a fatal error.
...with the debugger enabled. I know it's a little strange for a command to return 0 in release mode if it fails and yet you can't practically rely on that because you can't debug your program with that code.

But you can temporarily disable the debugger around it, so there is a way to do what you want.

Code: Select all

InitSprite()

DisableDebugger
i = ScreenDepth()
EnableDebugger

Debug i
Maybe a command like IsScreen() would be nice, but can't you track if your screen is open or not by yourself ?

Re: Bullet-proof way to check if a Screen is open?

Posted: Mon Feb 03, 2014 12:53 am
by Alex777
Thanks, Luis! You are right - it's not difficult to track it myself, which is what I will do.