Difference between revisions of "Convert"
From OpenEUO
					
										
					
					| m | m | ||
| Line 1: | Line 1: | ||
| − | + | == Calling Pattern == | |
| + | Call | ||
| + |  local r[, ...] = sl.convert(arg[, ...]) | ||
| + | Args | ||
| + |  arg1...argN are strings, numbers, or tables of strings and or numbers | ||
| + | Results | ||
| + |  r1...rN are (tables of) numbers, strings, or tables of numbers and or strings | ||
| − | Convert takes any number of arguments and attempts to convert  | + | == Usage Example == | 
| + | |||
| + |  local con = sl.convert | ||
| + |  local t1 = {123,234,345} | ||
| + |  local t2 = con(t1) | ||
| + |  print(sl.keyvalstr(t2)) | ||
| + |  print(con(123)) | ||
| + |  print(con('EFT')) | ||
| + |  print(sl.keyvalstr(con('EFT_GHI_JKL'))) | ||
| + | |||
| + |  --> 'table keys:values = {' | ||
| + |  --> '1:RC,' | ||
| + |  --> '2:AH,' | ||
| + |  --> '3:FL,' | ||
| + |  --> '}' | ||
| + |  --> 'RC' | ||
| + |  --> '13038' | ||
| + |  --> 'table keys:values = {' | ||
| + |  --> '1:13038,' | ||
| + |  --> '2:5520,' | ||
| + |  --> '3:7767,' | ||
| + |  --> '}' | ||
| + | |||
| + | == Description == | ||
| + | |||
| + | Convert takes any number of arguments and attempts to convert them into either easyuo id/types (if the argument was a number) or openeuo numbers (if the argument was a string).  The 'sense' of conversion is automatically detected. Will also convert tables of types and strings of types joined with the underscore _ character.  Thanks Boydon and Cheffe for the conversion routines used internally. | ||
| == See Also == | == See Also == | ||
| * [http://www.easyuo.com/openeuo/wiki/index.php/Simplelib simplelib] | * [http://www.easyuo.com/openeuo/wiki/index.php/Simplelib simplelib] | ||
| + | |||
| + | * [[keys]] | ||
| + | |||
| + | * [[keystr]] | ||
| + | |||
| + | * [[keyvalstr]] | ||
Revision as of 16:17, 2 November 2010
Calling Pattern
Call
local r[, ...] = sl.convert(arg[, ...])
Args
arg1...argN are strings, numbers, or tables of strings and or numbers
Results
r1...rN are (tables of) numbers, strings, or tables of numbers and or strings
Usage Example
local con = sl.convert
local t1 = {123,234,345}
local t2 = con(t1)
print(sl.keyvalstr(t2))
print(con(123))
print(con('EFT'))
print(sl.keyvalstr(con('EFT_GHI_JKL')))
--> 'table keys:values = {'
--> '1:RC,'
--> '2:AH,'
--> '3:FL,'
--> '}'
--> 'RC'
--> '13038'
--> 'table keys:values = {'
--> '1:13038,'
--> '2:5520,'
--> '3:7767,'
--> '}'
Description
Convert takes any number of arguments and attempts to convert them into either easyuo id/types (if the argument was a number) or openeuo numbers (if the argument was a string). The 'sense' of conversion is automatically detected. Will also convert tables of types and strings of types joined with the underscore _ character. Thanks Boydon and Cheffe for the conversion routines used internally.
