Re: Wierd error (PING ROB)
- Posted by Robert Craig <rds at RapidEuphoria.com> Feb 17, 2005
- 503 views
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