[newbie] from string to operator

i’ve a script part like that :
[…]
case operand
when "+"
setNumber(getMemory + getNumber)
when "-"
setNumber(getMemory - getNumber)
when "*"
setNumber(getMemory * getNumber)
when "/"
setNumber(getMemory / getNumber)
end
[…]

is there a way to replace all the above with something like an eval
function :

eval(getMemory, operand, getNumber)

that’s to say a way to transform the string operand to the operator ???

···


yt

getMemory.send(‘+’,getNumber)

···

il Mon, 22 Mar 2004 09:56:19 +0100, yvon.thoravalNO-SPAM@free.fr (Yvon Thoraval) ha scritto::

i’ve a script part like that :
[…]
case operand
when “+”
setNumber(getMemory + getNumber)
when “-”
setNumber(getMemory - getNumber)
when “*”
setNumber(getMemory * getNumber)
when “/”
setNumber(getMemory / getNumber)
end
[…]

is there a way to replace all the above with something like an eval
function :

eval(getMemory, operand, getNumber)

that’s to say a way to transform the string operand to the operator ???

— Yvon Thoraval yvon.thoravalNO-SPAM@free.fr wrote: > i’ve a script
part like that :

[…]
case operand
when “+”
setNumber(getMemory + getNumber)
when “-”
setNumber(getMemory - getNumber)
when “*”
setNumber(getMemory * getNumber)
when “/”
setNumber(getMemory / getNumber)
end
[…]

is there a way to replace all the above with something like an eval
function :

eval(getMemory, operand, getNumber)

that’s to say a way to transform the string operand to the operator ???

Or use the “===” operator…

– Thomas Adam

···

=====
“The Linux Weekend Mechanic” – http://linuxgazette.net
“TAG Editor” – http://linuxgazette.net

“ We’ll just save up your sins, Thomas, and punish
you for all of them at once when you get better. The
experience will probably kill you. :)”

– Benjamin A. Okopnik (Linux Gazette Technical Editor)


Yahoo! Messenger - Communicate instantly…“Ping”
your friends today! Download Messenger Now
http://uk.messenger.yahoo.com/download/index.html