2014-04-28 82 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以某種方式完成這項工作。