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


Recommended Posts

Posted

what is the differents between:

 

if fibaro:getValue(lamp, "value") > "0"

 

and this line

 

if (tonumber(fibaro:getValue(lamp, "value")) > 0)

 

i know one line is smaller than the other

but is the first line for letters and the second for numbers only

or there is a substantial difference

 

also this

 

tonumber ("0") or just 0 or "0"

 

thanks

Posted

I hope this will help:

Please login or register to see this code.

  • Topic Author
  • Posted

    Please login or register to see this image.

    /emoticons/default_icon_biggrin.gif" alt=":-D" />  not at all

     

    i understand what it is what you wrote.

    But do not see what that has to do with my question (or maybe everything but i dont see it

    Please login or register to see this image.

    /emoticons/default_icon_redface.gif" alt=":oops:" /> )

    Posted

    2 examples in one you got numbers in other you got string but the result can be diffrent

    Please login or register to see this code.

    Posted

    To try to clarify:

    "10" is text for the number of 10, you can not do any calculations on the text. In the example the text in the value mystring. To do calculations on the value mastering you have to convert it a number, this you with tonumber(mystring). If you do a simple adding of tonumber(mystring)+tonumber(mystring) you will get 20. If you leave out to number here you will try to add together two texts.

    Posted

    For completeness lua string compare, does exist!

    Please login or register to see this link.

    I quote:

    Lua compares strings in alphabetical order, which follows the locale set for Lua. For instance, with the European Latin-1 locale, we have "acai" < "açaí" < "acorde".

    And for that same reason, "5" > "10" is true (the example of Mr Socha.)!

    If you don't know the type of variable "x", you can find out by printing it:

    Please login or register to see this code.

    Join the conversation

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

    Guest
    Reply to this topic...

    ×   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...