Newbie: Deleting the rest of a line

Say I have this text: “xxxxxxxxxx info info info”
In AppleScript, does anyone know of a way to shorten the string to the first 10 letters? Thanks.

: Say I have this text: “xxxxxxxxxx info info info”
: In AppleScript, does anyone know of a way to shorten the string
: to the first 10 letters? Thanks.

set shortText to text 1 thru 10 of "xxxxxxxxxx info info info"

NG

Your question is a bit vague. What program is the “line” in? If it’s a text editor, check the text editor’s dictionary on how to handle lines (or paragraphs, if imakes a distiction). I can help you write the proper object code for several text editor, if I know which one you’re using.

If the line can be read into applescript, then:

Assuming you know that the “line” is long than 10 letters and that you want the first 10 letters no matter what they are.

set sometext to "xxxxxxxxxx info info"
set newtext to text 1 thru 10 of sometext
newtext -- returns "xxxxxxxxxx"

If a character marks the different between the text you wish to keep and that you wish to remove, then

set sometext to "xxxxxxxxxx info info"
set former_delimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to space
set newtext to text item 1 of sometext
set AppleScript's text item delimiters to former_delimiters
newtext -- returns "xxxxxxxxxx"

because the space character separates the first 10 from the others.

m_g