PDA

View Full Version : possible for function to return array?


dunkel3d
07-28-2003, 08:22 PM
Hello, I'm having a trouble getting my function to return an array.

float $oldArray[] = {0,1,2,3,4,5};

proc float returnNewArray (float $myArray[])
{
for ($f = 0; $f <= size($myArray); $f++){
float $newArray[];
$newArray[$f] = $myArray[$f];
if ((size($newArray)) - (size($myArray)) == 0){
return $newArray;
}
}
float $testArray[] = returnNewArray($oldArray);
// Error: Cannot cast data of type float[] to float. //

Is it that I'm declaring my array incorrectly?
Is there such a thing a float array function

OR:

proc float returnNewArray2 (float $myArray[])
{
for ($f = 0; $f <= size($myArray); $f++){
float $newArray[];
$newArray[$f] = $myArray[$f];
return $newArray[$f];
}
}
float $testArray[] = returnNewArray2($oldArray);
// Error: Cannot cast data of type float to float[]. //

Please help,

S

:scream:

GDC
07-28-2003, 09:43 PM
If you want your function to return an array you have to declare it that way.

proc float[] returnNewArray (float $myArray[])
{
for ($f = 0; $f <= size($myArray); $f++){
float $newArray[];
$newArray[$f] = $myArray[$f];
if ((size($newArray)) - (size($myArray)) == 0){
return $newArray;
}
}


--g

dunkel3d
07-28-2003, 09:48 PM
thanks GDC.

S

CGTalk Moderation
01-15-2006, 06:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.