WoW:API EditBox GetNumber

From AddOn Studio
Revision as of 13:37, 12 March 2005 by WoWWiki>DerGhulbus (i just read the type is really number, not float; strange language, this lua ;))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
GetNumber -Documentation by DerGhulbus-
number = editBox:GetNumber()

If a number was entered, it returns a numerical value of the number. If anything else was entered (including nil) it returns 0.


Arguments

none


Returns
number
number
Number - corresponding to the number entered in the EditBox

Details

This function proves to be very useful when reading in numbers. While GetText() will return a string, which you can't perform any arithmetic operations or comparison with, this function converts the TextString to a number. This will even work for all strings that are considered as well formed numerical constants in lua (so it will work for '314.16e-2' too).

If you enter a string, or a hybrid like 'abc123def', the function returns 0.

If you enter a hybrid like 12abc34 the function will ignore everything after the last valid digit (thus returning 12 in the example)


Template:WoW API