1

I can't seem to find any information or understanding why the compiler throws error " E2029 'OF' expected but '[' found " when I try to use static array instead of dynamic.

I'm calling functions form a DLL file, so I'm having this code:

function RetrieveDSOData(whatchannels: uchar; var DSOCH1, DSOCH2: array of double; 
var LADATA: array of ushort; Nth_Sample: uchar): longint; 
stdcall; external 'E_l80.dll';

This compiles ok, but I have AV errors in DLL files, and since I suspect that the issue is the dynamic array does not get size specified, I wanted to throw it a static array.

But, if I write the above function with

DSOCH1, DSOCH2: array [0..31] of double;

I get the compiler error mentioned above.

Additional info: I have instructions on how to use this DLL written for C, and since I barely know it, I might be missing something else around these arrays: This is the original function:

long RetrieveDSOData(unsigned char whatchannels, double *DSOCH1,
double *DSOCH2, unsigned short *LADATA, unsigned char Nth_Sample)

with explanations like this:

*DSOCHX: A pointer to an array of points from the DSO channels.
*LADATA: A pointer to an array of LA data

Any help would be appreciated. (and please do not edit this question just for deleting this last sentence... makes no sense...)

3
  • Have you tried defining your own type and using that instead? type TMyArray = array[0..31] of Double; Commented May 16, 2015 at 0:12
  • You need to create a type alias TMyArray = array[0..31] of double and then use TMyArray. Commented May 16, 2015 at 0:13
  • True. The hint given (as well as in the answer) does get me through compiler, however now the app hangs at calling the function... :( Do you happen to help me out on the second-part of the question...? Commented May 16, 2015 at 0:50

1 Answer 1

7

Define a type, and use that type instead.

type
  TDSOArray = array[0..31] of double;

 function RetrieveDSOData(whatchannels: uchar; 
  var DSOCH1, DSOCH2: TDSOArray;
  var LADATA: array of ushort; 
  Nth_Sample: uchar): longint; stdcall; external 'E_l80.dll';  

This will at least resolve the compiler errors. I'm a little confused by how you got from an array of points from the DSO channels to array[0..31] of double. I can't answer the rest of your question either, for the same reason - I don't know what LA Data is, so I don't know how you got to array of ushort for the LADATA parameter.

Sign up to request clarification or add additional context in comments.

16 Comments

On a side note, from what I've understood, the difference between "declare" and "define" is "define" is how you create a type, whereas "declare" is how you use that type as a variable. Is that correct?
@Jerry: Thanks. Corrected. (Define seems more correct from a vocabulary standpoint. It is defining a type, not declaring you have one.)
@JustMarc: I've edited my answer; I can't interpret the types you provided later in the question, because you didn't include the information needed to do so, and I've no knowledge regarding the DLL you're trying to use. I've added specifics in my answer.
@JustMarc; What you posted here (which you said was with explanations like this) isn't clear. Somewhere there has to be information about what "LADATA: A pointer to an array of LA data" means; I don't know what LA is, so I don't know what *an array of LA data might be.
Almost certainly the arrays should be translated as pointers. And the open array var LADATA: array of ushort; can't match unsigned short *LADATA which is a plain by value PWord.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.