Domino 9 und frühere Versionen > ND6: Entwicklung

bestimmten Index eines Arrays löschen

(1/2) > >>

theBastian:
Hi,

ich möchte ein Array prüfen. Falls ein Index mit einem bestimmten Wert beginnt, möchte ich diesen löschen und dann das Arrays neu dimensionieren.


--- Code: ---Dim session As New NotesSession
Dim db As notesdatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim i As Integer
Dim strSoftwareEntry As String
Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments

Set doc = collection.GetFirstDocument()
While Not(doc Is Nothing)

For i = Lbound(doc.Feld) To Ubound(doc.Feld)
strSoftwareEntry = Left$(doc.Feld(i), 9)
If strSoftwareEntry = "Wert" Then _
doc.Feld(i) = ""
Next
Redim doc.Feld(i) As String

Call doc.Save( True, True )

Set doc = collection.GetNextDocument(doc)
Wend
--- Ende Code ---

Leider erhalte ich beim Löschen des Indexes (genauer beim Ändern in "") den Fehler "Illegal use of PROPERTY".

Wißt ihr, warum? Danke schonmal im voraus.

cu
Sebastian

dirk_2909:
Hallo

Du musst alle gültigen werte in ein Array schreiben und anschließend das dem Feld zuweisen;

Dim arrNew( ) as String
dim i as Integer
...
....

While Not(doc Is Nothing)
      i= 0
      Forall strV in doc.Feld
                                   
                                   strSoftwareEntry   = Left$(strV, 9)   
         If strSoftwareEntry <> "Wert" Then
                                                             Redim Preserve arrNew( i )
                                                             arrNew( i ) = strV
                                                             i = i + 1
                                                End if
   
                   End Forall
   
      doc.Feld = arrNew   
      Call doc.Save( True, True )
      
      Set doc = collection.GetNextDocument(doc)
   Wend

Dirk

theBastian:
Danke für die schnelle Antwort.

Redim läuft dann für jeden Index außer denjenigen, der gelöscht werden soll.
Wenn die Schleife mehrmals läuft, ist das bestimmt nicht sonderlich per performant, oder?

Da muss es doch noch eine andere Lösung geben.

cu
Sebastian

koehlerbv:
Ja: Mit @Trim und @Replace in einem Evaluate-Statement.

Bernhard

LN4ever:
Das ist doch eigentlich der "klassische Einzeiler" - auf zwei Zeilen gestreckt, damit nur die Dokumente geändert werden, die das Feld enthalten.

@If(@IsUnavailable(Wertfeld);@Return("");NULL);
FIELD Wertfeld:=@Trim(@Unique(@Replace(Wertfeld;"Wert";"")))

Navigation

[0] Themen-Index

[#] Nächste Seite

Zur normalen Ansicht wechseln