Get STDIN data

Windows specific forum
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by wavemaker.

Hello:

I wrote this program trying to get the STDIN string to write a CGI program -handling forms data, etc.- in PB Windows, but I can't even get SetConsoleMode_ working. Any help?

InitWindow(0)
temporal.s = " "
numero.l = 0
If OpenWindow(0, 100, 100, 195, 260, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "PureBasic Window")
resultado = GetStdHandle_(#STD_INPUT_HANDLE)
If SetConsoleMode_(resultado,#ENABLE_LINE_INPUT | #ENABLE_ECHO_INPUT | #ENABLE_PROCESSED_INPUT)
Repeat
EventID.l = WaitWindowEvent()
If ReadConsoleInput_(resultado,@temporal,1000,@numero)
MessageRequester("Stdin:",temporal,0)
EndIf
If EventID = #PB_EventCloseWindow
Quit = 1
EndIf
Until Quit = 1
EndIf
EndIf
End

Thanks

Juan Calderón Alonso
Registered user
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Mr.Skunk.

Don't have really time for the moment to experiment your code, but i saw two errors:
resultado must be Long => resultado.l (as the result is a handle DWORD)
There is a problem from GetStdHandle (the result is -1 instead of the handle address), so perhaps SetConsoleMode would work if you solve the GetStdHandle problem...

Hope it can help you...

Mr.Skunk

Edited by - mr.skunk on 11 July 2001 06:49:45
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Mr.Skunk.

On your code, you need AllocConsole_() just before calling GetStdHandle to make it work.

Your temporal.s is not the good way to retreive info from console with your ReadConsoleInput_(). See here :
http://msdn.microsoft.com/library/defau ... r_8p6a.asp

You have to create an input record buffer which is much more than a simple string (key event, mouse event...)
It should works with this input record buffer

Hope it helps...

Mr Skunk

Edited by - mr.skunk on 11 July 2001 17:52:54
Post Reply