Page 1 of 1

Posted: Tue Jun 25, 2002 12:48 am
by BackupUser
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

Posted: Tue Jun 25, 2002 2:00 am
by BackupUser
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.

Posted: Wed Oct 23, 2002 11:23 am
by BackupUser
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

Posted: Wed Oct 23, 2002 11:39 am
by BackupUser
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:

Code: Select all

If OpenConsole()
  PrintN("Line #1")
  PrintN("Line #2")
  MessageRequester("","Done!",0)
  CloseConsole()
EndIf
End
PB - Registered PureBasic Coder

Posted: Wed Oct 23, 2002 12:03 pm
by BackupUser
Restored from previous forum. Originally posted by Insomniac.

Yes to Console format and I can still produce the problem with your code with the messagerequester removed.

Insomniac - Registered PB user

Posted: Wed Oct 23, 2002 12:13 pm
by BackupUser
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

Posted: Wed Oct 23, 2002 12:23 pm
by BackupUser
Restored from previous forum. Originally posted by TheBeck.

PureBasic compiler 3.4 (registered)
Windows XP Pro

No error with windows compile after MANY runs.
Error every time after line 1 with console compile and message requester removed.

Looks like a bug to me.

Posted: Wed Oct 23, 2002 12:26 pm
by BackupUser
Restored from previous forum. Originally posted by TheBeck.
Does it crash if you remove
the CloseConsole() command?
For me it crashed after that line was removed.

Posted: Wed Oct 23, 2002 12:27 pm
by BackupUser
Restored from previous forum. Originally posted by Insomniac.

Yep. Same problem with CloseConsole removed.

Insomniac - Registered PB User

Posted: Wed Oct 23, 2002 12:30 pm
by BackupUser
Restored from previous forum. Originally posted by TheBeck.

I removed the print functions and it doesn't crash.