2016-09-02 11 views
0

Lotus Notes内にデータベースがあり、指定されたフォーム名が選択されるまで、すべてのフォームをループするLotusScriptを作成しようとしています。指定したフォーム名を選択したら、残りのコードを実行します。ロータスノーツ - lotusscript指定された値までループを返す

基本的に、私は以下

Forall Form In db.Forms 
For form.name <> "Server Information" 
    Next form 
(loop until "Server Information) 
...... (rest of code) 

End Forall 

をやろうとしていますと、私が働いている完全なコードです。

Sub Initialize 

    Dim session As New NotesSession 
    Dim db As NotesDatabase 
    Dim fileName As String 
    Dim fileNum As Integer 
    Dim headerstring As String 
    Dim values As String 
    Dim selection As String 
    Dim collection As NotesDocumentCollection 
    Dim doc As notesdocument 
    Dim exportField List As String 

    On Error Resume Next 

    exportField("ServerName_5") = "ServerName_5" 

    Set db = session.CurrentDatabase 


    Forall Form In db.Forms 
     'I WANT TO SKIP ALL FORM NAMES UNTIL "Server Information" is the current or selected form 
     'Once the entire loop is complete I don't to go to the next form 
     If Isempty(form.Fields) Then 
      Messagebox form.Name & " has no fields" 
     Else 
      If form.Name = "Server Information" Then    
       fieldCount = 0 
       msgString = "" 
       fileNum% = Freefile() 
       fileName$ = "c:\temp\" & form.Name & ".csv" 
       Open FileName$ For Output As fileNum% 

       Forall field In form.Fields 
        If Iselement(exportField(field)) Then     
         msgString = msgString & Chr(10) & _ 
         "" & field 
         fieldCount = fieldCount + 1 
         headerstring=headerstring & |"| &field &|",| 
        End If 
       End Forall 

       Write #fileNum%, |",| & headerstring & |"| 
       headerstring="" 
      Else 
      End If 



     End If 



     selection = |Form="| & form.Name & |"| 
     Set collection=db.Search(selection, Nothing, 0) 

     For x = 1 To collection.count 
      Set doc =collection.GetNthDocument(x) 
      values="" 
      Forall formfield In form.Fields 
       If Iselement(exportField(formfield)) Then 
        newvalue=doc.GetItemValue(formfield) 
        values=values & |"| & Cstr(newvalue(0)) & |",| 
       End If 
      End Forall 

      Write #fileNum%, |",| & values &|"| 
      values="" 
     Next 

'now check aliases 
     If Isempty(form.Aliases) Then 
'Messagebox form.Name & " has no aliases" 
     Else 
      Forall aliaz In form.Aliases 
       If aliaz = form.Name Then 
        Goto NextAliaz 'alias is same as form name 
       End If 
       selection = |Form="| & aliaz & |"| 
       Set collection=db.Search(selection, Nothing, 0) 

       For x = 1 To collection.count 
        Set doc =collection.GetNthDocument(x) 
        values="" 
        Forall formfield In form.Fields 
         If Iselement(exportField(formfield)) Then 
          newvalue=doc.GetItemValue(formfield) 
          values=values & |"| & Cstr(newvalue(0)) & |",| 
         End If 
        End Forall 

        Write #fileNum%, |",| & values &|"| 
        values="" 
NextAliaz: 
       Next 
      End Forall 
     End If 

     Close fileNum% 
    End Forall 

End Sub 
+0

あなたは正確に何をしようとしていますか?フォームフィールドをヘッダー行として入力し、サーバー情報フォームを含むドキュメントをCSVにエクスポートしますか?これらのドキュメントのServerName_5フィールドのみをファイルに書き出しますか? "isElement()"全体がドキュメントにそのフィールドがあるかどうかを調べることですか? – Duston

+0

あなたの質問は何ですか?コードを実行するとどうなりますか?そして、あなたが起こると予想されることは起こりません。具体的にしてください。 –

答えて

1

まず、私はhow to fishを教えてあげます。

速く、限り、あなたは、古典的なノート者協会の領域に残るように簡単漁業技術:Help\help85_designer.nsf(バージョン9である場合、IBMのWebサイトからまたはhereからそれを得る)

その後、ここにあなたの魚があります今日のために。

しかし、これには、恐ろしい無限ループの古典的な危険性があります。望ましい状態には至らない可能性があります。

NotesDatabaseクラスのgetForm()メソッドを使用することをお勧めします。 LotusScriptのオブジェクト指向機能と、既成のDomino APIの組み込みクラスを力と表現力で過小評価しないでください。

関連する問題