Re: NSRegular expression question
Re: NSRegular expression question
- Subject: Re: NSRegular expression question
- From: Jim Weisbin <email@hidden>
- Date: Sun, 3 Sep 2017 19:45:12 -0400
Shane Stanley <email@hidden> wrote
>
> On 3 Sep 2017, at 1:12 am, Jim Weisbin <email@hidden> wrote:
>>
>> To get rid of the leading zeroes in order to do the look up, I’m casting the
>> string to an integer, which works. It’s guaranteed to be a number based on
>> the regex above, but is there any down side to doing it that way?
>
> Sounds fine to me:
>
> set theWord to (theText's substringWithRange:matchRange)'s
> integerValue() as text
>
> Also, these two lines:
>
> set thePathNoExt to pathString's stringByDeletingPathExtension()
> set theText to current application's NSString's stringWithString:thePathNoExt
>
> can be one:
>
> set theText to pathString's stringByDeletingPathExtension()
Thanks, I finished the program. Thank you so much for the Sqlite Lib. It’s a
godsend for what I’m doing.
I have another dumb question though. I tried to set up a handler which is
copied from your book:
on renameFileAt:posixPath1 toName:newName1
set fileManager to current application's NSFileManager's
defaultManager()
set posixPath1 to current application's NSString's
stringWithString:posixPath1
set theNewPath to posixPath1's stringByDeletingLastPathComponent()'s
stringByAppendingPathComponent:newName1
if fileManager's fileExistsAtPath:theNewPath then
error "A file with that name already exists"
else
set {theResult, theError} to fileManager's
moveItemAtPath:posixPath1 toPath:theNewPath |error|:(reference)
if (theResult as boolean) is false then
error (theError's localizedDescription() as text)
end if
end if
end renameFileAt:toName:
When I try to call it it like this:
set theResult to its renameFileAt:name1 toName:name2
I get an error “could not continue…”
But when I include the handler in-line (in other words, just running the code
in-line, not as a handler) it works fine. So there is a problem with the way
i’m calling it. Also, the Script editor always “corrects” it to "set theResult
to (its renameFileAt:posixPath1 toName:newName1)"
What am I doing wrong?
Jim Weisbin | C.T.O. | Human | Post Human | 27 West 20th Street | Suite 801 |
New York, NY | 10011 | (212) 352-0211 | (917) 375-2272 | 2046 Broadway |
Santa Monica, CA | 90404 | (310) 264-0211 telephone | www.humanworldwide.com
<http://www.humanworldwide.com/>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
applescriptobjc-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden