On *:Start: {
hmake wordcount 1000
if ($isfile(wordcount.hsh)) hload -o wordcount wordcount.hsh
}
alias -l dmdx return $findfile($mircdir,dialog.mdx,1)
alias -l vmdx return $findfile($mircdir,views.mdx,1)
alias -l bmdx return $findfile($mircdir,bars.mdx,1)
alias -l gmdx return $findfile($mircdir,ctl_gen.mdx,1)
alias -l udll return $findfile($mircdir,mdx.dll,1)
alias -l mdx {
if ($isid) dll $udll $1-
elseif ( $2- == $null ) return $dll($udll,$1,.)
return $dll($udll,$1,$2-)
}
dialog wordcount {
title "Word Count"
size -1 -1 214 107
option dbu
list 1,3 3 206 88,size
button "OK", 2, 89 94 36 10, ok
text "",3, 5 96 60 10
menu "&File", 4
menu "&Options",5,4
item "Remove selected line", 6,5
item "Remove Hash File",7,5
item "Clear Dialog Data",8,5
item "Save without closing",11,5
item break, 9,4
item "&Close", 10,4
}
on 1:dialog:wordcount:menu:6: {
if ($did($dname,1).sel) did -d wordcount 1 $did($dname,1).sel
}
on 1:dialog:wordcount:menu:7: {
var %aysywtp = $input(Are you sure you want to proceed $+ $chr(44) $+ $crlf $+ and start your count from scratch?,wd,Caution data will be lost!)
if (%aysywtp == $true) {
echo -a *** Word count set to 0.
if ($hget(wordcount)) hfree wordcount
if ($isfile(wordcount.hsh)) .remove wordcount.hsh
dialog -x wordcount wordcount
}
}
on 1:dialog:wordcount:menu:8: { did -r wordcount 1 }
on 1:dialog:wordcount:menu:10: { dialog -x $dname $dname }
on *:dialog:wordcount:menu:11: { hsave -o wordcount wordcount.hsh }
on *:dialog:wordcount:close:0: { hsave -o wordcount wordcount.hsh }
on *:dialog:wordcount:init:0: {
mdx SetMircVersion $version
mdx MarkDialog $dname
mdx SetControlMDX $dname 1 Listview grid report > $vmdx
did -i $dname 1 1 headerdims 290 100
did -i $dname 1 1 headertext Word List $chr(9) Number of words
did -a $dname 3 Number of words: $hget(wordcount,0).item
var %x = $hget(wordcount,0).item
while (%x) {
did -a $dname 1 1 0 $hget(wordcount,%x).item $+ $chr(9) $+ + 0 0 0 $str($chr(160),13) $hget(wordcount,%x).data
dec %x
}
}
on *:dialog:wordcount:dclick:1:{
echo -a Word: $gettok($gettok($gettok($gettok($did($dname,$did,$did($dname,$did).sel),2-,32),1,9),2-,32),4,32)
echo -a Word number: $calc($did($dname,$did).sel - 1)
}
On *:input:*:{
if (/* iswm $1) { return $1- }
if (!$hget(wordcount)) { hmake wordcount 1000 }
hinc wordcount $*
}
alias wordcount {
if (!$1) && (!$dialog(wordcount)) dialog -dm wordcount wordcount
if ($hget(wordcount,$1)) { echo -a * /count: You have said $1 $hget(wordcount,$1) time(s) }
}