Attribute VB_Name = "Engine" ''Here is the engine of the program! Public Sub Calculate() 'On Error Resume Next ResetP1 ''These P's are process bars, ignore ''Every object is placed on the WINDOW ''DATA is the input textbox If Len(Window.xData.Text) > 0 Then ''Fix DATA If Not Right$(Window.xData.Text, 1) = "!" Then Window.xData.Text = Window.xData.Text + "!" tmp$ = "" For x = 1 To Len(Window.xData.Text) If Mid$(Window.xData.Text, x, 1) = " " Then tmp$ = tmp$ + "_" Else tmp$ = tmp$ + Mid$(Window.xData.Text, x, 1) Next x Window.xData.Text = tmp$ Window.xData.Refresh StepP2 ResetP1 ''Get all patterns Window.Patterns.Clear If Window.HTMLCheck.Value = 0 Then Window.P1.Min = 1 Window.P1.Max = Len(Window.xData.Text) For x = 1 To Len(Window.xData.Text) i = Len(Window.xData.Text) - x If Window.Limit1 = 1 Then i = 1 For y = 1 To i ''PATTERNS is the listbox object titled "Patterns" Window.Patterns.AddItem Mid$(Window.xData.Text, x, y) Next y Window.P1.Value = x Next x Else ''Zastavica ''Isolate the tags For x = 1 To Len(Window.xData.Text) e = Mid$(Window.xData.Text, x, 1) Select Case e Case "<": Rec = True: m$ = "" Case ">": Rec = False: Window.TagList.AddItem m$ Case Else If Rec Then m$ = m$ + e End Select Next x ''Find all sequences within the tags only Window.P1.Min = 0 Window.P1.Max = Window.TagList.ListCount - 1 For x = 0 To Window.TagList.ListCount - 1 i = Len(Window.xData.Text) - x For y = 0 To i s$ = "" For z = x To y s$ = s$ + "<" + Window.TagList.List(z) + ">" Next z Window.Patterns.AddItem s$ Next y Window.P1.Value = x Next x End If Window.Patterns.Refresh StepP2 ResetP1 ''Find repeating patterns ''This is all about scaning PATTERNS, finding the ones that repeat there and placing to RPPATTERNS only those that are not here yet. ''RPPATTERNS is a listbox object titiled "Repeating Patterns" Dim Found As Boolean Window.RpPatterns.Clear Window.P1.Min = 0 Window.P1.Max = Window.Patterns.ListCount - 1 For x = 0 To Window.Patterns.ListCount - 1 Window.Patterns.Selected(x) = True For y = 0 To Window.Patterns.ListCount - 1 If x <> y And Window.Patterns.List(x) = Window.Patterns.List(y) Then Found = False For z = 0 To Window.RpPatterns.ListCount - 1 If Window.RpPatterns.List(z) = Window.Patterns.List(y) Then Found = True Next z If Not Found Then Window.RpPatterns.AddItem Window.Patterns.List(x) Window.RpPatterns.Refresh Window.RpPatterns.Selected(Window.RpPatterns.ListCount - 1) = True End If End If Next y Window.P1.Value = x Next x StepP2 ResetP1 ''Sort repeating patterns by size ''This is a standard sort procedure If Window.RpPatterns.ListCount > 1 Then Window.P1.Min = 0 Window.P1.Max = Window.RpPatterns.ListCount - 1 For x = 0 To Window.RpPatterns.ListCount - 1 Window.RpPatterns.Selected(x) = True For y = 0 To Window.RpPatterns.ListCount - 1 ''Sort direction determinet by the option settings on the WINDOW If (Len(Window.RpPatterns.List(x)) < Len(Window.RpPatterns.List(y)) And Window.Smallest) Or (Len(Window.RpPatterns.List(x)) > Len(Window.RpPatterns.List(y)) And Window.Biggest) Then tmp2 = Window.RpPatterns.List(x) tmp3 = Window.RpPatterns.List(y) Window.RpPatterns.List(x) = tmp3 Window.RpPatterns.List(y) = tmp2 Window.RpPatterns.Refresh End If Next y Window.P1.Value = x Next x End If StepP2 ResetP1 ''Find exceptions ''This is to fill EXCEP, RKEYS and USE ''EXCEP is a textbox object titled "Exceptions" ''RKEYS is a textbox object titled "Return keys" ''USE is a listbox object titled "Usefull patterns" ''You're probably only looking for the value of RKEYS, so note that the others are required to determine it! Window.RKeys.Text = "" Dim Used As Boolean tmp$ = Window.xData.Text Window.P1.Min = 0 tmp4 = Window.RpPatterns.ListCount - 1 If tmp4 < 1 Then tmp4 = 1 Window.P1.Max = tmp4 Window.Use.Clear For x = 0 To Window.RpPatterns.ListCount - 1 Window.RpPatterns.Selected(x) = True Used = False d$ = Window.RpPatterns.List(x) 5 i = InStr(tmp$, d$) If i > 0 Then Mid$(tmp$, i, Len(d$)) = String$(Len(d$), "*") Window.Excep.Text = tmp$ Window.Excep.Refresh Used = True GoTo 5 End If If Used Then Window.Use.AddItem d$: Window.RKeys.Text = Window.RKeys.Text + d$ Window.P1.Value = x Next x Window.Excep.Text = tmp$ StepP2 End If Window.P1.Value = Window.P1.Min Window.P2.Value = Window.P2.Min End Sub ''Procedures for progress bars from here on... Private Sub ResetP1() Window.P1.Min = 0 Window.P1.Max = 100 End Sub Private Sub StepP2() If Window.P2.Value + 1 > Window.P1.Max Then Window.P2.Max = Window.P2.Value + 1 Window.P2.Value = Window.P2.Value + 1 End Sub