1. Newbie - help with pointers
Dear members
I just started subscribing and was wondering if anyone could help me with a
beginner's question.
I just started working with euphoria and I'm using it to interact with an
Advantech lab card. I'm using this lab card to read in digital input. I'm
using the dll's to link the card's functions so that I can access them in
Euphoria. In the function DRV_DeviceOpen, a pointer for one of the input
parameters(DRIVERHANDLE) is required.
DRIVERHANDLE is a pointer to the configuration data for the lab card.
In the next function, DRV_DioReadBit, the input parameters ask for
DRIVERHANDLE again, which was assigned in DRV_DeviceOpen.
I have no idea if I am declaring the functions correctly. I think my main
problem is with pointers. How do I substitute C language pointers into
Euphoria if Euphoria doesn't use pointers?
I've been getting errors when I put the DRIVERHANDLE pointer variable into
DRV_DioReadBit.
I'm not sure if I explained my problem clearly enough. If there is any more
info that you need, I'll try to supply it. Some of the program's code is
shown below.
HELP!
--opening DLL and linking driver functions to Euphoria
global atom ad32
atom OpenBoard, Digin --Function IDs
--link to the DLL
ad32 = linkDLL("ADAPI32.dll")
OpenBoard = define_c_func(ad32, "DRV_DeviceOpen", --First function
being linked
--!!!!!!!!!here is where the functions requires a pointer!!!!!!!!!
{C_INT, C_POINTER}, C_INT)
if OpenBoard = -1 then
puts(1, "OpenBoard cannot be found!\n")
end if
Digin = define_c_func(ad32, "DRV_DioReadBit", --Third function
being linked
!!!!!!!!here is where the function requires the pointer that was used in
DRV_OpenDevice!!!!!!!!!!!!
{C_POINTER, C_INT}, C_INT)
if Digin = -1 then
puts(1, "Digin cannot be found!\n")
end if
-------------------------------------------------------------------------
atom error_result, status
atom DriverHandle
DriverHandle = allocate(8)
printf(1, "This is the address of the block of memory allocated to
DriverHandle %d\n",
{DriverHandle})
--Using the OpenBoard function
error_result= c_func(OpenBoard, {000, DriverHandle})
printf(1, "The value of error_result is %d\n", {error_result})
poke(DriverHandle, atom_to_float64(64)) -- fill the buffer
puts(1, "hello\n")
--Using the Digin function
status = c_func(Digin, {DriverHandle, 8})
printf(1, "The value of status is %d\n", {status})
_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com
2. Re: Newbie - help with pointers
Kenley Lim:
Because you are using a special DLL, you need to give the people on
the list the exact discription of each function so we can help you.
What I mean is how does your user's manual describe the detail of calling
the function from "C" and we will help you to translate them to Euphoria.
If you were using standard windows functions then everyone would not need
this extra information. You only have to describe one function then we can
show you how to use it in Euphoria, for example read bits.
Bernie