Das Notes Forum

Domino 9 und frühere Versionen => Entwicklung => Thema gestartet von: robertpp am 21.02.03 - 14:56:19

Titel: Schleife stoppen
Beitrag von: robertpp am 21.02.03 - 14:56:19
Ich habe eine LScript und möchte aber das nicht alle items durchlaufen werden:

Sub RecordItemValues(Source As NotesUIDocument)
   Dim doc As NotesDocument
   Set doc = source.Document
   Forall i In doc.items
      If i.Name="Status" Then
         itemValues(Ucase(i.Name)) = i.Text         
         Exit Forall         
      End If         
   End Forall
End Sub

Hier hab ich schon eingebaut wenn das Feld "Status" ist dann soll er itemValues ausführen!
Ich hab aber das problem das in ein zweites Feld habe mit dem Namen "Sachbea" und es soll itemValues auch bei diesem Feld ausführen aber ich hat ja beim Feld "Status" die Schleife beendet!
Welche lösung gibt es das er nur nach bestimmten felder sucht?

danke robertpp
Titel: Re:Schleife stoppen
Beitrag von: Rob Green am 21.02.03 - 15:02:56
dann lass zB nen Counter auf 2 hochzählen, so daß die Schleife beim zweiten "Treffer" danach rausfliegt.

If i.Name="Status" Then
         itemValues(Ucase(i.Name)) = i.Text        
counter = counter + 1
if counter >1 then
         Exit Forall        
end if
...

edit: wobei, warum machst Du eigentlich ne Schleife, wenn Du weißt, wie das Feld heißt und welchen Zustand es haben soll? Dazu gibt es doch
flag = notesDocument.HasItem( itemName$ )
Titel: Re:Schleife stoppen
Beitrag von: robertpp am 21.02.03 - 15:06:35
ich glaub so könnte das wirklich funken!!!
ich probiers schnell mal!

robertpp
Titel: Re:Schleife stoppen
Beitrag von: Rob Green am 21.02.03 - 15:07:53
achte nochmal bitte auf mein nachträgliches  "Edit" im obigen Postign, wegen HasItem...ist schneller und einfacher
Titel: Re:Schleife stoppen
Beitrag von: robertpp am 21.02.03 - 15:13:57
was gibt mir nachher das flag zurück?
robertpp
Titel: Re:Schleife stoppen
Beitrag von: Rob Green am 21.02.03 - 16:18:59
mal ein Beispiel aus der Help:

Code
Examples: HasItem method  

  1.   This script displays a message about a document.
Dim doc As NotesDocument
'...set value of doc...
If doc.HasItem( "Subject" ) Then
  Messagebox _
  ( "There is a Subject item on this document." )
Else
  Messagebox _
  ( "There is no Subject item on this document." )
End If
  2.   This example shows how you can use HasItem and AppendItemValue together. Suppose you have a discussion database with Main Topics and Responses. After users have created and saved several documents, you decide that the Response documents should store the original Subject from the Main Topic, as well as their own Subject.
You create an OriginalSubject field on the Response form that inherits its value from the Subject field of the Main Topic. This works nicely, but you still have several Response documents with no value for Original Subject. You write this script to remedy the situation. It uses HasItem to check every Response in the main view of the current database for an item called OriginalSubject. If HasItem returns False, it uses AppendItemValue to create an item called OriginalSubject.
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim mainDoc As NotesDocument
Dim responseDoc As NotesDocument
Set db = session.CurrentDatabase
Set view = db.GetView( "Main View" )
' get the first document in the view, which is a Main Topic
Set mainDoc = view.GetFirstDocument
' visit every Main Topic in the view
While Not ( mainDoc Is Nothing )
  ' get the first response to the Main Topic
  Set responseDoc = view.GetChild( mainDoc )
  ' visit every response to the Main Topic
  While Not ( responseDoc Is Nothing )
    If Not (responseDoc.HasItem("OriginalSubject")) Then
      ' copy the Main Topic's Subject item into the 
      ' Response's OriginalSubject item
      Call responseDoc.AppendItemValue _
      ( "OriginalSubject", _
      mainDoc.GetItemValue( "Subject" ) )
      Call responseDoc.Save( True, False )
    End If
    ' get the next response to the Main Topic
    Set responseDoc = view.GetNextSibling( responseDoc )
  Wend
  ' get the next Main Topic
  Set mainDoc = view.GetNextSibling( mainDoc )
Wend
Titel: Re:Schleife stoppen
Beitrag von: robertpp am 24.02.03 - 09:02:02
Danke für die hilfe!!!
robertpp