Using Tom's suggestions I was able to get the data passed with
apparent success to the DLL (see code below). The problem is that
as I step into the dll call line, the Axapta Application totally
crashes and it's icon disappears from the tool bar leaving me looking
at the editor screen waiting for it to come out of the call!
Axapta just disappears... poof gone.. no error warnings.. no "Send
Error to Microsoft... no nothin!!
I suspect this is occurring at the point in the DLL logic where it
attempts to write the solution to the binary space passed to it.
Anybody have any experience with this?
Thanks to All
Tim Peterson
CODE IS AS FOLLOWS:
client static int runDLL()
{
Dll ringoDLL;
DllFunction LSsolveRingo2;
int iRingoReturn;
int nIntParams,nDblParams;
Binary dParams,nParams,RMLength,RMCostCwt,RMAvail,FGCredit,Diam;
Binary
EndDrop,Bundle,FGNeeded,FGMax,Iyldpt,Iyield,Indxrm,NumCopies;
Binary Infgup,Ifg,Ifup;
Binary Objval,Objbnd,numpats;
// Declare Vars used to query output
real oObjVal,oObjbnd;
int oNumPats;
;
// Binary array equivalents CALC BASED ON TEST DAT
nParams = new Binary(20); // 5 ints * 4 bytes = 20
dParams = new Binary(32); // 4 dbl * 8 bytes = 32
RMLength = new Binary(16); // 2 dbl * 8 bytes = 16
RMCostCwt = new Binary(16); // 2 dbl * 8 bytes = 16
RMAvail = new Binary(16); // 2 dbl * 8 bytes = 16
FGCredit = new Binary(32); // 4 dbl * 8 bytes = 32
Diam = new Binary(32); // 4 dbl * 8 bytes = 32
EndDrop = new Binary(32); // 4 dbl * 8 bytes = 32
Bundle = new Binary(8); // 2 ints * 4 bytes = 8
FGNeeded = new Binary(16); // 4 ints * 4 bytes = 16
FGMax = new Binary(16); // 4 ints * 4 bytes = 16
Iyldpt = new Binary(16); // 4 ints * 4 bytes = 16
Iyield = new Binary(20); // 5 ints * 4 bytes = 20
Indxrm = new Binary(400); // 100 ints * 4 bytes = 400
NumCopies = new Binary(400); // 100 ints * 4 bytes = 400
Infgup = new Binary(400); // 100 ints * 4 bytes = 400
Ifg = new Binary(400); // 100 ints * 4 bytes = 400
Ifup = new Binary(400); // 100 ints * 4 bytes = 400
// Binary objects for return solution
Objval = new Binary(8);
Objbnd = new Binary(8);
numpats = new Binary(4);
// Define function parameters
ringoDLL = new DLL('c:\\RingoDLL\\ringo3');
LSsolveRingo2 = new DLLFunction(ringoDLL,'LSsolveRingo2');
LSsolveRingo2.returns(ExtTypes::DWord);
LSsolveRingo2.arg(ExtTypes::Pointer, // nParams int
ExtTypes::DWord, // nIntParams int
ExtTypes::Pointer, // dParams dbl
ExtTypes::DWord, // nDblParams int
ExtTypes::Pointer, // RMLength dbl
ExtTypes::Pointer, // RMCostcwt dbl
ExtTypes::Pointer, // Bundle int
ExtTypes::Pointer, // RMAvail dbl
ExtTypes::Pointer, // FGNeeded int
ExtTypes::Pointer, // FGMax int
ExtTypes::Pointer, // FGCredit dbl
ExtTypes::Pointer, // Diam dbl
ExtTypes::Pointer, // EndDrop dbl
ExtTypes::Pointer, // Iyldpt int
ExtTypes::Pointer, // Iyield int
ExtTypes::Pointer, // Objval Ptr
ExtTypes::Pointer, // Objbnd Ptr
ExtTypes::Pointer, // Numpats Ptr
ExtTypes::Pointer, // Indxrm int
ExtTypes::Pointer, // Numcopies int
ExtTypes::Pointer, // Infgup int
ExtTypes::Pointer, // Ifg int
ExtTypes::Pointer); // Ifup int
// Fill test data
// The dWord(1,2) parameters ar 1 = Start byte offset 2 = Value
placed in byte
nintParams = 5;
nParams.dWord( 0, 4); // Numfps
nParams.dWord( 4, 2); // Numrm
nParams.dWord( 8,100); // Numpatsmx
nParams.dWord(12,100); // Numelsmx
nParams.dWord(16, 60); // Limsecs
nDblParams = 4;
dParams.Double( 0,0.3400); // NeutralAxis
dParams.Double(8,3.1900); // WtPerFt
dParams.Double(16,0.0000); // Cpcut
dParams.Double(24,3.14159); // PI
RMLength.Double( 0,20.00); // Double
RMLength.Double( 8,40.00);
RMCostcwt.Double( 0,30.43); // Double
RMCostcwt.Double( 8,30.43);
Bundle.dWord( 0,1); // Integer
Bundle.dWord( 4,1);
Rmavail.Double( 0,9999.99); // Double
Rmavail.Double( 8,9999.99);
FGNeeded.dWord( 0, 4); // Integer
FGNeeded.dWord( 4, 2);
FGNeeded.dWord( 8,100);
FGNeeded.dWord(12,100);
FGMax.dWord( 0, 20); // Integer
FGMax.dWord( 4, 18);
FGMax.dWord( 8, 6);
FGMax.dWord(12, 3);
FGCredit.Double( 0,000.00); // Double
FGCredit.Double( 8,000.00);
FGCredit.Double(16,000.00);
FGCredit.Double(24,000.00);
Diam.Double( 0, 12.7500); // Double
Diam.Double( 8, 48.0000);
Diam.Double(16, 61.0625);
Diam.Double(24,132.0000);
EndDrop.Double( 0,14.000); // Double
EndDrop.Double( 8,16.000);
EndDrop.Double(16,16.000);
EndDrop.Double(24,30.000);
Iyldpt.dWord( 0, 2); // Integer
Iyldpt.dWord( 4, 3);
Iyldpt.dWord( 8, 4);
Iyldpt.dWord(12, 5);
Iyield.dWord( 0, 2); // Integer
Iyield.dWord( 4, 1);
Iyield.dWord( 8, 1);
Iyield.dWord(12, 1);
Iyield.dWord(16, 1);
// Initialize ObjVal, ObjBnd and Numpats to 0
Objval.Double(0,0.000);
Objval.Double(0,0.000);
Numpats.dWord( 0, 0);
iRingoReturn = 9999;
iRingoReturn = LSsolveRingo2.call
(nParams,nIntParams,dParams,nDblParams,RMLength,
RMCostCwt,Bundle,RMAvail,FGNeeded,FGMax,
FGCredit,Diam,EndDrop,Iyldpt,Iyield,
Objval,Objbnd,numpats,Indxrm,NumCopies,Infgup,
Ifg,Ifup);
return iRingoReturn;
}
--- In [email protected], "Thomas Jensen"
<[EMAIL PROTECTED]> wrote:
>
> Hi Tim
>
> Try using the Binary object in stead of the Array class:
>
> Binary binary = new Binary(8);
> Binary binary_out = new Binary(8);
>
> binary.dword(0,10);
> binary.dword(4,20);
>
> iReturn = _myFunction.call(iParam1,binary,binary_out)
>
> Regards
> Thomas
>
>
> ________________________________
>
> Fra: [email protected] på vegne af tsk1958pete
> Sendt: on 02-11-2005 23:00
> Til: [email protected]
> Emne: [development-axapta] Passing Arrays to and from 3rd Party DLL
>
>
>
> Hi All,
>
> Trying to call a standard DLL (not com standard). The parameters
> passed in are an integer var and an array (input data) lastly an
> empty array of 100 elements is passed that will be filled with
> solution data by the DLL. My problem is that the DLL is getting the
> int parameter 1 correctly, but not either of the arrays. I didn't
> think I needed to designate pass by reference.
>
> Anybody have a solution
>
> I'm calling it as follows:
>
> client static int runDLL()
> {
> Dll _myDLL;
> DllFunction _myFunction;
> int iParam1,iReturn;
> Array iInParams,iOutSolution;
>
> iInParams = new Array(Types::Integer);
> iOutSolution = new Array(Types::Integer);
>
> _myDLL = new DLL('c:\\mydll');
> _myFunction = new DLLFunction(_myDLL,'myFunction ');
>
> _myFunction.arg(ExtTypes::DWord, // iParam1 int
> ExtTypes::Pointer, // nInParams int
> ExtTypes::Pointer) // iOutSolution dbl
>
>
> iParam1 = 6
> iInParams.value(1,10);
> iInParams.value(2,20);
>
> iOutSolution.value(1,0);
> iOutSolution.value(2,0);
>
> iReturn = 9999;
> iReturn = _myFunction.call(iParam1,iInParams,iOutSolution)
> }
>
> Thanks for any help
> Tim Peterson
>
>
>
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
SPONSORED LINKS
| Computer part | Microsoft axapta |
YAHOO! GROUPS LINKS
- Visit your group "development-axapta" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

