Re: String character offset in excel cell string value
Re: String character offset in excel cell string value
- Subject: Re: String character offset in excel cell string value
- From: Paul Berkowitz <email@hidden>
- Date: Wed, 20 Oct 2004 08:31:31 -0700
Title: Re: String character offset in excel cell string value
On 10/20/04 8:05 AM, "Stephanos Piperoglou" <email@hidden> wrote:
I'm trying to parse a string contained in an Excel workbook
[...}
rec_name is a string. Offset is a method of string. Why is access not allowed?
obviously offset is being interpreted by Excel somehow. Take it outside the tell block?
Thanks that did it, though it did mess up my code a bit (a lot initially because I rewrote it thinking that variables are scoped inside tell blocks, which they're not. AppleScript is weird - but in a good way :-). Kind of like perl only you can actually read your own code). I hit upon a little diatribe on AppleScript's name resolution mechanism in the mean time that makes this kind of clear. Can I use something like "using terms" to tell AppleScript to look up terms in the Standard Extensions namespace or use an explicit namespace qualifier of some sort?
Sometimes 'tell me' works. But not here. Excel's 'offset' rules inside a tell block. If you find it awkward to terminate the tell block and start another, it's quite simple - just call out to a handler (subroutine). There's no need to select anything either . The concatenation operator for strings, which display dialog uses, is '&' not '+'.
tell application "Microsoft Excel"
activate
set sheet1 to first worksheet of workbook "addresses_greek.xls"
set thisrow to row 7 of sheet1
select thisrow
set rec_name to the string value of the first cell of thisrow as string
set firstSpace to my GetOffset(" ", rec_name)
display dialog "Offset of first space: " & firstSpace
end tell
to GetOffset(subString, mainString)
return (offset of subString in mainString)
end GetOffset
Alternative:
--
Paul Berkowitz
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden