Welcome! Log In Create A New Profile

Advanced

DLL Passing dynamic arrays

Posted by walrus 
walrus
DLL Passing dynamic arrays
May 27, 2008 06:31AM
I am trying to pass a dynamic array to a dll.

Here is the code snippet:

WaveBuff, TofMemory is dynamic array
WaveMemory is dynamic array

Temp_wavepages = svar:WavePages * 16384
Temp_peak = svartongue sticking out smileyeakPages * 16384
temp_tof = svar:TofPages * 16384
WaveMemory = new dynamic array of Temp_wavepages 1 byte int
WaveBuff = new dynamic array of Temp_wavepages 1 byte int
PeakMemory = new dynamic array of Temp_peak 1 byte int

addr = &WaveMemory
res = Dimension(WaveMemory)
ResRead = fRead(FileID,res,addr)

TofMemory = new dynamic array of Temp_peak 1 byte int
addr = &TofMemory
res = Dimension(TofMemory)
ResRead = fRead(FileID,res,addr)

CallDLL32("atco_fpm.dll", "fp_maxmin_expand", WaveMemory[(RecordNum*ut:RedPts)+1],TofMemory[(RecordNum*ut:TofPts)+1],WaveBuff[1],ut:RedScale,ut:RedPts/2)

This dll is a working dll so no problem there. It works with C and Power Basic.
Can anyone see any glaring problems?
Any help would be great.

walrus
KenKnight
Re: DLL Passing dynamic arrays
May 27, 2008 07:28PM
Hi Walrus,

Are you sure you aren't supposed to be passing those WaveMemory items as pointers with the & ampersand?. For that matter it looks like you're passing an element of the array and not the entire array. Put that element in a variable prior to the call and then pass the pointer to the variable through the function and see if that works.

Cheers!
Ken
BLS
Re: DLL Passing dynamic arrays
May 28, 2008 01:52PM
// First messages are on new.pcsoft.us.windev.
Just had a second look at your code. As already said in my first
message (original pcsoft forum) / You can't pass a dynamic array to a dll function.
However: The question is what are you really passing ? Answer : 1 Byte.
Means : you can create a fixed array like :

fixedWaveMem is array fixed of 1 1 byte int //

and now all you have to do is to copy the contents of :
WaveMemory[(RecordNum*ut:RedPts)+1] into fixedWaveMem !
Use fixedWaveMem as DLL parameter.

BUT I doubt that it is nessesary to pass an fixed array .
IMO :

fWaveMem is 1 byte int = WaveMemory[(RecordNum*ut:RedPts)+1]

should to the job.

I've googled for atco_fpm.dll. No results... so further help is
impossible, without C API
hth Bjoertn
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: