Exception handling

From Bohemia Interactive Community
Revision as of 18:26, 22 July 2006 by Djura (talk | contribs) (completed)
Jump to navigation Jump to search


In Armed Assault is implemented system of scripting commands which allows your scripts react to lots of kinds of exceptions. Standard construction is:

try {
    //block, that can throw exception
    if (_name == "") then {
        throw "invalid _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:

Template:Box File

try {
    TitleText ["Sgt. Detritus: I get bomb to his car ;-)", "PLAIN DOWN"]
    [jeepOne] exec "fireBomb.sqs"
}
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"] }