Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Inline IF ELSE doesnt work?


Question

Posted

@jgab Jan, i used to use inline IF ELSE abbreviations like

 

variable1 = variable2 == false and false or true

 

and it worked for me but thise line doesnt work. I want to get the useHTML quickapp variable, that is always a string value, and convert it to a bolean while assigning it to variable USEHTML

 

USEHTML = self:getVariable("useHTML") == "false" and false or true

 

Where is the trick?

 

 

5 answers to this question

Recommended Posts

  • 0
Posted

Hi,

 

First is self:getVariable("useHTML") value "true"  /"false" or "0" / "1"

Use print(self:getVariable("useHTML")) to check what value is stored there ...

  • 0
  • Inquirer
  • Posted
    21 minutes ago, ivx said:

    Hi,

     

    First is self:getVariable("useHTML") value "true"  /"false" or "0" / "1"

    Use print(self:getVariable("useHTML")) to check what value is stored there ...

    I know what value is storeed there. This is not the question..There is either "false" or "true" stored (in string type, as QA variables are stored always as string).

    • 0
    Posted

    USEHTML = (self:getVariable("useHTML") == "false") and false or true

    • Thanks 1
    • 0
    Posted
    8 hours ago, Neo Andersson said:

    @jgab Jan, i used to use inline IF ELSE abbreviations like

     

    variable1 = variable2 == false and false or true

     

    and it worked for me but thise line doesnt work. I want to get the useHTML quickapp variable, that is always a string value, and convert it to a bolean while assigning it to variable USEHTML

     

    USEHTML = self:getVariable("useHTML") == "false" and false or true

     

    Where is the trick?

     

     

    No, it doesn't work this way. Replacing "inline ifthenelse" with "and or" has pitfalls if you return boolean values.

    In your case it won't return false if there is a "or true" the end. In this case the "or true" will return.

    You can code around it by switching the test

    Please login or register to see this code.

    or shorter

    Please login or register to see this code.

     

    • 0
  • Inquirer
  • Posted (edited)
    14 minutes ago, jgab said:

    No, it doesn't work this way. Replacing "inline ifthenelse" with "and or" has pitfalls if you return boolean values.

    In your case it won't return false if there is a "or true" the end. In this case the "or true" will return.

    You can code around it by switching the test

    Please login or register to see this code.

    or shorter

    Please login or register to see this code.

     

    Wow, thanks..the last one is pretty neat

    @jgab Jan, these days its pretty hard to catch you online...I hope you are doing well...

    May i ask one more question...I am struggling hardly with multiselect.. (i am not using the new view at all it is even worse) but in the old view, i just cant do some action

     

    1. I cant select all the devices by code

     

    2. and most importantly i cant delete the dropdown options..it just doesnt work... self:updateView("dd","options", {}), neither  self:updateView("dd","options", nil) nothing works..

     

    3. How to unselect an item by code

     

    Are these things even posssible

    Edited by Neo Andersson

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...