Jump to content

Visual Basic (.NET) programmers.


Removed #5

Recommended Posts

This was fairly straight forward. I've pulled the text data from a font file, and in this routine am searching backwards through an array of designer names looking for a hit on the designer. strString contains the concatenated text from the font file.

Code:


Function SearchDesigner(ByVal strString As String) As String 

  'Dim errMsg As String 

  Dim i As Integer         

  Dim strstrString As String = strString.ToLower         

  If Len(strString) = 0 Then Return ""         

  For i = UBound(arDesigner) - 1 To 0 Step -1             

    Try                 

      If strstrString Like "*" & arDesigner(i, 0) & "*" Then                     

        arDesignerCounter(i) += 1                     

        Return arDesigner(i, 1)                 

      End If             

    Catch e As ArgumentException                 

      'errMsg = String.Format("Line {0} {1} " & vbLf & "Contains an invalid pattern and will be skipped.", i, arDesigner(i, 0))                 

      'MessageBox.Show(errMsg, "Pattern Error", MessageBoxButtons.OK, MessageBoxIcon.Information)             

    End Try         

  Next         

  Return ""     

End Function 

I've just parsed my way through 225,000 font files. Most of the time this works as I expect but upon occasion (1,500 more or less out of the 225,000 files) it doesn't.

For example: strString = "© daisuke sugisawa001.00'"

The array I'm parsing through, in part, looks like:

Quote:

[TABLE]

[TD="class: alt2"] DadoQueiroz Dado Queiroz

Daisuke Monma Daisuke Monma

daisuke sugisawa Daisuke Sugisawa

Dale R. Kramer Dale R Kramer

dale schumacher Dale Schumacher[/TD]

[/TABLE]

It should have been true only on the middle line, since nothing that I can see matches til that point.

and the last three lines of the array look like:

Quote:

[TABLE]

[TD="class: alt2"] Typographer?s Edition (93) Typographers Edition (93)

Typographer?s Edition \(93\) Typographers Edition (93)

Typographer?s Edition (94) Typographers Edition (94)[/TD]

[/TABLE]

Like is returning true ( a match ) on the last line ... and I can't see why. Looking at the other files where I've not had a valid hit it appears as if the paranthesis might be the proble but a paranthesis is a match character to the like operator. Anyone?

By the way, the reason for the backward search is to allow those cases where a name is contained within another name to get hit first. "Paul Roberts" needs to come after "Paul Robertson" (logically) for example - solved easiest by an alphabetical sort and a reverse search.


Edited by Al Jones
Link to comment
Share on other sites

This was fairly straight forward. I've pulled the text data from a font file, and in this routine am searching backwards through an array of designer names looking for a hit on the designer. strString contains the concatenated text from the font file.

Code:


Function SearchDesigner(ByVal strString As String) As String
'Dim errMsg As String
Dim i As Integer
Dim strstrString As String = strString.ToLower
If Len(strString) = 0 Then Return ""
For i = UBound(arDesigner) - 1 To 0 Step -1
Try
If strstrString Like "*" & arDesigner(i, 0) & "*" Then
arDesignerCounter(i) += 1
Return arDesigner(i, 1)
End If
Catch e As ArgumentException
'errMsg = String.Format("Line {0} {1} " & vbLf & "Contains an invalid pattern and will be skipped.", i, arDesigner(i, 0))
'MessageBox.Show(errMsg, "Pattern Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Try
Next
Return ""
End Function
[/CODE]

I've just parsed my way through 225,000 font files. Most of the time this works as I expect but upon occasion (1,500 more or less out of the 225,000 files) it doesn't.

For example: strString = "© daisuke sugisawa001.00'"

The array I'm parsing through, in part, looks like:

Quote:

[TABLE]

[TD="class: alt2"] DadoQueiroz Dado Queiroz

Daisuke Monma Daisuke Monma

[i]daisuke sugisawa[/i] Daisuke Sugisawa

Dale R. Kramer Dale R Kramer

dale schumacher Dale Schumacher[/TD]

[/TABLE]

It should have been true only on the middle line, since nothing that I can see matches til that point.

and the last three lines of the array look like:

Quote:

[TABLE]

[TD="class: alt2"] Typographer?s Edition (93) Typographers Edition (93)

Typographer?s Edition \(93\) Typographers Edition (93)

Typographer?s Edition (94) Typographers Edition (94)[/TD]

[/TABLE]

Like is returning true ( a match ) on the last line ... and I can't see why. Looking at the other files where I've not had a valid hit it appears as if the paranthesis might be the proble but a paranthesis is a match character to the like operator. Anyone?

By the way, the reason for the backward search is to allow those cases where a name is contained within another name to get hit first. "Paul Roberts" needs to come after "Paul Robertson" (logically) for example - solved easiest by an alphabetical sort and a reverse search.

[hr][/hr]

debuggin brb

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy , along with dressing your husky as a unicorn on the first Thursday of each month