Posted: Wed Nov 26, 2003 12:50 pm
ok, i've ported a little example of WriteConsole from VB
and as WriteConsole has that kind of argument (const void *), i've tested in PureBasic, and works well, no problem...
Therefore I think the ByVal problem is not-existing
The reason why the code submitted by PB does't work is not imputable to how PB deals with API's, but is in the code...
Anyway i'll find other examples and try again
byez
Code: Select all
#FOREGROUND_BLUE = $1
#FOREGROUND_GREEN = $2
#FOREGROUND_RED = $4
#BACKGROUND_BLUE = $10
#BACKGROUND_GREEN = $20
#BACKGROUND_RED = $40
#BACKGROUND_INTENSITY = $80
#BACKGROUND_SEARCH = $20
#FOREGROUND_INTENSITY = $8
#FOREGROUND_SEARCH = ($10)
#ENABLE_LINE_INPUT = $2
#ENABLE_ECHO_INPUT = $4
#ENABLE_MOUSE_INPUT = $10
#ENABLE_PROCESSED_INPUT = $1
#ENABLE_WINDOW_INPUT = $8
#ENABLE_PROCESSED_OUTPUT = $1
#ENABLE_WRAP_AT_EOL_OUTPUT = $2
#STD_OUTPUT_HANDLE = -11
#STD_INPUT_HANDLE = -10
#STD_ERROR_HANDLE = -12
#INVALID_HANDLE_VALUE = -1
Global hConsoleOut.l, hConsoleIn.l
If AllocConsole_()
hConsoleOut = GetStdHandle_ (#STD_OUTPUT_HANDLE)
If hConsoleOut = #INVALID_HANDLE_VALUE
MessageRequester("?","Unable To get STDOUT",1)
EndIf
hConsoleIn = GetStdHandle_(#STD_INPUT_HANDLE)
If hConsoleIn = #INVALID_HANDLE_VALUE
MessageRequester("?","Unable To get STDIN",1)
EndIf
Else
MessageRequester("?","Couldn't allocate console",1)
EndIf
SetConsoleTitle_("Test const void *")
SetConsoleTextAttribute_ (hConsoleOut, #FOREGROUND_RED | #FOREGROUND_GREEN | #FOREGROUND_INTENSITY | #BACKGROUND_BLUE)
Procedure ConsoleWritel(sInput.s)
cWritten.l
WriteConsole_(hConsoleOut, sInput, Len(sInput), cWritten, #NULL)
EndProcedure
Procedure.s ConsoleRead()
ZeroPos.l
ConsoleReadLine.s = "0000000000"
ReadConsole_ (hConsoleIn, ConsoleReadLine, Len(ConsoleReadLine), #NULL, #NULL)
ZeroPos = FindString(ConsoleReadLine, Chr(0),1)
If ZeroPos > 0
ConsoleReadLine = Left(ConsoleReadLine, ZeroPos - 3)
ProcedureReturn ConsoleReadLine
EndIf
EndProcedure
ConsoleWritel("Please enter your name: ")
MessageRequester(ConsoleRead(),"Your Name:",1)
Therefore I think the ByVal problem is not-existing

The reason why the code submitted by PB does't work is not imputable to how PB deals with API's, but is in the code...
Anyway i'll find other examples and try again

byez