1. Wierd error (PING ROB)
Some wierd thing, hSaveStdout is a constant, defined as you will see
below. But using this constant /*/broke/*/ working code...
Bizarrely, calling c_func(xGetStdHandle..) inline works, but saving
this as a constant does not !!!!!!!
I get the same results on 2.4 and 2.5(a)...
--
-- odd thing with STD_OUTPUT_HANDLE/constants
--
include dll.e
include machine.e
constant
kernel32 = open_dll("kernel32.dll")
constant
xGetStdHandle = define_c_func(kernel32, "GetStdHandle",
{C_LONG}, -- DWORD nStdHandle // input, output, or
error device
C_POINTER), -- HANDLE
xGetConsoleScreenBufferInfo = define_c_func(kernel32,
"GetConsoleScreenBufferInfo",
{C_POINTER, -- HANDLE hConsoleOutput, // handle of
console screen buffer
C_POINTER}, -- PCONSOLE_SCREEN_BUFFER_INFO
lpConsoleScreenBufferInfo // address of screen buffer info.
C_INT) -- BOOL
constant sizeofCSBI = 18 -- (trust me!)
constant pCSBI=allocate(sizeofCSBI)
constant STD_OUTPUT_HANDLE = #FFFFFFF5 -- (-11)
constant hSaveStdout = c_func(xGetStdHandle,{STD_OUTPUT_HANDLE})
puts(1,"Hello\n")
----!!!! FINE !!!! -----
if not
c_func(xGetConsoleScreenBufferInfo,{c_func(xGetStdHandle,{STD_OUTPUT_HANDLE}),pCSBI})
then
----!!!! BROKEN !!!! -----
-- if not c_func(xGetConsoleScreenBufferInfo,{hSaveStdout,pCSBI})
then
?9/0
end if
2. Re: Wierd error (PING ROB)
Pete Lomax wrote:
> Some wierd thing, hSaveStdout is a constant, defined as you will see
> below. But using this constant /*/broke/*/ working code...
>
> Bizarrely, calling c_func(xGetStdHandle..) inline works, but saving
> this as a constant does not !!!!!!!
>
> I get the same results on 2.4 and 2.5(a)...
>
> }}}
<eucode>
> --
> -- odd thing with STD_OUTPUT_HANDLE/constants
> --
> include dll.e
> include machine.e
>
> constant
> kernel32 = open_dll("kernel32.dll")
>
> constant
> xGetStdHandle = define_c_func(kernel32, "GetStdHandle",
> {C_LONG}, -- DWORD nStdHandle // input, output, or
> error device
> C_POINTER), -- HANDLE
>
> xGetConsoleScreenBufferInfo = define_c_func(kernel32,
> "GetConsoleScreenBufferInfo",
> {C_POINTER, -- HANDLE hConsoleOutput, // handle of
> console screen buffer
> C_POINTER}, -- PCONSOLE_SCREEN_BUFFER_INFO
> lpConsoleScreenBufferInfo // address of screen buffer info.
> C_INT) -- BOOL
>
> constant sizeofCSBI = 18 -- (trust me!)
> constant pCSBI=allocate(sizeofCSBI)
> constant STD_OUTPUT_HANDLE = #FFFFFFF5 -- (-11)
>
> constant hSaveStdout = c_func(xGetStdHandle,{STD_OUTPUT_HANDLE})
>
> puts(1,"Hello\n")
> ----!!!! FINE !!!! -----
> if not
>
> c_func(xGetConsoleScreenBufferInfo,{c_func(xGetStdHandle,{STD_OUTPUT_HANDLE}),pCSBI})
> then
> ----!!!! BROKEN !!!! -----
> -- if not c_func(xGetConsoleScreenBufferInfo,{hSaveStdout,pCSBI})
> then
> ?9/0
> end if
> </eucode>
{{{
I didn't try to run this code, but it wouldn't surprise me
if you get a different value returned by GetStdHandle
before the puts() versus after it. The reason is that
I don't create any console window until you do your first output
to the screen. Maybe you could move the puts() before the constant
declaration. The puts() will then be executed before the c_func()
that's assigned to the constant.
Regards,
Rob Craig
Rapid Deployment Software
http://www.RapidEuphoria.com
3. Re: Wierd error (PING ROB)
Robert Craig wrote:
>
> Pete Lomax wrote:
> > Some wierd thing, hSaveStdout is a constant, defined as you will see
> > below. But using this constant /*/broke/*/ working code...
> >
> > Bizarrely, calling c_func(xGetStdHandle..) inline works, but saving
> > this as a constant does not !!!!!!!
> >
> > I get the same results on 2.4 and 2.5(a)...
>
> I didn't try to run this code, but it wouldn't surprise me
> if you get a different value returned by GetStdHandle
> before the puts() versus after it. The reason is that
> I don't create any console window until you do your first output
> to the screen. Maybe you could move the puts() before the constant
> declaration. The puts() will then be executed before the c_func()
> that's assigned to the constant.
I can confirm (for Win2k, at least) that using the constant after you've
already created a console works fine. Interestingly, it even seems to
work after a call to free_console().
Matt Lewis
4. Re: Wierd error (PING ROB)
On Wed, 16 Feb 2005 17:27:06 -0800, Robert Craig
<guest at RapidEuphoria.com> wrote:
>I didn't try to run this code, but it wouldn't surprise me
>if you get a different value returned by GetStdHandle
>before the puts() versus after it.
Thanks, you were spot on.
Pete
5. Re: Wierd error (PING ROB)
- Posted by Brian Broker <bkb at cnw.com>
Feb 17, 2005
-
Last edited Feb 18, 2005
Pete Lomax wrote:
>
>
> Some wierd thing, hSaveStdout is a constant, defined as you will see
> below. But using this constant /*/broke/*/ working code...
>
> Bizarrely, calling c_func(xGetStdHandle..) inline works, but saving
> this as a constant does not !!!!!!!
>
> I get the same results on 2.4 and 2.5(a)...
>
> }}}
<eucode>
> --
> -- odd thing with STD_OUTPUT_HANDLE/constants
> --
> include dll.e
> include machine.e
>
> constant
> kernel32 = open_dll("kernel32.dll")
>
> constant
> xGetStdHandle = define_c_func(kernel32, "GetStdHandle",
> {C_LONG}, -- DWORD nStdHandle // input, output, or
> error device
> C_POINTER), -- HANDLE
>
> xGetConsoleScreenBufferInfo = define_c_func(kernel32,
> "GetConsoleScreenBufferInfo",
> {C_POINTER, -- HANDLE hConsoleOutput, // handle of
> console screen buffer
> C_POINTER}, -- PCONSOLE_SCREEN_BUFFER_INFO
> lpConsoleScreenBufferInfo // address of screen buffer info.
> C_INT) -- BOOL
>
> constant sizeofCSBI = 18 -- (trust me!)
> constant pCSBI=allocate(sizeofCSBI)
> constant STD_OUTPUT_HANDLE = #FFFFFFF5 -- (-11)
>
> constant hSaveStdout = c_func(xGetStdHandle,{STD_OUTPUT_HANDLE})
>
> puts(1,"Hello\n")
> ----!!!! FINE !!!! -----
> if not
>
> c_func(xGetConsoleScreenBufferInfo,{c_func(xGetStdHandle,{STD_OUTPUT_HANDLE}),pCSBI})
> then
> ----!!!! BROKEN !!!! -----
> -- if not c_func(xGetConsoleScreenBufferInfo,{hSaveStdout,pCSBI})
> then
> ?9/0
> end if
> </eucode>
{{{
I don't trust you...
sizeofCSBI should be 22
I've got GetConsoleScreenBufferInfo wrapped in my Console lib. The lib is
still not done but it's useable. If you'd like to take a look at it, let me
know...
-- Brian
6. Re: Wierd error (PING ROB)
On Thu, 17 Feb 2005 11:56:04 -0800, Brian Broker
<guest at RapidEuphoria.com> wrote:
>I don't trust you...
>sizeofCSBI should be 22
Yeah, third person to confirm that today, thanks!
)
>
>I've got GetConsoleScreenBufferInfo wrapped in my Console lib. The lib is
>still not done but it's useable. If you'd like to take a look at it, let me
>know...
Erm, I'm tied into arwen. But yep, I'll have a look at it.
Regards,
Pete