Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Pass an array of reals to a 3d party dll
Message
De
31/01/2006 06:23:11
 
 
À
29/01/2006 15:14:10
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
01091099
Message ID:
01091815
Vues:
14
Hi Christian.

Thank you. It worked.

Thank you both for your precious help.

Dimitrios


>Hi,
>
>this should get you started:
>
>
>
>#INCLUDE vfp2c.h
>SET LIBRARY TO vfp2c32.fll ADDITIVE
>INITVFP2C32(VFP2C_INIT_MARSHAL)
>SET PROCEDURE TO vfp2c.prg ADDITIVE
>
>&& lprec __EXPORT_TYPE * __WINAPI make_lp(int rows, int columns)
>DECLARE INTEGER make_lp IN lpsolve55.dll INTEGER rows, INTEGER columns
>&& MYBOOL __EXPORT_TYPE __WINAPI set_col_name(lprec *lp, int colnr, char *new_name)
>DECLARE SHORT set_col_name IN lpsolve55.dll INTEGER lp, INTEGER colnr, STRING new_name
>&& MYBOOL __EXPORT_TYPE __WINAPI set_add_rowmode(lprec *lp, MYBOOL turnon)
>DECLARE SHORT set_add_rowmode IN lpsolve55.dll INTEGER lp, SHORT turnon
>&& MYBOOL __EXPORT_TYPE __WINAPI add_constraintex(lprec *lp, int count, REAL *row, int *colno, int constr_type, REAL rh)
>DECLARE SHORT add_constraintex IN lpsolve55.dll INTEGER lp, INTEGER count, INTEGER row, INTEGER colno, INTEGER constr_type, DOUBLE rh
>&& MYBOOL __EXPORT_TYPE __WINAPI set_obj_fnex(lprec *lp, int count, REAL *row, int *colno)
>DECLARE SHORT set_obj_fnex IN lpsolve55.dll INTEGER lp, INTEGER count, INTEGER row, INTEGER colno
>
>&& there is a potential problem with the MYBOOL type!
>&& MYBOOL is defined as: typedef MYBOOL unsigned char
>&& unsigned char is 8 bits wide, in FoxPro there is no equivalent datatype for use in the DECLARE command
>&& declaring it as SHORT (16 bits wide) works but the upper 8 bits that are returned are undefined.
>&& To be on the safe side BITAND(returnValue,0xFF) should be used to mask out the upper 8 bits
>
>&& example converted to FoxPro code (error handling ommitted)
>
>#DEFINE ROWTYPE_LE	1
>
>LOCAL lnColCount, loCols, loRows, lpRec
>
>lnColCount = 2
>loCols = CREATEOBJECT('CIntArray',lnColCount)
>loRows = CREATEOBJECT('CDoubleArray',lnColCount)
>
>lpRec = make_lp(0,lnColCount)
>set_col_name(lpRec,1,"x")
>set_col_name(lpRec,2,"y")
>set_add_rowmode(lpRec,1)
>
>&& C arrays are always 0 based, but the wrapper objects abstracts
>&& this fact and makes them 1 based
>loCols.Element(1) = 1
>loRows.Element(1) = 120
>loCols.Element(2) = 1
>loRows.Element(2) = 210
>
>add_constraintex(lpRec, lnColCount, loRows.Address, loCols.Address, ROWTYPE_LE, 15000)
>
>loCols.Element(1) = 1
>loRows.Element(1) = 110
>loCols.Element(2) = 2
>loRows.Element(2) = 30
>
>add_constraintex(lpRec, lnColCount, loRows.Address, loCols.Address, ROWTYPE_LE, 4000)
>
>&& and so on ...
>
>
>Regards
>Christian
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform