An old C function problem revisited

new topic     » topic index » view thread      » older message » newer message

All,

I asked a question about this C function call a couple of years ago and got some
answers but never could resolve the problem.  Every time I call the following
routine:

--CWBAPI unsigned int WINAPI cwbUN_DisplayCommandPrompter(
--                              cwbCO_SysHandle systemHandle,
--                              UINT promptFlags,
--                              LPSTR commandString,
--                              UINT * dateFormat,
--                              BOOL * batchCommand);

global atom xcwbUN_DisplayCommandPrompter
xcwbUN_DisplayCommandPrompter = define_c_func(cwbunapi,
    "_cwbUN_DisplayCommandPrompter@20",
            {C_UINT, C_UINT, C_POINTER, C_POINTER, C_POINTER},C_UINT)
global function cwbUN_DisplayCommandPrompter(atom system_handle, atom prompt,
                        sequence command)
    atom xcommand, xprompt, xdate_format, date_format, xbatch, batch
    xcommand = allocate(32768)
    mem_set(xcommand, ' ', 32768)
    poke(xcommand, command)
    poke(xcommand + length(command), #00)
    xdate_format = allocate(4)
    xbatch = allocate(4)
    cwbUN_EURtnCode = c_func(xcwbUN_DisplayCommandPrompter,
                {system_handle, prompt, xcommand,
                xdate_format, xbatch})
    if cwbUN_EURtnCode = CWB_OK then
        command = peek_string(xcommand)
        date_format = peek4u(xdate_format)
        batch = peek4u(xbatch)
    else
        date_format = 0
        batch = 0
    end if
    free(xcommand)
    free(xdate_format)
    free(xbatch)

    return {cwbUN_EURtnCode, command, date_format, batch}

end function


I get the following error:

c:\eutools\include\cwbun.ew:3631 in function cwbUN_DisplayCommandPrompter()
A machine-level exception occurred during execution of this statement

I have played around with this one for a week or so and am ready to give up
again.  You might be asking why 32768 is allocated but this routine can return a
much longer string than what is provided so you have to allocate enough.

Thanks for any help!

Jonas Temple
http://www.yhti.net/~jktemple

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu