getAttr / getAttrw

parte:getAttr / getAttrw(nomeAttributo: stringa) → stringa

Legge un attributo, ritorna il valore o nil se l'attributo non e' presente.  La versione unicode si aspetta il nome dell'attributo come stringa unicode e ritorna una stringa unicode.

Esempio 67. Esempio getAttr()

local codice = prt:getAttr('CODICE')
local altezza = tonumber(prt:getAttr('ALTEZZA') or “0”)



Esempio 1. Esempio getAttr / getAttrw

local prt = top_ptop():find("BIELLA")
print("\nCodice: " .. (prt:getAttr("COD") or "nil"))
-- versione unicode: parametro e valore di ritorno sono string_w
local valW = prt:getAttrw(_U("COD"))
if valW then print("\nLunghezza: " .. valW:length()) end