Exception handling: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(I'll write next part later...)
 
mNo edit summary
Line 1: Line 1:
[[Category:Armed Assault:Scripting]]
[[Category:Armed Assault:Scripting]]


In Armed Assault is implemented system of [[Armde Assault:Scripting commands|scripting commands]] witch allows your scripts react to lots of kinds of exceptions.
In Armed Assault is implemented system of [[Armde Assault:Scripting commands|scripting commands]] which allows your scripts react to lots of kinds of exceptions.
Standard construction is:
Standard construction is:



Revision as of 17:55, 22 July 2006


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 ["And the name is:", "PLAIN DOWN"]
       ~1
       TitleText [_name, "PLAIN DOWN"]

}

catch {

   //block, that processes an exception
   if (_exception == "invalid _name") then {
       echo "Wrong name detected"
       TitleText ["And the name isn't", "PLAIN DOWN"]
   }

}

Template:AnswerMe Probably is possible this too:

try {

   TitleText ["Sgt. Detritus: He have luck, but next time I'll kill him!", "PLAIN DOWN"]
   [jeepOne] exec "killDriver.sqs"

}

catch {

   if (_exception == "car empty") then {
       TitleText ["Sgt. Detritus: He have luck, but next time I'll kill him!", "PLAIN DOWN"]
   } else {
       TitleText ["Sgt. Detritus: Some strange error appears...", "PLAIN DOWN"]

}