Exception handling: Difference between revisions
Jump to navigation
Jump to search
m (Now is program flow more clear) |
m (Parameters to script) |
||
Line 25: | Line 25: | ||
Probably is this possible too: | Probably is this possible too: | ||
{{Box File| | {{Box File|[] fireBomb.sqs|<pre> | ||
_car = _this select 0 | _car = _this select 0 | ||
if (crew _car == 0) then { | if (crew _car == 0) then { |
Revision as of 10:23, 23 July 2006
In Armed Assault exception handling is an implemented system of special scripting commands (try, catch and throw), which allows your scripts to create and to react to exceptions.
Standard construction is:
try { //block, that can throw exception if (_name == "") then { throw "no name" } else { TitleText [format["Good morning, Captain %1.", _name], "PLAIN DOWN"] ~1 TitleText [_name, "PLAIN DOWN"] }
catch { //block, that processes an exception if (_exception == "no name") then { echo "Name wasn't entred" TitleText ["And the name isn't", "PLAIN DOWN"] } }
Template:AnswerMe
Probably is this possible too:
try { TitleText ["Sgt. Detritus: I get bomb to his car ;-)", "PLAIN DOWN"] [jeepOne] exec "fireBomb.sqs" TitleText ["Sgt. Detritus: He is dead!", "PLAIN DOWN"] }
catch { if (_exception == "vehicle empty") then { TitleText ["Sgt. Detritus: He have luck, but next time I'll kill him!", "PLAIN DOWN"] } else { TitleText [format["Sgt. Detritus: Some strange error appears... %1... hmm... another time I'll get him!", _exception], "PLAIN DOWN"] }