Differenze

Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.

Link a questa pagina di confronto

hollywoodlibs:tables:testreplacechars [2016/10/21 09:10]
admin creata
hollywoodlibs:tables:testreplacechars [2016/10/21 09:25] (versione attuale)
admin
Linea 1: Linea 1:
 ====== Replacing strings in table items ====== ====== Replacing strings in table items ======
  
 +**TB.ReplaceChars()** is a very powerful function that scan a table and replaces any occurancies of a string with another. The process can optionally be fully recursive.
 +
 +<​code>​
 +Function TB.TEST_ReplaceChars()
 +  Local table = { { name = "​Spiderman",​ power = "​Web"​ },
 +                  { name = "​Thor",​ power = "​Hammer"​ },
 +                  { name = "​Flash",​ power = "​Speed"​ },
 +                  { name = "Iron Man", power = "​Armour"​ },
 +                  { name = "Iron Man", power = "​Weapons"​ },
 +                  { name = "​Hulk",​ power = "​Strenght"​ } }
 +                  ​
 +  NPrint("​TABLE CONTENT"​)
 +  For i = 0 To 5
 +    Local v = table[i]
 +    NPrint("​INDEX : [color=#​red]"​ .. i .. "​[/​color],​ NAME : [color=#​yellow]"​ .. v.name .. "​[/​color],​ POWER : " .. v.power)
 +  Next
 +
 +  NPrint("​\nLOCATING AND REPLACING ALL <man> WITH <​woman>"​)
 +  TB.ReplaceChars(table,​ "​man",​ "​woman",​ True, False)
 +  ​
 +  NPrint("​\nTABLE CONTENT"​)
 +  For i = 0 To 5
 +    Local v = table[i]
 +    NPrint("​INDEX : [color=#​red]"​ .. i .. "​[/​color],​ NAME : [color=#​yellow]"​ .. v.name .. "​[/​color],​ POWER : " .. v.power)
 +  Next
 +  ​
 +  NPrint("​\nLeft mouse to QUIT."​)
 +  ​
 +  WaitLeftMouse()
 +  ​
 +EndFunction
 +</​code>​
hollywoodlibs/tables/testreplacechars.txt ยท Ultima modifica: 2016/10/21 09:25 da admin
CC Attribution-Noncommercial 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0