- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
When a program terminates I get a message like 'Program .. has exited with code 0.' Could anyone please help me finding all the possible code values with which a program can exit.
Thanks,
Vivek
When a program terminates I get a message like 'Program .. has exited with code 0.' Could anyone please help me finding all the possible code values with which a program can exit.
Thanks,
Vivek
Link Copied
7 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The exit code can be anything. 0 usually means success. It's entirely up to the program to specify what the exit code is - in Fortran, you'd use CALL EXIT to set this.
Steve
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You get this message when your code hits a STOP statement. If you
want a different code you can say, for example: STOP 2000, and then
the message will be '...exited with code 2000'. You can, as an alternative,
use text: STOP 'your message goes here'.
want a different code you can say, for example: STOP 2000, and then
the message will be '...exited with code 2000'. You can, as an alternative,
use text: STOP 'your message goes here'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Actually, the STOP statement doesn't set the exit value.
Steve
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks. But if there is no exception handling, would the error code always be negative?
Vivek
Vivek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sorry, in the last message it should have been 'exit code' not error code.
Vivek
Vivek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To Steve L.: Maybe we are not talking about the same thing, but from the
form of the message he is getting it sounds like what happens in
windows when it hits a stop statement. From the on-line docs:
STOP
Statement: Terminates program execution before the end of the program unit.
Syntax
STOP [stop-code]
stop-code
(Optional) A message. It can be either of the following:
A scalar character constant of type default character.
A string of up to six digits; leading zeros are ignored. (Fortran 95/90 and FORTRAN 77 limit digits to five.)
Effect on Windows Systems
If you specify stop-code, the effect differs depending on its form, as follows:
If stop-code is specified as a character constant, the STOP statement writes the specified message to the standard error device and terminates program execution. The program returns a status of zero to the operating system.
If stop-code is specified as a string of digits, the STOP statement writes the following to the standard error device and terminates program execution:
Return code stop-code
In QuickWin programs, the following is displayed in a message box:
Program terminated with Exit Code stop-code
In both cases, the program returns a status of stop-code to the operating system as an integer.
form of the message he is getting it sounds like what happens in
windows when it hits a stop statement. From the on-line docs:
STOP
Statement: Terminates program execution before the end of the program unit.
Syntax
STOP [stop-code]
stop-code
(Optional) A message. It can be either of the following:
A scalar character constant of type default character.
A string of up to six digits; leading zeros are ignored. (Fortran 95/90 and FORTRAN 77 limit digits to five.)
Effect on Windows Systems
If you specify stop-code, the effect differs depending on its form, as follows:
If stop-code is specified as a character constant, the STOP statement writes the specified message to the standard error device and terminates program execution. The program returns a status of zero to the operating system.
If stop-code is specified as a string of digits, the STOP statement writes the following to the standard error device and terminates program execution:
Return code stop-code
In QuickWin programs, the following is displayed in a message box:
Program terminated with Exit Code stop-code
In both cases, the program returns a status of stop-code to the operating system as an integer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah, I had forgotten that STOP nnnnn would turn that into an exit status.
I have noticed that QuickWin programs tend to have their threads exit with a status of -1, and the main program zero. If the exit status is greater than zero, that's the time to wonder what else happened.
Steve
I have noticed that QuickWin programs tend to have their threads exit with a status of -1, and the main program zero. If the exit status is greater than zero, that's the time to wonder what else happened.
Steve

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page