Das Notes Forum

Domino 9 und frühere Versionen => ND6: Entwicklung => Thema gestartet von: BennyB am 13.06.05 - 09:03:25

Titel: Anfängerprob. Typemismatch in If
Beitrag von: BennyB am 13.06.05 - 09:03:25
Ich habe eine Ansicht, eine Spalte hat folgende Werte:

@If(
Newsletter = "Newsletter"; "X";
"")


Nun hab ich eine Aktion, die mir diesen Wert wenn er "gesetzt" ist nicht setzten soll und anders herum.

Code
Sub Click(Source As Button)
	
	Dim session As New NotesSession
	Dim db As NotesDatabase
	Dim dc As NotesDocumentCollection
	Dim doc As NotesDocument
	
	Set db = session.CurrentDatabase
	Set dc = db.UnprocessedDocuments
	Set doc = dc.GetFirstDocument
	
	While Not (doc Is Nothing)
		
		If (doc.Newsletter = "") Then
			doc.Newsletter = "Newsletter"
		Else
			doc.Newsletter = ""
		End If
		
		doc.Save True, True, True
		
		Set doc = dc.GetNextDocument(doc)
	Wend
	
	Dim workspace As New NotesUIWorkspace
	Call workspace.ViewRefresh
	
End Sub

Die If-Anweisung bringt die Fehlermeldung Type Mismatch, ich hab keine Ahnung warum. Ich kenne mich zu wenig aus mit NotesScript habe in der HIlfe gesucht jedoch nichts passendes gefunden. Logischerweiße finde ich sollte es gehn, sind ja beides Texte wie verglichen werden.
Bitte um Denkanstöße, DANKE

Grüßer Benny
Titel: Re: Anfängerprob. Typemismatch in If
Beitrag von: Glombi am 13.06.05 - 09:05:19
Es muss

If (doc.Newsletter(0) = "") Then

heissen.

Andreas
Titel: Re: Anfängerprob. Typemismatch in If
Beitrag von: BennyB am 13.06.05 - 09:56:59
Warum muss ich bei der Abfrage die (0) und bei der Zuweißung keine (0) angeben?
Titel: Re: Anfängerprob. Typemismatch in If
Beitrag von: umi am 13.06.05 - 10:02:16
Bei der Abfrage erhälst Du automatisch immer einen Array.
Du setzt auch immer einen Array. Ein Integer zum Bleistift ist immer ein Array mit 1 Element vom Typ Integer.

gruss
umi
Titel: Re: Anfängerprob. Typemismatch in If
Beitrag von: Glombi am 13.06.05 - 10:02:51
Aus der Hilfe:

valueArray = notesDocument.GetItemValue( itemName$ )
Parameters
itemName$
String. The name of an item.
Return value
value
The value or values contained in the specified name. The data type of the value depends on the data type of the item.
   Notes item type   Value return type
   Rich text   Array of strings. The text in the item, rendered into plain text
   Text or text list (includes Names, Authors, and Readers item types)   Array of strings
   Number or number list   Array of doubles
   Date-time or range of date-time values   Array of variants of type Date
When GetItemValue returns an array, each element in the array corresponds to a value in the item. If the item contains a single value, the array has just one element.
Usage
If multiple items have the same name, this method returns the value of the first item.
For text, number, and time-date items, GetItemValue always returns an array, even when there is only a single value in the item. If you know the item contains only a single value, access the first element in the array, which is at index 0. If you know the item contains multiple values, but you don't know how many, iterate over the array elements using the Forall statement.
To get a date-time value as an array of NotesDateTime and NotesDateRange objects, see GetItemValueDateTimeArray.
"Extended class" syntax
You can also access the contents of an item directly, without using GetItemValue. The following two statements are equivalent:
t = lastDoc.GetItemValue( "Topic" )
t = lastDoc.Topic
This syntax lets you access and modify items the same way you access and modify other NotesDocument properties. The return value is the same, that is, an array of values for text, number, or time-date items, and a string for rich text items.
You can set the value of an item with this syntax, too:
mailMemo.Subject = "Update on stock options"
Call mailMemo.Save( False, True )
For more information about setting an item value with this syntax, see the AppendItemValue and ReplaceItemValue methods.