I don't know whose code the original console.inc was but I hacked it up a bit and added a Waitkey function.
James
Console.bi
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'Console routines
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
library "KERNEL32.DLL"
Declare Function AllocConsole Alias "AllocConsole" () As LONG
Declare Function FreeConsole Alias "FreeConsole"() As LONG
Declare Function GetCommandLine Alias "GetCommandLineA" () As DWORD
Declare Function GetStdHandle Alias "GetStdHandle" (Byval handle As DWORD) As DWORD
Declare Function WriteConsole Alias "WriteConsoleA" (Byval hConsoleOutput As DWORD, lpBuffer As ASCIIZ, Byval nNumberOfCharsToWrite As LONG, lpNumberOfCharsWritten As LONG, Byval lpReserved As LONG) As LONG
Declare Function ReadConsole Alias "ReadConsoleA" (Byval hConsoleInput As DWORD, Byval lpBuffer As DWORD, Byval nNumberOfCharsToRead As LONG, lpNumberOfCharsRead As LONG, pInputControl As ANY) AS LONG
Declare Function SetConsoleTitle Alias "SetConsoleTitleA" (lpConsoleTitle As ASCIIZ) As LONG
Declare Function SetConsoleMode Alias "SetConsoleMode"(Byval handle As DWORD,Byval dwMode As DWORD)As LONG
Declare Function GetConsoleMode Alias "GetConsoleMode"(Byval handle,lpMode As DWORD)
library ""
'==============================================================================
%STD_INPUT_HANDLE = -10
%STD_OUTPUT_HANDLE = -11
%STD_ERROR_HANDLE = -12
'==============================================================================
Function cprint(bufout As string)
Dim As long ConsOut
Dim As long buflen,bufrit
ConsOut = GetStdHandle (%STD_OUTPUT_HANDLE)
buflen=len bufout
WriteConsole ConsOut,bufout,buflen,bufrit,0
End Function
'==============================================================================
Function cinput(s As string) As string
Dim As long ConsIn
Dim As string bufin
Dim As long buflen,bufrit
bufin=nuls 100
cprint s
ConsIn = GetStdHandle(%STD_INPUT_HANDLE)
ReadConsole ConsIn,*bufin,100,bufrit,0
Function=left bufin,bufrit
End Function
'==============================================================================
Sub WaitKey()
Dim As long ConsIn,blen,mode
Dim As string b
b = nuls 10
ConsIn = GetStdHandle(%STD_INPUT_HANDLE)
GetConsoleMode(ConsIn,mode)
SetConsoleMode(ConsIn,0)
ReadConsole ConsIn,*b,4,blen,0
SetConsoleMode(ConsIn,mode)
End Sub
'==============================================================================
Function commandline() As string
Dim Byref z As zstring
&z=GetCommandLine
Function=z
End Function
'==============================================================================
Function stripquotes(s As string) As string
Dim As long a
a=asc(s,1)
if a=34 then
a=instr 2,s,chr(34)
s=mid s,2,a-2
end if
Function=s
End Function
'==============================================================================
Demo:
'#console
#include "Console.bi"
Function O2Main() As sys
Dim i As integer
Dim As string cr,s
cr = chr(13)+chr(10)
AllocConsole
SetConsoleTitle "Test Oxygen Console"
For i = 1 to 5
cprint("This is string "+str(i)+ cr)
Next i
cprint("press any key" + cr)
WaitKey
s = cinput("enter data -> ")
cprint("Data = " + s + cr)
cprint("press any key" + cr)
WaitKey
FreeConsole
Function = 1
End Function
O2Main()