Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
AutoCAD ActiveX Parameter Passing Problem
Message
De
26/10/1998 18:51:46
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00150616
Message ID:
00150712
Vues:
25
>Don,
>
>You can't pass a VFP array to a OLE sever like that. Vlad posted a cool way to convert to double last week using a couple of lines of C code in a DLL. You could use that to build a string that represented the 3 doubles and pass that to AutoCad.

Strangely I can pass single double precision number (rather VFP Floating point numbers) and string arrays to AutoCad, just not arrays of numbers.

You mean this one I assume :

The fastest solution I know:

Put the following function into a C DLL:
extern "C" void __declspec( dllexport )
StringToDouble(LPCSTR tpszDouble, double* tpnDouble)
{
//-- lpnDouble points to the same memory as tpszDouble
double* lpnDouble = (double*)tpszDouble;
//-- Copy the value from lpnDouble to the return param
*tpnDouble = *lpnDouble;
return;
}

extern "C" void __declspec( dllexport )
DoubleToString(double tnDouble, LPSTR tpszDouble)
{
//-- lpszDouble points to the same memory as tnDouble
LPSTR lpszDouble = (LPSTR)&tnDouble;
//-- Copy the value from lpszDouble to the return param
memcpy(tpszDouble, lpszDouble, 8);
//-- Apend a null char to the return param
// (just to be sure it's ok)
tpszDouble[8] = '\0';
return;
}

The declaration in VFP will be:

DECLARE StringToDouble IN ;
MyDll.dll ;
STRING@, DOUBLE@

DECLARE DoubleToString IN ;
MyDll.dll ;
DOUBLE, STRING@

And use them:
*-- lcDouble must have 8 (the length of DOUBLE) + 1 bytes
lcDouble = REPLICATE(chr(0), 9)
lnDoubleIn = 123.45
lnDoubleOut = 0

= DoubleToString(lnDoubleIn, @lcDouble)
= StringToDouble(@lcDouble, @lnDoubleOut)
*-- Now, lnDoubleOut equals lnDoubleIn


Obviously, the purpose of DoubleToString is testing only.

Vlad

David - thank you for answering. I will try above

>
>>I am working with ActiveX for AutoCad version 14 in VFP 5.0. I have run the following code. All lines work until I reach the last.
>>I get an error message :
>>
>>"OLE error code ox80020005: type mismatch" ............
Best Regards
Don Simpson
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform