Re: Use AS operators dinamically
Re: Use AS operators dinamically
- Subject: Re: Use AS operators dinamically
- From: "Mark J. Reed" <email@hidden>
- Date: Fri, 1 Jan 2010 15:52:33 -0500
Operators are not strings, and vice-versa. While you can construct
and evaluate code at runtime via "run script", it's slow and awkward.
Not to mention insecure if you execute code from user-supplied data,
but it sounds like you're hard-coding the array, so that's not an
issue here.
I recommend you just use a if/else to look at the operation
selector value and perform the desired operation explicitly, e.g.
set {target, op, value} to opArray
if op is "starts with" then
set returnValue to (target starts with value)
else if op is "ends with" then
set returnValue to (target ends with value)
...
end if
On Friday, January 1, 2010, Hagimeno <email@hidden> wrote:
> Hi,
>
> I would like to know if and how is possible to use the AS operators like starts with, contains, ends with, starting from them as "string".
> Suppose you have an array like this that contains the variable where to search, the operator and the string to search:
>
> set myArray to {myVar, "starts with", "john"}
>
> I would like to be able to search in myWar using the operator starts with that is described as string but need to be real operator.
>
> Is possible to do that?
>
> Alex
>
>
>
>
> _______________________________________________
> 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
>
--
Mark J. Reed <email@hidden>
_______________________________________________
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