From: Jonathan Goldberg on 16 Dec 2009 10:26 I forgot to include this: The sascbtl file needs to be changed to delete the return value specification.
From: Francogrex on 23 Dec 2009 17:26 On Dec 16, 8:56 am, s.las...(a)POST.TELE.DK (Søren Lassen) wrote: > Franco, > > I do not think your approach is quite the right one. > Even if you succeed, you would probably have a memory leak, > as you allocate the return values with malloc, but the > memory is (as far as I can see) not released again anywhere. > > If you want to take data from an array and return the > data in another array, you should probably let SAS allocate > both arrays. Something like this: > > data x; > array vals(4) (12 2 13 4); > array returns (4) 8; > call module('*e','test',vals(1),returns(1),4); > run; > > That way, SAS will take care of allocating and deallocating the > memory. > > Your C routine would then look something like > > EXPORT void test (double *inarray, > double *outarray, > int n) > { > int i; > for (i=0; i<n;i++) > { > outarray[i]=inarray[i]*2; > } > return; > > } OK, you approached works in other systems that call the dll but still a problem in sas: filename sascbtbl catalog 'work.api.test'; data _null_; file sascbtbl; input; put _infile_; cards4; routine test minarg=3 maxarg=3 module=sasN; arg 1 update byaddr format=RB8. ; arg 2 update byaddr format=RB8. ; arg 3 input byvalue format=PIB4. ; ;;;; run; data _null_; array vals(4) (2.75 2.3 13.1 4.2); array returns(4) (0 0 0 0); call module('*e','test',vals(1),returns(1), 4); put returns(1)=; put returns(2)=; put returns(3)=; put returns(4)=; run; returns1=5.5 returns2=0 returns3=0 returns4=0 NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds
From: Richard A. DeVenezia on 23 Dec 2009 19:38 On Dec 13, 1:21 pm, Francogrex <fra...(a)grex.org> wrote: > On Dec 13, 10:17 am, Francogrex <fra...(a)grex.org> wrote: > > > On Dec 13, 12:36 am, Savian <savian....(a)gmail.com> wrote: > > > > Do you have control of the dll or is it 3rd party? > > > I make it myself from the C file I showed above. > > ok since I got no solutions then I guess it's either not possible or > I'll need to ask the sas developers at the sas institute because the > programmers don't seem to know about it. An example with both C and SAS sources can be found at http://www.devenezia.com/downloads/sas/sascbtbl In the GetProcessChildWindows sample, the key bit of source is: rccw = modulen ('GetProcessChildWindows', addr(handle[1,1]), dim1 (handle)); with corresponding a SASCBTBL entry: ~~~ routine GetProcessChildWindows module = rad4sas minarg = 2 maxarg = 2 returns = long ; arg 1 input num byvalue format=pib4. ; arg 2 input num byvalue format=pib4. ; ~~~ byvalue is used for the array because the address of the array is passed after computing it via the ADDR function In the rad4sas.c source, the corresponding bit of source is: DWORD GetProcessChildWindows ( unsigned long *handleArray, unsigned long nHandles ) -- Richard A. DeVenezia
First
|
Prev
|
Pages: 1 2 3 4 Prev: Programmer Productivity using EE, Next: need help with the GLIMMIX for Goodness-of -fit |