Wolygon
2011-05-07 02:54:49
Hey, I have the following case to set variables to use in the function (there will be more actions):
Example 1:
This is clearly repetitive as I'm doing the same thing over and over, so a function would be good like:
Example 2:
And then set them in the function.
But since the variables are local this would not work, instead I would have to make them global. So is there a way to set "local variables for a function from another function", I would guess not as that is kind of the point of a global variable.
If not what do you think would be the best method of doing this:
1) Make global variables
2) Just use Example1
3) Something else
I just don't which is considered worse, messy looking code (example1) or setting them as global variables.
Thanks.
Example 1:
case action of
'OpenDoor' : begin
TileOffset.x := 5;
TileOffset.y := 5;
ObjID := 29261;
end;
'ClimbDown' : begin
TileOffset.x := 5;
TileOffset.y := 5;
ObjID := 29261;
end;
end;This is clearly repetitive as I'm doing the same thing over and over, so a function would be good like:
Example 2:
case action of
'OpenDoor' : ObjFindingVar(5, 5, 29261);
'ClimbDown' : ObjFindingVar(5, 5, 29261);
end;And then set them in the function.
But since the variables are local this would not work, instead I would have to make them global. So is there a way to set "local variables for a function from another function", I would guess not as that is kind of the point of a global variable.
If not what do you think would be the best method of doing this:
1) Make global variables
2) Just use Example1
3) Something else
I just don't which is considered worse, messy looking code (example1) or setting them as global variables.
Thanks.