Discussion:
I want to halt execution
(too old to reply)
NadCixelsyd
2010-10-22 21:15:37 UTC
Permalink
Raw Message
I have just purchased PB, both Windows and Console version, although I
don't think I needed to buy both.

I'm converting a QuickBasic program. If I get to a you-shouldn't-be-
here situation, I simply put out an error message and exit the
program. I sometimes use STOP or SYSTEM. In VisualBasic, I simply
say END. Just so the user (me), knows that a major error has
occurred, sometimes I intentionally raise an error condition. The
only way I can find to exit a PB program is to go to the end of
PBMAIN. That's a pain to code, especially if I'm three functions
deep. Is there a way to just end the program? I've looked at the
manual but I can't find any way to end prematurely.

So I said to myself, "Hey, I'm a mathematician. I'll just divide by
zero to stop". WRONG. I find it incredible that PB doesn't stop.
It's not even an option. "OK," I said, "I'll just take the square
root of a negative number"... That doesn't work either.

And while QB doesn't check for array bounds (VB does), it should at
least be a PB option, especially when I'm debugging a program.

What other common errors does PB simply let slide?
Peter Manders
2010-10-25 14:13:06 UTC
Permalink
Raw Message
On Fri, 22 Oct 2010 14:15:37 -0700 (PDT), NadCixelsyd
Post by NadCixelsyd
I have just purchased PB, both Windows and Console version, although I
don't think I needed to buy both.
I'm converting a QuickBasic program. If I get to a you-shouldn't-be-
here situation, I simply put out an error message and exit the
program. I sometimes use STOP or SYSTEM. In VisualBasic, I simply
say END. Just so the user (me), knows that a major error has
occurred, sometimes I intentionally raise an error condition. The
only way I can find to exit a PB program is to go to the end of
PBMAIN. That's a pain to code, especially if I'm three functions
deep. Is there a way to just end the program? I've looked at the
manual but I can't find any way to end prematurely.
So I said to myself, "Hey, I'm a mathematician. I'll just divide by
zero to stop". WRONG. I find it incredible that PB doesn't stop.
It's not even an option. "OK," I said, "I'll just take the square
root of a negative number"... That doesn't work either.
And while QB doesn't check for array bounds (VB does), it should at
least be a PB option, especially when I'm debugging a program.
What other common errors does PB simply let slide?
It's not an error, it's a feature...

You have to rethink the way you write your programs. You're used to
having QB handle such things for you, but that results in an overhead
in speed and size of the executables. In PB you're responsible for
error checking, so you can decide for yourself if you want that
overhead or not. You can use ON EROR GOTO or just check the built in
ERR variable after those statements that need checking for errors.

You'll get a much better response to your questions on the PowerBasic
forums (fora) on their website. I also advise you try and find the
POFFS data, which you can use for offline searching of those forums.

If you want to abort your program you can call ExitProcess(exitcode)
when testing, but I don't advise using it in production code because
PowerBasic can't perform its clean up and exit code that way.

You can control array bound checking with:
#DEBUG ERROR ON
#DEBUG ERROR OFF
--
Peter Manders.

Wise men talk because they have something to say,
fools because they have to say something. (Plato)
Loading...