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

Advanced game related topics
Alex777
User
User
Posts: 47
Joined: Sun Nov 16, 2008 12:47 am
Location: Cayman Is.
Contact:

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

Post 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.
User avatar
luis
Addict
Addict
Posts: 3876
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

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

Post 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 ?
"Have you tried turning it off and on again ?"
A little PureBasic review
Alex777
User
User
Posts: 47
Joined: Sun Nov 16, 2008 12:47 am
Location: Cayman Is.
Contact:

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

Post by Alex777 »

Thanks, Luis! You are right - it's not difficult to track it myself, which is what I will do.
Post Reply