User Tools

Site Tools


embeddedapi:devel:lua

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
embeddedapi:devel:lua [2013/04/24 10:09]
linuxmaniac [sr.xavp.get_keys]
embeddedapi:devel:lua [2013/09/16 22:14]
linuxmaniac [sr.xavp.get_keys]
Line 312: Line 312:
 ==== sr.xavp.get_keys ==== ==== sr.xavp.get_keys ====
  
-returns array table with the key names of the xavp variable.+returns an array table with the key names of the xavp variable.
  
 Prototype Prototype
Line 324: Line 324:
 <code c> <code c>
 $xavp(test=>one) = 1; $xavp(test=>one) = 1;
-$xavp(test=>two) = "two"; +$xavp(test[0]=>two) = "two"; 
-$xavp(test=>three) = 3;+$xavp(test[0]=>three) = 3;
 </code> </code>
  
Line 331: Line 331:
 t = sr.xavp.get_keys("test", 0) t = sr.xavp.get_keys("test", 0)
 for k,v in pairs(t) do for k,v in pairs(t) do
-  print(string.format("%d:%s\n", k, v)+  sr.log("info", string.format("%d:%s\n", k, v))
 end end
 </code> </code>
Line 346: Line 346:
  
 returns a dictionary table with the values of the xavp variable. returns a dictionary table with the values of the xavp variable.
 +Third param is optional and it choose between get all the values of a key ( 0, default) or just the first ones (1)
  
 Prototype Prototype
  
 <code c> <code c>
-t = sr.xavp.get("xavp_name", 1)+t = sr.xavp.get("xavp_name", 1, 0)
 </code> </code>
  
Line 356: Line 357:
  
 <code c> <code c>
-$xavp(test=>one) = 1; +$xavp(test=>a) = 1; 
-$xavp(test=>two) = "two"; +$xavp(test[0]=>a) = 2; 
-$xavp(test=>three) = 3;+$xavp(test[0]=>a) = 3; 
 +$xavp(test[0]=>b) = "one"; 
 +$xavp(test[0]=>b) = "two"; 
 +$xavp(test[0]=>b) = "three";
 </code> </code>
  
 <code c> <code c>
-t = sr.xavp.get("test", 0)+t = sr.xavp.get("test", 0, 0
 +for k,t2 in pairs(t) do 
 + for i,v in ipairs(t2) do 
 +   sr.log("info", string.format("%s[%d]:%s[%s]\n", k, i, tostring(v), type(v))) 
 + end 
 +end 
 + 
 +t = sr.xavp.get("test", 0, 1)
 for k,v in pairs(t) do for k,v in pairs(t) do
-  print(string.format("%s:%s[%s]\n", k, tostring(v), type(v))+ sr.log("info", string.format("%s:%s[%s]\n", k, v, tostring(v), type(v)))
 end end
 </code> </code>
Line 371: Line 382:
  
 <code c> <code c>
-three:3[number] +a[1]:3[number] 
-two:two[string+a[2]:2[number
-one:1[number] +a[3]:1[number] 
-</code>+b[1]:three[string] 
 +b[2]:two[string] 
 +b[3]:one[string]
  
 +a:3[number]
 +b:three[string]
 +</code>
 ===== SR.SL Package ===== ===== SR.SL Package =====
  
embeddedapi/devel/lua.txt · Last modified: 2017/06/23 11:31 by sdamm