Monday, March 02, 2015
   
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:


Help Develop!

Thank You! :c)



Connect: Google+

Visitors of the World

Latest Posts

  • Basic Android App using Google Maps and Current Location

    • Wed 25-Feb-15
      SOrry ive solved the previous error but having an error context.LOCATIO N_SERVICE);
      lindalee  
    • Wed 25-Feb-15
      Hi im getting an error getLastKnownLocation(provider) can not resolve provider any hekp
      lindalee
  • JDatabase: using the Joomla database with examples

    • Sat 28-Feb-15
      High Praise, Thx Scott! I still use this for myself, nice to know it was of some use to you.
      Joel L.  
    • Fri 27-Feb-15
      Wow, thank you so much, Joomla documents are written for those who can read Joomla documents. :lol: Your ...
      Scott N.  
    • Thu 26-Feb-15
      Clearly represented jfactory querys. This helped me a lot. Thank you very much. :-)
      Oddy