• Professional advice
  • Order before 23.59 uur shipped today
  • Almost always available (+31 73 762 0 762)
  • Monday open late

Tonumber command

tonumber()

 

Action :

Tries to convert the passed value into a number.
 

Usage and parameter :

tonumber(argument)

  • argument: Een argument van een willekeurig type dat omgezet dient te worden naar een getal.

 

Returned value :

A nummeric value.

 

Programming example :

-- assign a string to a variable mystring
local mystring = '123'

 
-- Example below will result in an error message since mystring is not a number.
if (mystring > 100)  then

end 


-- Thats why we convert a string into a nummeric value.
-- Example : Put the device off when 'Brightness" is more thant 50.

if (tonumber(mystring) >10)  then
   fibaro:debug('This works, the variable is more than 10');
end

 

 

See also:

tosting()
LUA reference manual 5.2 : tonumber

 

 

 

 
Customer Service Phone

+31737620762
mon-fri: 10am-5pm and sat 10am-3pm

 
Adress

Gerstakker 16 5236 VG Empel Netherlands

Google maps