Re: An old C function problem revisited
- Posted by Bernie Ryan <xotron at bluefrog.com> Feb 23, 2006
- 533 views
Jonas Temple wrote: > > 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: > > }}} <eucode> > --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 > > </eucode> {{{ > > 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 > <a href="http://www.yhti.net/~jktemple">http://www.yhti.net/~jktemple</a> Jonas: It may be because you are not using the correct function name. You may have to use 'A' at the end of function name if you are using ANSI. Take a look at this link it says something about not having and 'A' or 'W' the function will be OEM call. I don't know much about AS400, I hope this helps. http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/info/rzaik/rzaikcaexpressprogstd.htm#HDRCAEXPRESSPROGSTD Bernie My files in archive: WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API Can be downloaded here: http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan