Dim sort As New sorter ' sorter is an internal class; its syntax and use can change. Just used to demonstrate how it could work
Dim text As String
Dim words As Variant, uniqueWords List As Integer
Dim sorted As Variant, sortedVals As Variant
Dim count As Integer, scale As Double
Dim hr As rtHRule, cnt as integer

text = doc.getFirstItem("Body").Text
words = Tokenize(text) ' this is just an internal function with limited use - not a part of the product
Forall w In words
 If w<>"," Then
  If Iselement(uniqueWords(Lcase(w))) Then
   uniqueWords(Lcase(w)) = uniqueWords(Lcase(w)) + 1
  Else
   uniqueWords(Lcase(w)) = 1
  End If
 End If
End Forall

sort.SortOrder=False ' descending
Set style = New rtstyle(0)
Set style.Paragraph = New rtParagraphStyle (0)
style.Paragraph.setTab 0, style.Paragraph.FirstLineLeftMargin +3*ONE_CM
Set style.Font = New rtFontStyle (0)
style.Font.FontSize=10
style.Font.Bold = True
style.Font.Typeface="Baskerville"
style.Font.NotesColor=NOTES_COLOR_DKBLUE
style.Paragraph.setTab 5*ONE_CM, TAB_LEFT

cnt = 0
Forall u In uniqueWords
 If u>1 Then
  cnt = cnt + 1
  Print "#" & cnt & " " & Listtag(u) &" (" &u &") "
  Set rtp = New rTextParagraph (Listtag(u) &" (" &u &")" &Chr(9) )
  Set rtp.Style = style
  sort.addObjectNode rtp, u
 End If
End Forall
sorted = sort.getObjectValues
sortedVals = sort.getValues
scale = sortedVals(0)/80
ctxDump.EndInsert
Forall rts In sorted
 Set hr = New rtHRule(Cint(0.6*ONE_CM))
 hr.RuleWidth = sortedVals(count) / scale
 hr.RuleWidth = sortedVals(count) / scale
 hr.fitToWindow=True ' percentage
 Set hr.Color = New rtColor(9)
 hr.Color.setRGB (10000*Rnd) Mod 255, (10000*Rnd) Mod 255, (10000*Rnd) Mod 255
 
 Count = count+1
 rts.hasParagraphBreak = True
 ctxDump.add rts
 ctxDump.add hr
End Forall
|