Difference between revisions of "Convert"

From OpenEUO
Jump to: navigation, search
m (Usage Example)
m (Usage Example)
 
Line 18: Line 18:
  
 
  --> table keys:values = {
 
  --> table keys:values = {
--> 1:RC,
+
    1:RC,
--> 2:AH,
+
    2:AH,
--> 3:FL,
+
    3:FL,
--> }
+
    }
--> RC
+
    RC
--> 13038
+
    13038
--> table keys:values = {
+
    table keys:values = {
--> 1:13038,
+
    1:13038,
--> 2:5520,
+
    2:5520,
--> 3:7767,
+
    3:7767,
--> }
+
    }
  
 
== Description ==
 
== Description ==

Latest revision as of 17:19, 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.

See Also