how can I create a function that return out array ? pls help

Im doing research about electrical and now Im writing the code to output the electric current according to degree input.
my code have no function at all, so I would like to create a function the take some integer input and return out the Array data output, may be it difficult to understand I will post the code that I want to change into function.


[code]
{// Handle Channel 3
unsigned int channel = 2;
unsigned int space = device->GetDataQueueSpace(channel);

cli::array <short >^ data =gcnew array <short > (buffer);
double sinsin = 0;
double gaus =0;
anglecon = double::Parse(angleupdown->Text);

if (anglecon>30 && anglecon <=60)
-> for (int i = 0; i <buffer ; i++)
{
if(i<buffer-1){
gaus = (I3max-I3min) * cos(2 * (double)i * PI / (double)3000);
for(int j=0; j<166 ; j++){
sinsin = gaus * sin(2 * (double)j * PI / (double)166);
if(i==buffer-1){
break;
}else{
if(i%2==1){
sinsin = -sinsin * CR;
}else{
sinsin = sinsin * CR;
}
-> data[i] = (short)sinsin;
if(j!=165)
{i++;
}
}
}
}
}
unsigned int enqueued = device->EnqueueData(channel, data);
}
[code end]

i want to make a function that

function (int Imax, int Imin, int buffer) {
............
} return Data; // Data is an array

How can I write a function please help. Thank you so much.




Topic archived. No new replies allowed.