Removing characters from end of string

I am trying to remove 1 character from the leading string and 2 characters from the trailing string.

The information comes from the clipboard but has some characters that I want removed. The code to trim the leading character works fine but I get the following error when trying to remove the trailing 2.

error "Can’t get end of "Shrout Cemetery

"." number -1728 from last insertion point of "Shrout Cemetery

"



-- Change clipboard to text format
set the clipboard to (the clipboard as string)


-- copy clipboard to string
set the myText to the clipboard

-- trim leading character
set myText to text 2 thru end of myText as string
display dialog myText


-- trim trailing 2 characters
set myText to text 1 thru ((end of myText) - 2) as string
display dialog myText

-- put back into clipboard
set the clipboard to (myText as string)


Thanks for any suggestions
Roger

Hi,

the first character is text 1, the last character is text -1.
so this removes the first character


set myText to text 2 thru -1 of myText

and this removes the first and the last character


set myText to text 2 thru -2 of myText

the as string coercions are not needed

Thanks worked great

Sometimes I think my brain has been fried.

Roger