[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: AW: return function
- From: "Peter Prade" <prade@...>
- Date: Sat, 11 Aug 2001 21:25:03 +0200
I don't speak portuguese, but i think i can answer this anyway:
dostring executes the given string in a seperate chunk, so you can't return
with a dostring call.
however, the result of dostring() is the return value(s) of the executed
string, so you can just pass it through, like this:
function f1()
tab={{1,2,3}, {4,5,6}}
s="return tab[1][1], tab[1][2]"
return dostring(s)
end
-----Ursprüngliche Nachricht-----
Von: owner-lua-l@tecgraf.puc-rio.br
[mailto:owner-lua-l@tecgraf.puc-rio.br]Im Auftrag von Marcos E. Wurzius
Gesendet: Samstag, 11. August 2001 4:59
An: Multiple recipients of list
Betreff: return function
Excuse, but I don't get to write in English.
In Portuguese...
Numa função, construo uma string para retornar.
function f1()
tab={{1,2,3}, {4,5,6}}
...
...
s="return tab[1][1], tab[1][2]"
dostring(s)
end
a , b = f1() -- não retorna nada
function f2()
tab={{1,2,3}, {4,5,6}}
return tab[1][1], tab[1][2]
end
a, b = f2() -- return a=1, b=2
Como faço no primeiro caso para retornar o resultado esperado?
A string "s" é construída durante a execução da função.
Marcos