Console App Problem(?) with Win XP
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by ebs.
I am having a problem with a Console application compiled with PB 3.2. Here's some simple test code:
OpenConsole()
PrintN("Line #1")
PrintN("Line #2")
MessageRequester("","Done!",0)
CloseConsole()
End
(The MessageRequester statement is only there to keep the console window open so I can check the output.)
If I run the executable program from Win XP Explorer by double-clicking, everything works fine - I see a console window open and the two lines of text are displayed.
However, if I run the same program from the Win XP command prompt, only the first line of text is displayed, then a fatal error occurs. Since Win XP has such totally useless error messages ("ctest.exe has encountered a problem and needs to close. We are sorry for the inconvenience. If you were in the middle of something, the information you were working on might be lost."), I can't tell you much about what type of error occurred. It does say under "Exception Information" that the code is 0xc0000095, if that helps any.
I assume that a console program is meant to be run from the command prompt, and all console I/O should go to that console window. Is this correct?
Thanks for your help,
Eric
I am having a problem with a Console application compiled with PB 3.2. Here's some simple test code:
OpenConsole()
PrintN("Line #1")
PrintN("Line #2")
MessageRequester("","Done!",0)
CloseConsole()
End
(The MessageRequester statement is only there to keep the console window open so I can check the output.)
If I run the executable program from Win XP Explorer by double-clicking, everything works fine - I see a console window open and the two lines of text are displayed.
However, if I run the same program from the Win XP command prompt, only the first line of text is displayed, then a fatal error occurs. Since Win XP has such totally useless error messages ("ctest.exe has encountered a problem and needs to close. We are sorry for the inconvenience. If you were in the middle of something, the information you were working on might be lost."), I can't tell you much about what type of error occurred. It does say under "Exception Information" that the code is 0xc0000095, if that helps any.
I assume that a console program is meant to be run from the command prompt, and all console I/O should go to that console window. Is this correct?
Thanks for your help,
Eric
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Franco.
Hi Eric,
I tested your code and it works everytime fine.
For the command line I run cmd.exe and a Dos-Box opens. When I type in the name of the test app and press enter, a second Dos-Box opens with the 2 lines and the MessageBox appears.
When I close the MessageBox the second Dos-Box closes to.
Nothing bad happens all the way.
Tested on WinXP Home.
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.
Hi Eric,
I tested your code and it works everytime fine.
For the command line I run cmd.exe and a Dos-Box opens. When I type in the name of the test app and press enter, a second Dos-Box opens with the 2 lines and the MessageBox appears.
When I close the MessageBox the second Dos-Box closes to.
Nothing bad happens all the way.
Tested on WinXP Home.
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Insomniac.
I can confirm this one with PB 3.3 on Windows XP Pro using your test code BUT only if you run the program over and over until it dies... I manage to run it about 60 times ( pressing up arrow then enter in the command window) before I get the exception. Then the error occurs every time the program is run util you close the command window and open a new one.
Must be some resource getting depleted?
I had the same problem with a console program I wrote.... but I didn't find it until I used
my program in a dos 'for' loop to process every file in a folder e.g. (DOS command follows:)
for %i IN (*.*) DO myprog.exe %i
The program would throw an exception before the end of the directory and I'd put it the the too hard basket for a while.
I'll post this over in the bug forum and see if Fred bites...
Insomniac - Registered PB user
I can confirm this one with PB 3.3 on Windows XP Pro using your test code BUT only if you run the program over and over until it dies... I manage to run it about 60 times ( pressing up arrow then enter in the command window) before I get the exception. Then the error occurs every time the program is run util you close the command window and open a new one.
Must be some resource getting depleted?
I had the same problem with a console program I wrote.... but I didn't find it until I used
my program in a dos 'for' loop to process every file in a folder e.g. (DOS command follows:)
for %i IN (*.*) DO myprog.exe %i
The program would throw an exception before the end of the directory and I'd put it the the too hard basket for a while.
I'll post this over in the bug forum and see if Fred bites...
Insomniac - Registered PB user
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
Firstly, have you selected "Console" as the executable format in the
Compiler Options?
Secondly, you should be checking that the console was successfully
opened before printing to it -- although if you're seeing the first
line then this may not be the problem. Try changing your code to:
PB - Registered PureBasic Coder
Firstly, have you selected "Console" as the executable format in the
Compiler Options?
Secondly, you should be checking that the console was successfully
opened before printing to it -- although if you're seeing the first
line then this may not be the problem. Try changing your code to:
Code: Select all
If OpenConsole()
PrintN("Line #1")
PrintN("Line #2")
MessageRequester("","Done!",0)
CloseConsole()
EndIf
End
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
I was just thinking... you say it crashes when run from a command
prompt -- perhaps this is because you're trying to close a console
that was already open (the prompt)? Does it crash if you remove
the CloseConsole() command?
PB - Registered PureBasic Coder
I was just thinking... you say it crashes when run from a command
prompt -- perhaps this is because you're trying to close a console
that was already open (the prompt)? Does it crash if you remove
the CloseConsole() command?
PB - Registered PureBasic Coder
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm