Sorting Text by textStyle.

2008-11-30 Thread Richmond Mathewson
Um, probably reinventing the wheel here. Notwithstanding that, just tried this:

put the number of chars in fld "f1" into XCHARS
  repeat with XX=1 to XCHARS
if the textStyle of char XX of fld "f1" is italic then
  put char XX of fld "f1" after fld "f2"
  end if
  end repeat

where field "f1" contained a large text of which about 50% was italicised.

It worked.

Mind you, still didn't tell me how many paragraphs field "f1" contained.

sincerely, Richmond Mathewson.



A Thorn in the flesh is better than a failed Systems Development Life Cycle.




___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Sorting Text

2007-03-08 Thread Greg Wills
Ahh, this list amazes me with peoples generosity and knowledge. Thank 
you to those who provided an answer. It is much appreciated. I will put 
your suggestions to use in the next few days.


cheers

Greg
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Sorting text

2007-03-07 Thread J. Landman Gay

Simon HARPER wrote:

As an addition to this does the sorting machinery allow frequency counts 
for words in a text field?


The old MetaCard IDE shipped with a very efficient word-counting script 
as one of its examples. Here it is with superfluous stuff removed and 
reformatted as a function:


function wordCount pText
  repeat for each word w in pText
add 1 to wordCount[w]
  end repeat
  put keys(wordCount) into keyWords
  sort keyWords -- optional
  repeat for each line l in keyWords
put l & tab & wordCount[l] & return after tResult
  end repeat
  return tResult
end wordCount

--
Jacqueline Landman Gay | [EMAIL PROTECTED]
HyperActive Software   | http://www.hyperactivesw.com
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Sorting text -- frequency count addition

2007-03-07 Thread Marielle Lange

Hi there,
As an addition to this does the sorting machinery allow frequency  
counts for words in a text field?



on mouseup
  put the text of field 1 into tText
  put replacetext(tText, "[^\w\s]", "") into tText
  put replacetext(tText, "\b\d+\b", "") into tText
  put replacetext(tText, "\s+", " ") into tText
  set the itemdel to " "
  sort items of tText by word 1 of each
  put tText
  put frequencyCount(tText, true) into message
end mouseup

function frequencyCount pText, pCaseSensitive
  if pText is empty then return empty
  
  if pCaseSensitive is true then
put tolower(pText) into pText
   end if
   
  set the itemdel to " "
  repeat with x = 1 to the number of items in pText
put item x of pText into tWord
if tWord is empty then next repeat
if aWordFreq[tWord] is empty then
  put 1 into aWordFreq[tWord]
else
  put aWordFreq[tWord] + 1 into aWordFreq[tWord]
   end if
end repeat
put the keys of aWordFreq into tKeys
put empty into tList
repeat for each line tKey in tKeys
  put tKey && "(" & aWordFreq[tKey] & ")" & cr after tList
end repeat
sort lines of tList by item 1 of each
   -- replace cr with "  " in tList
return tList
  end frequencyCount


Both the sorting and the frequency count functions were typed in 2  
minutes, you may have to tweak them a little to ensure a correct  
behavior.


Best,
Marielle


Marielle Lange (PhD),  http://widged.com
Bite-size Applications for Education





___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Sorting text

2007-03-07 Thread Marielle Lange

Hi Greg,


1. Does anyone have a similar program


If you download SoSmartSoftware excellent revonline picker:

You can look for "user movable fields" or look for "Troutfoot" on  
revonline.


My plan was to shuffle a sentence and get him to click on words to  
paste the word into another text box in the correct order.


Feel free to contact me on list or privately if you need any help on  
this (send me a copy if you post on list as I don't always have the  
time to check out each post on the list).


That's an exercise I need to add to my exercist collection:


To get a better idea of what you are after, in the collection at:   

What is the closest to what you have in mind:  (1) Unscrambel (2)  
Unscramble the sentence  (3) Sentence Reconstruction (4) Mixed-up  
Sentence (5) Fridge Magnets... or something different?



2. Sorting. I am using the "sort" command to sort the words in a  
container from the text field, but they are not sorting. If I  use  
a few lines of text, then these get sorted, but I was under the  
impression that if the line "sort items of holder" (holder as a  
variable) is used, then the words in a container would be sorted.  
But it is not.



