Re: Handler works only once
Re: Handler works only once
- Subject: Re: Handler works only once
- From: Kai <email@hidden>
- Date: Mon, 24 Feb 2003 20:18:31 +0000
on Mon, 24 Feb 2003 08:40:27 -0600, Rich Carroll <email@hidden> wrote:
>
Thanks Has & Kai & Julifos and anyone else who expended brain power on this.
>
The scripts work great, and are much more streamlined than my own. However I
>
have an additional question.
>
I want to be able to exclude extensions in file names. So if "." is followed
>
by only 2, 3, or 4 more characters before the end of the file name, don't
>
remove the "."
>
When repeating thru every item in a value, how do you get the item number?
>
--
>
if charRef's contents is in validChars then
>
set res to res & charRef
>
else if charRef's contents is "." and (charRef's item) is -3 then
>
set res to res & charRef
You really want something like character -4 of the whole name (txt), Rich.
Also, you could optimise the handler slightly by checking for the extension
point only once per name (rather than on every iteration of the repeat loop)
- perhaps something like this:
=====================================
on stripInvalidChars(txt, validChars)
set res to ""
repeat with charRef in txt
if charRef's contents is in validChars then
set res to res & charRef
end if
end repeat
if txt's character -4 is "." and res ends with [NO-BREAK]
txt's text -3 thru -1 then set res to [NO-BREAK]
res's text 1 thru -4 & "." & res's text -3 thru -1
return res
end stripInvalidChars
=====================================
--
Kai
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.