2014-04-28 54 views
0

我想按lotusscript中的字段值(字符串)排序字段值(字符串)。 有没有人有想法来解决这个问题?Lotusscript:如何按字段排序字段值(字数组)

非常感谢。

+2

你尝试了什么?这不是一个完整解决方案的平台,而是帮助您解决自己的特定问题。请告诉我们,你自己做了哪些努力来解决问题,这使得人们更有可能回答你的问题... –

+0

只是为了给你一点启动的帮助:[Here](http:// searchdomino.techtarget.com/tip/Counting-unique-elements-in-a-text-list)是一种很酷的方式,可以在Formula中使用它...当然,这在LotusScript中完全不起作用,但它仍然很酷;) –

+0

我不认为你已经清楚地问过这个问题。我怀疑西蒙和托斯滕都误解了你想要的东西。是否在一个文档中有一个多值字段,其中包含具有一些重复项的单词列表,并且您希望按字母顺序对这些值进行排序,但是根据有多少重复项进行排序,以便列表c,d, b,a,a,b,a,a被重新排序a,a,a,a,b,b,c,d? –

回答

0

就个人而言,我会避免LotusScript,如果你可以帮助它。你将遇到limitations,这是无法解决的。

无论您采取哪条路线,从性能角度来看,最好让View索引完成工作。

所以你会创建一个视图。第一列如下。

  • 列值:您要检查的字段。
  • 排序:升序
  • 类型:分类的

这之后您可以使用NotesViewNavigator访问数据。相关的方法调用是getNextCategory。这会给你一个视图条目对象,你可以调用ChildCount来获得总数。

例如(声明:代码从存储器写入,不能保证运行):

Dim sess As New NotesSession 
Dim db As NotesDatabase 
Dim vw As NotesView 
Dim nav as NotesViewNavigator 
Dim entryA As NotesViewEntry 
Dim entryB As NotesViewEntry  

Set db = sess.CurrentDatabase 

Set vw = db.GetView("testView") 

vw.AutoUpdate = False 

Set nav = vw.CreateViewNav 

Set entryA = nav.GetFirst 
while entryA not Nothing 
    Set entryB = nav.GetNextCategory(entryA) 
    if entryB not nothing then 

     ' Do your processing. 
     ' entryB.childCount will give total. 

    end if 

    set EntryA = EntryB 

Wend 

view.AutoUpdate = True 

这样繁重(字符串排序,计数)由查看索引处理。所以你只需要处理最终结果。

0

直接回答运算的(旧)的问题,在LotusScript中要做到这一点的方法是既简单又方便:

dim para as string 
dim words as variant 
dim fq list as long 

'get the text to freq-count 
para = doc.text '(or $ from somewhere) 
'tidy up para by removing/replacing characters you don't want 
para = replace(para, split(". , : ; - [ ]()"), "") 
words = split(para) 'or split(words, "delim") - default is space 
forall w in words 
if iselement(words(w)) then 
    fq(w) = fq(w) + 1 
Else 
    fq(w) = 1 
End forall 
'you now have a count of each individual word in the FQ list 

'to get the words out and the word frequencies (not sorted): 
forall x in fq 
    print listtag(x) = x 
End forall 

完蛋了。 LotusScript没有问题 - 快速简单(和列表可以很大)。要得到一个排序列表,你必须移动到一个数组并对其进行排序或移动到一个字段,让@sort以某种方式完成这项工作。