Re: Simple delete
Re: Simple delete
- Subject: Re: Simple delete
- From: Christopher Nebel <email@hidden>
- Date: Tue, 9 Mar 2004 11:12:52 -0800
On Mar 9, 2004, at 10:32 AM, Robert Poland wrote:
This simple delete appears not so simple. What am I missing?
tell application "Tex-Edit Plus"
set x to "09-Mar-04"
if item 1 of x = "0" then
delete item 1 of x
end if
end tell
x --> "9-Mar-04"
Are you saying that's what you want, or that's what you get? I'm
guessing the former, seeing as how that script doesn't work. There are
two big problems here:
1. You're telling Tex-Edit Plus to modify a plain AppleScript string,
which is not something it has anything to do with. If you wanted to
tell TEP to modify one of its documents, then fine, but otherwise, the
"tell" is irrelevant.
2. Strings in AppleScript are not modifiable -- you can't change them
at all, let alone delete pieces of them. What you can do is pick them
apart and construct new strings. For instance, this works:
set x to "09-Mar-04"
if item 1 of x = "0" then
set x to text from item 2 to end of x
-- There are several ways to express this; this is the one I like.
end if
x --> "9-Mar-04"
--Chris Nebel
AppleScript Engineering
_______________________________________________
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.