• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Use AS operators dinamically
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Use AS operators dinamically


  • Subject: Re: Use AS operators dinamically
  • From: Thomas Fischer <email@hidden>
  • Date: Mon, 4 Jan 2010 11:39:12 +0100

Hi!

Am 03.01.2010 um 20:52 schrieb Matt Neuburg:

> On Fri, 1 Jan 2010 20:15:48 +0000 (GMT), Hagimeno <email@hidden> said:
>> 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?
>
> Many modern scripting languages can easily do this sort of thing, but
> AppleScript is not one of them. m.

Fortunately, the state of affairs is not quite as bad.
For Hagimeno's example

	set myArray to {myVar, "starts with", "john"}

one could use

	set myAction to "return (\"" & item 1 of myArray & "\" " & item 2 of myArray & " \"" & item 3 of myArray & "\")"
	run script myAction

to get the desired result.
It is a bit awkward, and I don't know about the performance, but it will work.
Beware to keep track of the presence and absence of quotes: the resulting script has to look like
	return ("john is great" starts with "john")

All the best and Happy New Year to all of you!
Thomas

 _______________________________________________
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

References: 
 >Re: Use AS operators dinamically (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: Use AS operators dinamically
  • Next by Date: Applescript and memory
  • Previous by thread: Re: Use AS operators dinamically
  • Next by thread: Re: Use AS operators dinamically
  • Index(es):
    • Date
    • Thread