Sun, 15 May 2005 21:43:54 GMT
array data from/to excel to/from delphi dll
// the 1 line below is the excel registration // =REGISTER("test.dll","Delphitest1","2EO","test1","factor,matrix",1,"Delphi") procedure delphitest1(var a:double; var M1rows,M1cols:smallint; var M:TDoubleArray); stdcall; var row, rowstart, col:integer; begin for row:=0 to M1rows1 do begin rowstart:=row*M1cols; for col:=0 to M1cols1 do begin M[rowstart+col]:=a*M[rowstart+col]; end; end; end; What I'm having trouble doing is increasing the passed parameter by an additional excel range. The call from excel for the above routine is as follows : test1(100,A1:C5). Paste this formula into the excel spdsht as an array and you will get back the same matrix as you passed but numbers multiplied by 100. I'm having the hardest time trying to pass two excel ranges and then use those passed ranges in the delphi dll. When I inspect the values in delphi I get incorrect values so I'm doing something wrong. Maybe I'm scewing up the type text in the Excel defintion. For the above routine, it's '2EO' If I add arange after the double parameter for example, what should it be? I think I tried every possible combination ..? Also, if anyone know why the above parameters have to be passes by reference I'd sure love an explanation. I can see the 'return' parameter 'M' being this way but don't understand why the others need to be. I'm new to excel>dll and back so any/all explanations, code samples would be greatly appreciated. Again, the above procedure seems to work fine so I'd prefer staying w/ this syntax and just modify it. TIA, kw
