Infanite Parameters in a Function

Blitz3D Forums/Blitz3D Programming/Infanite Parameters in a Function

Knight #51(Posted 2008) [#1]
Is there a way to make a function that has infanite parameters???


Beaker(Posted 2008) [#2]
Pass a "blitz" array or bank.


Knight #51(Posted 2008) [#3]
Sorry for not making myselft clear ;D

Here is what I meant.....

I want to create a funtion that can pass infanite values

e.g

Function MoveThings(entity1,entity2......)

...............

Move Things

...............

End Function


mtnhome3d(Posted 2008) [#4]
you could just loop through and call the function every time but specify a different thing to move each tim


big10p(Posted 2008) [#5]
If you need to pass a huge amount of parameters into a function, you're doing something wrong.


Rroff(Posted 2008) [#6]
Indeed... case in point you should have a type collection for your game entities and then in the function for doing movement on those game entities you would itterate through the type collection.


_PJ_(Posted 2008) [#7]
What you need to do, is something like this instead:

Function MyFunction(Entity)
   DoSomethingToEntity
End Function

. . .. . . . .. . .

For MyEntities.EntityType=Each EntityType
     MyFunction(MyEntites\EntityField)
Next



Stevie G(Posted 2008) [#8]
I'm with big10p on this.


Knight #51(Posted 2008) [#9]
If you need to pass a huge amount of parameters into a function, you're doing something wrong.


ROFL :)

I was just wondering if it was possible to assign a function with infanite parameters ;)


SLotman(Posted 2008) [#10]
I was just wondering if it was possible to assign a function with infanite parameters ;)


You can't, you have a memory limitation, and if you cross it, you get an "stack overflow" (because parameters in assembly generally goes into the stack)

Of course, you can have LOTs of parameters, but that will slow your program. Better to make a Type with all "parameters" as fields, and then just pass the type into your function... you will be passing just a pointer to where all parameters are in memory, and it should be pretty fast :)


Knight #51(Posted 2008) [#11]
Thanks everybody ;D