Re: What is the equivalent EU expression
- Posted by Brian Jackson <bjackson at 2FARGON.COM> Mar 15, 2000
- 438 views
On Wed, 15 Mar 2000 21:51:30 -0500, Prasanta Chakraborty <prasanta at WRITEME.COM> wrote: >Hi, > >I am trying to call a C func from EU, the C Func is described as: >SQLAllocHandle(SQLSMALLINT HandleType, SQLINTEGER InputHandle, SQLINTEGER >FAR *OutputHandle); >where SQLINTEGER is of type long. > >What will be the equivalent EU code. > >Regards, >Prasanta. Prasanta, What you ask is actually a 2-part process. First you must define the c function (and the DLL it lives in) in the context of your program using open_dll() and define_c_func(). Here's an example: global constant wsock32 = open_dll("wsock32.dll") global constant func_WSAStartup = define_c_func(wsock32,"WSAStartup", {C_SHORT,C_POINTER},C_INT) This "links" the DLL to your program, and declares func_WSAStartup as an external C function that takes C types SHORT(euphoria integer) and POINTER (euphoria atom) as arguments, and returns a type INT(euphoria atom). Now to use the function, you would need to do this: integer arg1 atom arg2 atom returnValue -- you need to assign the appropriate values to arg1 and arg2 here returnValue = c_func(func_WSAStartup, {arg1, arg2}) Also, Fabio Ramirez has written a very nice MySQL interface for Euphoria which may either be exactly what you need, or at least give you some good examples of how to wrap SQL API functions using Euphoria. Hope this helps! Brian