Another possible solution is to let the DLL allocate the array, just return a pointer to it to Axapta and access the contents using the Binary class.
Kind regards
Thomas
-----Oprindelig meddelelse-----
Fra: [email protected] [mailto:[EMAIL PROTECTED] På vegne af tsk1958pete
Sendt: 6. november 2005 16:59
Til: [email protected]
Emne: Re: SV: [development-axapta] Passing Arrays to and from 3rd Party DLL
Byteway,
Thanks for sharing, your description of what happens is right on
point! My suspicion is Axpata "reserves" the memory space and when
the dll attempts(or actually does) to write to it is the point
Axapta crashes. Axapta does not appear to play well with others..
lol.. sorta "I'm gonna take my ball and go home"
To answer your question, the DLL is a material optimization program
that uses linear optimization to calculate how to pattern cut
material. The DLL is written in C++ by some very smart
mathmeticians specifically for our company. They are actively
working with us to modify the DLL in any fashion required to
integrate with Axapta.
The overview of the interface is:
1) Provide data to be optimized as input for the DLL
Input data consists of multiple "fields" of a sales
order line. In the code I provided you can see where
my test data populates the Binaries with multiple elements
2) DLL processes the input and calculates the optimized solution
3) DLL writes the solution to the memory space of the Binaries
passed in the call to DLL
4) Axapta code reads the elements of the binaries bringing the
solution back from the DLL...
A relatively simple process...
As stated the DLL developers can modify this process for the IO in
any way we request. We've considered IO exchange through text based
files, and could pass random file names(full pathed) for input and
output text file as string params. The text based solution seems
archaic, and potentially slow. This DLL process will be used
extensively, many.. many.. times as each sales order line is
entered. We use this to quote our material costs, to speed is an
important factor.
I'm very new to Axapta Development (normally work in Visual Fox or
VB). Any thoughts you might have on this solution are greatly
appreciated
Tim Peterson
--- In [email protected], Byteway <[EMAIL PROTECTED]>
wrote:
>
> Hi,
>
> Interresting topic, a couple of years ago I tried the same thing:
> accessing an array from a dll within Axapta. The result was that I
got
> the same behaviour as you describe - a hidden feature to close
Axapta
> even faster than my eyes can see ;-)
>
> Alternative:
> After some research I descovered that there is some kind of
standard to
> cope with these things. But it is only aplicable to com
interfaces.
> Google for ¨create COM next value methods".
> In pseudo code it goes like this:
> while (i get a next value from thirdpartydllmethod) { do something
with
> it }. Note that the method never passes an array, instead it
returns the
> next-value (until next value is null).
>
> Also what I discoverd in interfacing with third party dll's is
that the
> values given back in a fixed array, the offset to read the value
is the
> offset-count to the power of two. I don't know if I am clear
enough... I
> mean you can't just add the count of bytes to the previously read
value,
> to retrieve the next value. That way you would be reading
something
> which is not there, Axapta would go out of it's own boundries and
> windows will shut it down at ones.
>
> Can you give some more details on the peace of software you try to
> interface with? Perhaps there are better ways to this problem?
>
> Just some thoughts,
> /b
>
>
>
>
> tsk1958pete wrote:
>
> > Hi again All,
> > 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]
> > >
> >
> >
> >
> >
> >
> >
> >
> >
> > -----------------------------------------------------------------
-------
> > YAHOO! GROUPS LINKS
> >
> > * Visit your group "development-axapta
> > <http://groups.yahoo.com/group/development-axapta>" on the
web.
> >
> > * To unsubscribe from this group, send an email to:
> > [EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]
subject=Unsubscribe>
> >
> > * Your use of Yahoo! Groups is subject to the Yahoo! Terms
of
> > Service <http://docs.yahoo.com/info/terms/>.
> >
> >
> > -----------------------------------------------------------------
-------
> >
>
Yahoo! Groups Links
SPONSORED LINKS
| Computer part | Programming languages | Microsoft axapta |
| Support exchange |
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.

