Code: Select all
Sub compare
'user is the users input
'break here if a string has already been compared for this lyric
'No retrying!
If scorer.score(lcount) <> 0 Then
user = ""
return
EndIf
Dim As Integer g
'perfect
If UCase(user) = UCase(cursong.lyricarray(lcount)) Then
scorer.score(lcount) = (100 * Len(cursong.lyricarray(lcount))) + 500 ' perfect bonus
scorer.grade(lcount) = "1"
score+= scorer.score(lcount)
Else
'compare per letter
For p As Integer = 1 To Len(cursong.lyricarray(lcount))
If Right(Left(user,p),1) = Right(Left(cursong.lyricarray(lcount),p),1) Then
scorer.score(lcount)+ = 100
EndIf
Next
score+=scorer.score(lcount)
scorer.grade(lcount) = Str( (scorer.score(lcount)/100)/Len(cursong.lyricarray(lcount)))
EndIf
user = ""
End Sub
Now this will obviously match perfect matches. But here are some cases and what I'd like to happen:
cursong.lyricarray(lcount) = "concession"
_______________________________
user = "concession"
100% match: This works in my code
user = "condfsdfds"
40% match: this works in my code
user = "conchghession"
100% match, but I would add a penalty for the extra letters: This does not work in my code
user = "codfdsncesfdsfdikosn"
100% match again, - big penalty for extra letters: this does not work in my code
user = "confgfession"
90% match, this one I have no idea how to catch, explained below
So I know how to get the first two cases, for case three and four, I could just check for each letter in order, discarding incorrect ones. But for case 5, there is no second C, so that would not produce the output I want. Sorry to ask this again, but I am just not following this one hehe.
~Blyss