on mouseup
  put the text of field 1 into tText
  put replacetext(tText, "[^\w\s]", "") into tText
  put replacetext(tText, "\b\d+\b", "") into tText
  put replacetext(tText, "\s+", " ") into tText
  set the itemdel to " "
  sort items of tText by word 1 of each
  put tText
  put cr & "---" & cr & deleteDuplicates(tText, true) after message
  put cr & "---" & cr & deleteDuplicates(tText, false) after message
end mouseup

function deleteDuplicates pText, pCaseSensitive
  if pText is empty then return empty
  
  if pCaseSensitive is true then
set the casesensitive to true
  else
-- set the casesensitive to false
put tolower(pText) into pText
  end if
  
  set the itemdel to " "
  repeat with x = the number of items in pText down to 2
  if item x of pText = item (x-1) of pText then delete item x of  
pText

  end repeat
  return pText
end deleteDuplicates



The first replacetext will get rid of stuff like "?.:," (\w = word  
character, \s = spacing character; [^xy] = any character but x or y).  
You may want it or not, up to you to see. The second one will get rid  
of any number or sequence of digits on their own (\b = word boundary,  
\d = digit). The third one will replace any sequence of spaces, tabs  
or any other spacing characters with a single space.


You may have or not some use of the second function, to delete  
duplicates within the sorted text (useful to avoid mutiple instances  
of "the", "in", etc.)


Best,
Marielle


Marielle Lange (PhD),  http://widged.com
Bite-size Applications for Education


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Sorting text

2007-03-07 Thread Simon HARPER

Hi there,
As an addition to this does the sorting machinery allow frequency  
counts for words in a text field?



Cheers
Si.


Simon Harper
2.44 Kilburn Building
University of Manchester (UK)

Pri: [EMAIL PROTECTED]
Alt: [EMAIL PROTECTED]


On 7 Mar 2007, at 09:19, Mark Smith wrote:

Greg, you can certainly sort items, but what an item is depends on  
what the global property "the itemDelimiter" is (it defaults to  
comma).


So if you want to sort the words in a container, you might try

set the itemDelimiter to space
sort items of tContainer

You can sort lines and items, but I don't think you can sort words.

Best,

Mark


On 7 Mar 2007, at 09:45, Greg Wills wrote:



2. Sorting. I am using the "sort" command to sort the words in a  
container from the text field, but they are not sorting. If I  use  
a few lines of text, then these get sorted, but I was under the  
impression that if the line "sort items of holder" (holder as a  
variable) is used, then the words in a container would be sorted.  
But it is not.




___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your  
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Sorting text

2007-03-07 Thread Mark Smith
Greg, you can certainly sort items, but what an item is depends on  
what the global property "the itemDelimiter" is (it defaults to comma).


So if you want to sort the words in a container, you might try

set the itemDelimiter to space
sort items of tContainer

You can sort lines and items, but I don't think you can sort words.

Best,

Mark


On 7 Mar 2007, at 09:45, Greg Wills wrote:



2. Sorting. I am using the "sort" command to sort the words in a  
container from the text field, but they are not sorting. If I  use  
a few lines of text, then these get sorted, but I was under the  
impression that if the line "sort items of holder" (holder as a  
variable) is used, then the words in a container would be sorted.  
But it is not.




___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Sorting text

2007-03-07 Thread Greg Wills

Hi All

Has been ages since I have joined this discussion. I am writing a small 
program for a student with Cerebral Palsy who accesses his computer via 
a trackball. He is about to commence a literacy program and I was going 
to knock up a program to enable him to participate.


My plan was to shuffle a sentence and get him to click on words to 
paste the word into another text box in the correct order.


Two questions
1. Does anyone have a similar program - seems no point in reinventing 
the wheel (apart from the fun of it) - that they would like to share.


2. Sorting. I am using the "sort" command to sort the words in a 
container from the text field, but they are not sorting. If I  use a 
few lines of text, then these get sorted, but I was under the 
impression that if the line "sort items of holder" (holder as a 
variable) is used, then the words in a container would be sorted. But 
it is not.


Any suggestions or comments will be greatly received.

cheers

Greg Wills
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution