Re: Short form
Re: Short form
- Subject: Re: Short form
- From: "Mark J. Reed" <email@hidden>
- Date: Fri, 5 Sep 2008 15:31:59 -0400
The expression
characters 19 thru 20 of aWord
returns a list, not a string. {"C","N"} is not the same as "CN", so
the comparison fails. You could either do the "as string" *before*
the if, as part of the assignment to sname, rather than waiting until
you're doing a display dialog, or just use "text" instead of
"characters":
set sname to text 19 thru 20 of aWord
On Fri, Sep 5, 2008 at 3:19 PM, Script2 <email@hidden> wrote:
> Hi Michelle
>
> I tried this but does not work. What am I doing wrong, it just displays CN
> not found or TO not found.
>
> tell application "Finder"
> set file1text to read file ("Macintosh HD:Ruby:Paragraph Count:Issue
> List:M808") from 1
> set gterm to every paragraph of file1text
> repeat with aWord in gterm
> set sname to characters 19 thru 20 of aWord
> if sname is in {"CN", "TO", "LS"} then
> display dialog (sname as string) & " found"
> else
> display dialog (sname as string) & " not found"
> end if
> end repeat
> end tell
>
>
>
> Thanks for your help
>
> Ruby
> -----Original Message-----
> From: applescript-users-bounces+script2=email@hidden
> [mailto:applescript-users-bounces+script2=email@hidden]
> On Behalf Of Michelle Steiner
> Sent: Friday, September 05, 2008 1:43 PM
> To: Applescript Users
> Subject: Re: Short form
>
> On Sep 5, 2008, at 10:35 AM, Script2 wrote:
>
>> Is there a short form for writing this "if" statement
>>
>> If sname = "CN" or sname = "DD" or sname = "DR" or sname = "FM" then
>> (I have
>> about 10 names to check)
>
>
> if sname is in {"CN", "DD", "DR"} then
> -- do something
> else
> -- do something else
> end if
>
> --
> Please contribute to the Leukemia and Lymphoma Society, and help me
> meet my fund raising goal for my marathon training.
> <http://www.active.com/donate/tntdms/tntdmsMSteine>
>
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> tern.com
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to 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
>
--
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