| lucky_carl@mindspring.com 2006-05-14, 3:55 am |
| OK, I've spent a few minutes with this and I don't have time to play,
so my shortness of time is your gain.
So, I will award $50 (yes $50 U.S.) to the first person who sends me a
fix
to the following description, not an explanation, but a real .app or
..prg.
Basically, everything works except the parameters, so fix them so I can
send info to Clarion, have Clarion change the information of the two
parameters,
and send back the response, 0 or 1.
You can change the Clarion anyway you need, but the C code needs to be
as
is, except for setting the first paramter to 1111.
Below is C code that will setup an address to the Clarion procedure and
call a it in Clarion. Clarion will then evaluate the first parameter
to see if it is 1111. If the value where the pointer points in Clarion
is 1111 it will:
1) change the value of the location to "Changed by CW", this is the
data where the pointer points, not the pointer itself.
2) Change the value of the location to "Also changed by Clarion", this
is
the data where the pointer points, not the pointer itself.
3) Set the return value to 1
If the value where the first pointer points going into clarion is not
1111,
1) clear the value of the first location (parameter 1) where the
pointer points.
2) clear the value of the first location (parameter 2) where the
pointer points.
3) Set the return value of 0
To win the $50.00, send me an .app or .prj that compiles and be able to
run with
no errors. To show me the values changed, add a printf() after the
procedure
call and display the changed values.
The C code is in Visual Studio 2005, but can be in any version of
standard C, but can not be compiled inside the clarion, and clarion can
not
be compiled inside the C code. The C code is an executable, and the
clarion
is a dll.
Payment can be sent to you via Paypal, cashiers check, or what ever you
want.
lucky_carl@mindspring.com, if you need to call me, send me an e-mail
and
I will reply directly to you with my phone number, or you can send me
your
phone number and I will call you.
In order to determine the winner, I will use the time and date stamp of
the e-mail
sent to lucky_carl@mindspring.com.
C Code
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!
#include <windows.h>
#include <stdio.h>
#include <string.h>
typedef struct
{
char cwpassed_value1[16];
char cwpassed_value2[30];
} ITEM_LOOKUP;
ITEM_LOOKUP *tst; // pointer method
int main( int argc, char *argv[] )
{
HMODULE hmod;
typedef short (* PExportedFn)(char *,char *);
PExportedFn pfnEF;
short ReturnValue ;
hmod = LoadLibrary("CWDLL.DLL");
if (hmod == NULL)
printf("Did not load CWDLL.DLL\r\n");
else
{
printf("load DLL OK\r\n");
pfnEF = (PExportedFn)GetProcAddress(hmod, "PROCTOCALL");
if (pfnEF == NULL)
{
printf("Did not load procedure\r\n");
}
else
{
printf("Get Proc OK\r\n");
//Use any way you want to set the actual 1111 into
cwpassed_value1
// so the Clarion procedure can read it and determine if it's
// really 1111 or not, it needs to evaluated as a string in
Clarion
//Set the value of tst->cwpassed_value1 here with 1111
ReturnValue = pfnEF(tst->cwpassed_value1, tst->cwpassed_value2);
if (ReturnValue >= 1)
{
printf("ReturnValue1 Desc<%s>\r\n", tst->cwpassed_value1);
printf("ReturnValue2 Desc<%s>\r\n", tst->cwpassed_value2);
}
else
{
printf("pfnEF error");
}
} //End of if (retVal == true)
} //End of if (hmod == NULL)
return 0;
} //End of main
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!
Here's the Clarion code:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!
Currently the prototype is:
PROCTOCALL(ULONG,ULONG),SHORT,C,NAME('PR
OCTOCALL')
But you can change the clarion any way you want, just don't change the
C
code except for setting the value of 1111 into the first parameter.
PROCTOCALL FUNCTION (InCString1,InCString2) ! Declare
Procedure
TestValue LONG
ReturnValue SHORT
CODE ! Begin processed
code
MESSAGE('Proc2Call in Clarion|Coming in, InCString1 is:' & InCString1
& ':' )
!Here, be sure and correctly set CWValue to properly test if have
1111
IF TestValue = 1111 THEN
!When we correctly receive 1111, set the string values InCString1,
and InCString2 with text
! which will be available to the C code and the C will be able to
display it correctly
!InCString1 = "Changed by CW"
!InCString2 = "Also changed by Clarion"
ReturnValue = 1
ELSE
ReturnValue = 0
END
MESSAGE('Proc2Call in Clarion|Leaving, InCString1 is:' & InCString1 &
':|InCString2 is:' & InCString2 & ':' )
Return(ReturnValue)
|