can a function return an array?

Started by spook1, Sun 25/04/2004 21:28:52

Previous topic - Next topic

spook1

Simple question: can a function return an array?
And can I collect data from the function like

value.x = MyFunction(inputparamter).xcoordinate;
value.y = MyFunction(inputparamter).ycoordinate;
value.speed = MyFunction(inputparamter).speed;

or can I even state:

value= MyFunction(inputparameter);

Cheers,
Martijn

Robert Eric

#1
You seem to want to use classes in that first one.
Ã, Ã, 

stuh505

QuoteSimple question: can a function return an array?

Yes, a function can return an array.  I don't know if AGS allows this or not...why don't you try it and tell us

And can I collect data from the function like

Quote
value.x = MyFunction(inputparamter).xcoordinate;
value.y = MyFunction(inputparamter).ycoordinate;
value.speed = MyFunction(inputparamter).speed;

As Eric pointed out, this is the notation you would use to call a function that is within a class.

int x_value = MyClass.GetXCoordFunction(int parameter);

Quotevalue= MyFunction(inputparameter);

This is the regular way of using a function.

spook1

 am not sure about the classes. I use the struct command to set up value.x, value.y etc.

cheers,

martijn

Pumaman

Functions cannot return structs or arrays - they can only return primitive types.

The workaround is to create a global variable which the function updates.

SMF spam blocked by CleanTalk