I have two string,must be split matching,and need 100% the same count matches,how do this? Thanks a lot for help
string A(Reply)
"01: 2"
"02: 2; 3"
"03: 3; 4"
"04: 3"
"05: 2; 4"
"06: 3"
"07: 2; 3"
"08: 2; 4"
string B(Answer)
"01: 2"
"02: 2"
"03: 3; 4"
"04: 3"
"05: 2; 4"
"06: 3"
"07: 2"
"08: 2; 4"
result
(Reply)"01: 2" (Answer)"01: 2" =right
(Reply)"02: 2; 3" (Answer)"02: 2" =wrong
.
.
.
.
count matches=6
Your question is still quite hard to understand.
This is what I understand:
You have a document with two multi value fields and want to compare these and count the "equal" values:
Field A(reply) | Field B(answer) | Equal? |
---|---|---|
01: 2 | 01: 2 | equal |
02: 2; 3 | 02: 2 | |
03: 3; 4 | 03: 3; 4 | equal |
04: 3 | 04: 3 | equal |
05: 2; 4 | 05: 2; 4 | equal |
06: 3 | 06: 3 | equal |
07: 2; 3 | 07: 2 | |
08: 2; 4 | 08: 2; 4 | equal |
-------------- | --------------- | ------ |
Count | 6 |
In that case a simple For- loop can help:
Dim doc as NotesDocument
Dim fieldA as Variant
Dim fieldB as Variant
Dim i as Integer
Dim count as Integer
'- somehow get your doc
Set doc = ....
fieldA = doc.GetItemValue( "reply" )
fieldB = doc.GetItemValue( "answer" )
For i = 0 to ubound( fieldA )
If ubound( fieldB ) >= i Then
If fieldA(i) = fieldB(i) Then
count = count + 1
End If
End If
Next
Messagebox count & " equal lines found."
This whole thing seems to be to evaluate a test: In one field there are the correct answers and in the other the answers the person gave, and you want to know how many correct answers they gave...
Take care: If you save the correct answers directly in the document, then people can use Alt + Enter to look at the field properties and simply read out the correct answers from the fields and cheat like that.
If you are looking for a solution without writing LotusScript, you could add a computed field e.g. "CountRightAnswers" with the following formula:
_numReplies := @Elements( reply );
_wrongAnswers := @Trim( @Replace( reply; answer ; "" ) );
_numWrongAnswers := @Elements( _wrongAnswers );
_numReplies - _numWrongAnswers
What does this do: