Console redirection crashes Hello World

Just starting out? Need help? Post your questions and find answers here.
iancrt
User
User
Posts: 12
Joined: Sun May 18, 2003 10:55 am
Location: UK, LEEDS

Console redirection crashes Hello World

Post by iancrt »

hi,
I just bought pb as it seems to have good console capability, but just hit a problem I hoping there is a solution to.....
Nice simple classic prog:

Code: Select all

OpenConsole()
  PrintN("Hello World")
CloseConsole()
compile as console app, all cpu and tried with/without NT compliance as Helloworld.exe
Run the program from the command line and we get the expected 'Hello World'. problem starts when I try to use console redirection. Run the command

Code: Select all

helloworld >c:\daft
and I expected to get the file c:\daft containing 'Hello World', instead XP Pro shuts down the executable. Has anyone else had this problem? have I missed something in my code? Is there a workaround?

Better mention, doing all this on AMD 1700+ & Windows XP Professional
WolfgangS
Enthusiast
Enthusiast
Posts: 174
Joined: Fri Apr 25, 2003 3:30 pm

Post by WolfgangS »

Hi !
Windows immediately closes the console ...

try:

Code: Select all

OpenConsole() 
  PrintN("Hello World") 
  delay(1000)
CloseConsole() 
MFG
WolfgangS
iancrt
User
User
Posts: 12
Joined: Sun May 18, 2003 10:55 am
Location: UK, LEEDS

Post by iancrt »

hi,

thanks for that, doesn't work though. I'm calling the app from an existing console so its not closing. tried setting the delay quite large (100000) still got the same problem. I put the delay before printn() and the program took longer to crash. tried adding inkey() before printn and it waits for a key before crashing, So I think its specifically PrintN() thats causing the crash. Any other ideas?

ian
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

I will investigate all the console stuff soon, as it seems to be a bit strange.
iancrt
User
User
Posts: 12
Joined: Sun May 18, 2003 10:55 am
Location: UK, LEEDS

Thanks

Post by iancrt »

Thanks, I will watch for any updates.
I'm porting a suite of BCX,QBasic and PowerBasic Dos/Console Apps, so far only the redirection being a major problem.
Post Reply