OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Gielovic on 10 Nov 2007, 16:40:38
-
Hey guys,
I have somthing like this in my sqf script
FUNCTION = {private[blabla];
while(true) do{somthing};
[b]???if(true) exitWith{}???[/b]
}; //end
[blabla] call FUNCTION;
[balbal] call FUNCTION;
:
:
[blkajd] call FUNCTION;
do i need to insert an exitwith in the end of the function ( like i did in bold ) to let it terminate or does it do that automatically?
-
You don't need to terminate a function in any way. The only thing is that the function will always return the value of the last statement in it so I tend to just put nil at the end so that I'm not returning something unexpected (which is the same as a final if (true) exitWith {}).
add5ToVar =
{
var = var + 5;
};
add5ToVar =
{
var = var + 5;
nil;
};
add5ToVar =
{
var = var + 5;
if (true) exitWith {};
};