Get certain piece of text (i.e. second character)

Hi, I have this script like,

set theWord to text returned of (display dialog "Enter your word below." default answer "")

and would it be possible to get the 2nd or 3rd or any other certain piece of text returned of theWord? for example, if theWord is “AppleScript”, then get the 2nd letter, “p”.

Thanks in advance

Hi,

elements of class text are character and text (there are also word, line and paragraph)

you can use


set theWord to "AppleScript"

set b to item 2 of theWord -- is the same as item 2 of characters of a
set c to character 2 of theWord
set d to text 2 of theWord
--> all results are "p"

The difference between character and text is


set theWord to "AppleScript"

set c to characters 2 thru 4 of theWord --> {"p", "p", "l"}
set d to text 2 thru 4 of theWord --> "ppl"

Thanks alot:D