Re: getting chunks of text
Re: getting chunks of text
- Subject: Re: getting chunks of text
- From: yvan-koenig <email@hidden>
- Date: Thu, 17 Mar 2005 09:06:04 +0100
Perhaps this may help:
property monTexte : "Given a string of length unknown, I need to chop
it up to less than 256" & return & ¬
"characters, however, I do not want to chop a word in half, so scan
backwards" & return & ¬
"to the first space before 256 chars. Not to worried about what would
happen" & return & ¬
"when running into punctuation and such." & return & return ¬
& "I need a result set that I can repeat through, thanks." & return &
"-- " & return & ¬
"-------------------------------------------------------------" &
return & ¬
"Scott Haneda Tel: 415.898.2602" &
return & ¬
"<http://www.newgeo.com> Novato, CA U.S.A." &
return & "" & return & return & ¬
" _______________________________________________" & return & ¬
"Do not post admin requests to the list. They will be ignored." &
return & ¬
"Applescript-users mailing list
(email@hidden)" & return & ¬
"Help/Unsubscribe/Update your Subscription:" & return & ¬
email@hidden" & return & ¬
return & "This email sent to email@hidden"
set liste to my texte2liste(monTexte, " ")
set liste2 to {}
set ll to {}
set len to 0
repeat with w in liste
set ww to w as text
set len to len + 1 + (count of ww)
if len > 256 then
copy (my liste2texte(ll, " ")) to end of liste2
set ll to {ww}
set len to count of ww
else
copy ww to end of ll
end if -- len > 256
end repeat
(* now liste is a list of chunks of text whose length is not higher
than 256 *)
set textDecoupe to my liste2texte(liste2, return & return & "----- cut
here -----" & return & return)
-- =====
on texte2liste(leTexte_, TID)
set AppleScript's text item delimiters to TID
set laListe_ to (text items of leTexte_)
set AppleScript's text item delimiters to ""
return laListe_
end texte2liste
-- =====
on liste2texte(laListe_, TID)
set AppleScript's text item delimiters to TID
set leTexte_ to laListe_ as text
set AppleScript's text item delimiters to ""
return leTexte_
end liste2texte
-- =====
Yvan KOENIG
_______________________________________________
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