Saturday, September 20, 2014
   
Text Size
Login

AutoHotkey Ternary Operator

Just a quick note for the moment on how to use ternary operators in AutoHotkey.  A ternary operator for those who are unfamiliar with this is an "If...Then...Else..." statement written in a small amount of code, usually on one line, and exists in most programming languages.

For Example, the statement:

 


  1.  If (ThisCondition = true) 
  2.      ThisVar:=1 
  3.  Else 
  4.      ThisVar:=2 

Converted to Ternary this would look like:


  1.  ThisVar:=(ThisCondition = true) ? 1 : 2 
I'll add as there are a whole bunch of methods using the Ternary Operator in AutoHotkey (discussed on http://www.autohotkey.com/forum/topic29752.html) which I'll put in soon. I just needed something on my site now as I find myself looking for this bit of info every now and again.

Comments   

iBob35555VR
# iBob35555VR Thu, 26th July 2012
Oh ok So
Var := (Condition) ? Return_if_true : Return_If_false

Nice =P
Like | Dislike | 0 Reply | Reply with quote | Quote
Add Comment

Name:

Email:

Website:

Message:


Latest Posts