Why this simple code cannot 被successfully compiled? - page 2

 

it's a pity that I cannot see SRC button in the page....

I have not found the way to modify an element  of an array by a function call.

The two links in your last reply is what I like. 

 

tzm:

it's a pity that I cannot see SRC button in the page....

I have not found the way to modify an element  of an array by a function call.

The two links in your last reply is what I like. 

How to use the SRC button

 

This should work . . . 

double Array[100];
int ArrayIndex;


ArrayIndex = 23;

Function(Array, ArrayIndex);



// Function declaration
void Function(double& LocalArray[], int Index)
   {
   LocalArray[Index] = 1.4327;                 // set the element of the array
   }
 
You can do
double Function()
   {
   return(1.4327);
   }
////////////////
double Array[100]; 
Array[23]=Function();
or
void Function(double& LocalArray[], int Index)
   {
   LocalArray[Index] = 1.4327; // set the element of the array
   }
////////////////
double Array[100]; 
Function(Array, 23); // sets Array[23]
or
void Function(double& dbl)
   {
   dbl = 1.4327;
   }
////////////////
double Array[100]; 
double d; Function(d); Array[23]=d
But MQ4 does not allow
void Function(double& dbl)
   {
   dbl = 1.4327;
   }
////////////////
double Array[100]; 
Function(Array[23]); // < does not compile
 
WHRoeder:
You can do
or
or
But MQ4 does not allow
 

RaptorUK, WHRoeder and Wmlab:

  Yes, it workds! Many thanks to you all for your patience and timely reply.