Difference between revisions of "Exkeyvalstr"

From OpenEUO
Jump to: navigation, search
m (Created page with "== Calling Pattern == Call local r = sl.exkeyvalstr(arg) Args arg is a table Results r is a string == Usage Example == local s = {[11]=16} local t = { [0]='finale', alice=...")
 
m
Line 11: Line 11:
 
  local s = {[11]=16}
 
  local s = {[11]=16}
 
  local t = { [0]='finale', alice='joker', [s]='88'}
 
  local t = { [0]='finale', alice='joker', [s]='88'}
  local r = sl.keyvalstr(t)
+
  local r = sl.exkeyvalstr(t)
 
  print(r)
 
  print(r)
  
Line 33: Line 33:
  
 
* [[keystr]]
 
* [[keystr]]
 +
 +
* [[exkeyvalstr]]
  
 
* [[tabletolua]]
 
* [[tabletolua]]

Revision as of 18:38, 8 January 2011

Calling Pattern

Call

local r = sl.exkeyvalstr(arg)

Args

arg is a table

Results

r is a string

Usage Example

local s = {[11]=16}
local t = { [0]='finale', alice='joker', [s]='88'}
local r = sl.exkeyvalstr(t)
print(r)
--> table keys:values = {
    0:finale,
    alice:joker,
    keys:values = {
    11:16,
    }:88,
    }

Description

The helper function exkeyvalstr returns a human readable string composed of the keys and values found in its sole argument. The keys and values are converted to strings before insertion into the resultant string, if they are tables they will be converted using keyvalstr. If the sole argument is not a table, then the string 'not a table' is returned. future versions of the library may alter the output slightly. the key* and exkey* helpers aren't intended to convert data into a dostring compatible format; use tabletolua to address that need.

See Also

  • exkeyvalstr