Re: Use AS operators dinamically
Re: Use AS operators dinamically
- Subject: Re: Use AS operators dinamically
- From: has <email@hidden>
- Date: Mon, 4 Jan 2010 15:18:38 +0000
Takaaki Naganoya wrote:
> But our imagination is unlimited.
As are your security holes.
Sorry, but using 'run script' to compile and execute arbitrary code is almost always the wrong solution to a problem. And even where it's the only option available, there are extremely nasty gotchas to be negotiated.
As someone else suggested, if the OP has a genuine need to specify operators by string, use a conditional block that tests for each operator in turn:
on do_operation(operand_1, the_operator, operand_2)
considering hyphens, punctuation and white space
if the_operator is "+" then
return operand_1 + operand_2
else if the_operator is "-" then
...
end if
end considering
error "Unknown operator." from the_operator
end do_operation
Simple, fast, reliable.
If you want to do funky stuff, go use a language that's designed for it, such as Python or Ruby, e.g.:
$ irb
>> 2.send('+', 2)
=> 4
has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden