Welcome to MacForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Appleworks text script question

 
   Macintosh computer (Home) -> Apple Scripts RSS
Next:  Deleting data item from data source  
Author Message
Nathan Olson

External


Since: May 16, 2004
Posts: 3



(Msg. 1) Posted: Mon May 17, 2004 2:19 am
Post subject: Appleworks text script question
Archived from groups: alt>comp>lang>applescript (more info?)

I'm trying to delete multiple paragraphs in Appleworks. The following script
works, but seems a bit kludgy. I'd like to use a whose statement that
checked for every occurrence of two consecutive paragraphs. But

every character whose it contains return & return

doesn't work. Neither does paragraph. What am I missing?

Thanks in advance,
Nate Olson
<nolson66.RemoveThis@comcast.net>




tell application "AppleWorks"
set returnChar to (ASCII character 13)
tell text body of front document
try
set allReturns to offset of (every character whose it
contains returnChar)
if class of allReturns is not list then set allReturns to {}
repeat with i from (count of items of allReturns) to 2 by -1
set thisReturn to (item i of allReturns)
set prevReturn to (item (i - 1) of allReturns)
if (thisReturn - prevReturn) = 1 then ¬
delete (character (item i of allReturns))
end repeat
end try
end tell
end tell

 >> Stay informed about: Appleworks text script question 
Back to top
Login to vote
Michelle Steiner

External


Since: Jul 15, 2003
Posts: 4215



(Msg. 2) Posted: Mon May 17, 2004 2:35 am
Post subject: Re: Appleworks text script question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <BCCDA796.12470%nolson66@comcast.net>,
Nathan Olson <nolson66.DeleteThis@comcast.net> wrote:

 > I'm trying to delete multiple paragraphs in Appleworks. The following script
 > works, but seems a bit kludgy. I'd like to use a whose statement that
 > checked for every occurrence of two consecutive paragraphs. But
 >
 > every character whose it contains return & return
 >
 > doesn't work. Neither does paragraph. What am I missing?

By "delete multiple paragraphs," do you mean that you want to make all
the paragraphs into one paragraph? If that's the case, this should do
it for you:

tell application "AppleWorks 6"
tell text body of front document
set temp to paragraph 1
repeat with loop from 2 to count of paragraphs
set temp to temp & paragraph loop of paragraphs
end repeat
end tell
end tell

A paragraph is a block of text beginning with the start of the file or
the first character after a carriage return, and ending with a carriage
return or the end of the file.

I don't understand what you mean by "two consecutive paragraphs."

--
Stop Mad Cowboy Disease: Vote for John Kerry.<!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: Appleworks text script question 
Back to top
Login to vote
Nathan Olson

External


Since: May 16, 2004
Posts: 3



(Msg. 3) Posted: Mon May 17, 2004 11:11 am
Post subject: Re: Appleworks text script question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

My apologies. What I mean is I want to delete blank paragraphs -- those
paragraphs that contain no text, only returns. I think I tried to search for
those paragraphs that are equal to ASCII character 13, but that didn't work.

Nate Olson



On 5/16/04 11:35 PM, in article
michelle-06257E.23351416052004.TakeThisOut@news.west.cox.net, "Michelle Steiner"
<michelle.TakeThisOut@michelle.org> wrote:

 > In article <BCCDA796.12470%nolson66@comcast.net>,
 > Nathan Olson <nolson66.TakeThisOut@comcast.net> wrote:
 >
  >> I'm trying to delete multiple paragraphs in Appleworks. The following script
  >> works, but seems a bit kludgy. I'd like to use a whose statement that
  >> checked for every occurrence of two consecutive paragraphs. But
  >>
  >> every character whose it contains return & return
  >>
  >> doesn't work. Neither does paragraph. What am I missing?
 >
 > By "delete multiple paragraphs," do you mean that you want to make all
 > the paragraphs into one paragraph? If that's the case, this should do
 > it for you:
 >
 > tell application "AppleWorks 6"
 > tell text body of front document
 > set temp to paragraph 1
 > repeat with loop from 2 to count of paragraphs
 > set temp to temp & paragraph loop of paragraphs
 > end repeat
 > end tell
 > end tell
 >
 > A paragraph is a block of text beginning with the start of the file or
 > the first character after a carriage return, and ending with a carriage
 > return or the end of the file.
 >
 > I don't understand what you mean by "two consecutive paragraphs."<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Appleworks text script question 
Back to top
Login to vote
Michelle Steiner

External


Since: Jul 15, 2003
Posts: 4215



(Msg. 4) Posted: Mon May 17, 2004 11:47 am
Post subject: Re: Appleworks text script question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <BCCE241D.125A6%nolson66@comcast.net>,
Nathan Olson <nolson66.DeleteThis@comcast.net> wrote:

 > My apologies. What I mean is I want to delete blank paragraphs -- those
 > paragraphs that contain no text, only returns. I think I tried to search for
 > those paragraphs that are equal to ASCII character 13, but that didn't work.

This might be of some help; it returns the paragraphs that are not blank:

tell application "AppleWorks 6"
tell text body of front document
set Paras to paragraphs whose length is not 0
end tell
end tell

-- Michelle

--
Stop Mad Cowboy Disease: Vote for John Kerry.<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Appleworks text script question 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
10.5 change to unicode text causes AppleWorks problems - I have a longstanding AppleScript Studio tool which uses AppleScript Studio to draw a drawing in AppleWorks, then save the results as a .png or ..pict file. It did this using a line like the following -- ... -- code to tell AppleWorks 6 to open a Drawin...

Script to convert word docs to text files - Hello, I have hundreds of word docs that I want to import into filemaker pro (the text of the docs). Filemaker has an import option that enables you to import text files, but not word documents. I cant seem to get it to work, any ideas? Is this the righ...

Script editor question - How do I accept the Script Editor suggestions that appear as I type text that matches possible Apple Script keywords? For example, if I start a tell block, when I type "tell app", the remainder of "lication" appears faintly.

totally naive question re: PowerPC to Universal script con.. - So, I have a simple script that was made as a PowerPC application. Because of a stupid, silly haxie I have running that only like Universal apps I would like to have the script be a UB. Is there some easy way for me to make it be a UB? I wishfully..

Question about replacing a Macro in Word 2008 with an Appl.. - Hello, Although I've had a Mac for a few years now, I've never delved into Apple script. I find myself needing to start from scratch to replace a Macro in Word 2008 (MS eliminated VBA from this new version of Office - that's another story for another..
   Macintosh computer (Home) -> Apple Scripts All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]