limit variable to 160 chars

Hi Folks,

may you can help me out with the following:

set text_sms to contents of text view "text" of scroll view "text" of tab view item "Outbox" of tab view "tab" of window "main" as string

the input of the scroll view will be presented in the variable text_sms

No I try to limit the variable to 160 chars:


set text_sms to (characters 160 thru 160 of text_sms) as string
or
set text_sms to (characters 1 thru 160 of text_sms) as string
or
set txt_sms to text_sms for 35

Does anybody knows the correct syntax?

Thanks for your help,

Stefan

Hi Stefan,

to limit the input length of your text view to max. 160 characters I’d use an ‘on changed’ handler connexted to it:

on changed theObject
	set text_sms to content of theObject
	if length of text_sms > 160 then
		set content of theObject to text 1 thru 160 of text_sms
	end if
end changed

D.

Hi Dominik,

thanks a lot! This works really perfect! Thanks for your help and merry christmas!

Stefan