Infanite Parameters in a Function
Blitz3D Forums/Blitz3D Programming/Infanite Parameters in a Function
| ||
Is there a way to make a function that has infanite parameters??? |
| ||
Pass a "blitz" array or bank. |
| ||
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 |
| ||
you could just loop through and call the function every time but specify a different thing to move each tim |
| ||
If you need to pass a huge amount of parameters into a function, you're doing something wrong. |
| ||
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. |
| ||
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 |
| ||
I'm with big10p on this. |
| ||
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 ;) |
| ||
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 :) |
| ||
Thanks everybody ;D |