Sub découpe_recherche
'découpage en mot dans une table du texte de recherche
'??? If (DEBUG) Then
'??? TextWindow.WriteLine ("DEBUG/découpe_recherche/texte : " + texte + "/longueur=" + texte_longueur)
'??? EndIf
'extraction des mots du texte de la référence du répertoire
découpe_répertoire()
If répertoire_nombre > 0 Then
'au moins un mot valide pour la référence
If répertoire_nombre > 1 Then
'plus de UN mot alors recherche mots concaténés (=complet)
répertoire_nombre = répertoire_nombre + 1
répertoire_mot[répertoire_nombre] = complet_texte
répertoire_longueur[répertoire_nombre] = complet_position
'??? If (DEBUG) then
'??? TextWindow.Writeline ("DEBUG/découpe_répertoire/COMPLET texte : " + complet_texte + " longueur=" + complet_position)
'??? EndIf
EndIf
valide_position = 0
'recherche de correspondance des mots du répertoire
test_répertoire()
If (valide_position > 0) Then
'au moins un mot correspondant à la recherche
trouvé_nombre = trouvé_nombre + 1
trouvé_référence[trouvé_nombre] = répertoire_référence
trouvé_texte[trouvé_nombre] = répertoire_texte[répertoire_référence]
trouvé_liste[trouvé_nombre] = répertoire_nombre
récupère_mots()
EndIf
EndIf
EndWhile
EndSub
Sub découpe_répertoire
'découpage en mot dans une table du texte du répertoire
If (DEBUG) Then
TextWindow.WriteLine ("DEBUG/découpe_répertoire/référence(" + répertoire_référence + ") : " + texte + "/longueur=" + texte_longueur)
EndIf
'?? If (DEBUG) Then
'?? TextWindow.WriteLine ("DEBUG/découpe_répertoire/caractère : " + caractère + " UNI=" + caractère_unicode)
'?? EndIf
If (caractère_unicode = 0) Or (Text.IsSubText(" *?+-=!#£",caractère)) Then
If caractère_position > 0 Then
If (DEBUG) Then
TextWindow.Writeline ("DEBUG/découpe_répertoire/mot : " + mot + " longueur=" + caractère_position)
EndIf
répertoire_nombre = répertoire_nombre + 1
répertoire_mot[répertoire_nombre] = mot
mot = ""
répertoire_longueur[répertoire_nombre] = caractère_position
caractère_position = 0
EndIf
Else
complet_position = complet_position + 1
complet_texte = Text.Append(complet_texte, caractère)
caractère_position = caractère_position + 1
mot = Text.Append(mot, caractère)
EndIf
EndWhile
If (DEBUG) Then
TextWindow.Writeline ("DEBUG/découpe_répertoire/mot nombre =" + répertoire_nombre)
EndIf
EndSub
Sub test_répertoire
'vérification correspondance du texte du répertoire avec le masque de recherche
répertoire_position = 0
While (répertoire_position < répertoire_nombre)
'pour chaque mot de la référence répertoire
répertoire_position = répertoire_position + 1
recherche_position = 0
valide_nombre[répertoire_position] = 0
While (recherche_position < recherche_nombre)
'pour chaque mot du masque de recherche
recherche_position = recherche_position + 1
If (DEBUG) Then
TextWindow.Writeline ("DEBUG/test_répertoire/mot recherche : " + recherche_mot[recherche_position] + " /répertoire : " + répertoire_mot[répertoire_position])
EndIf
If recherche_mot[recherche_position] = répertoire_mot[répertoire_position] Then
'un mot identique (tous caractères)
ajoute_valide()
Else
'vérification si correspondance des caractères possibles (présence de masque)
masque_mot = recherche_mot[recherche_position]
masque_longueur = recherche_longueur[recherche_position]
texte = répertoire_mot[répertoire_position]
texte_longueur = répertoire_longueur[répertoire_position]
masque_valide = "NON"
If (DEBUG) Then
TextWindow.Writeline ("DEBUG/test_répertoire/masque mot : " + masque_mot + "/longueur=" + masque_longueur + " /texte : " + texte + "/longueur=" + texte_longueur)
EndIf
'vérification du mot (caractère par caractère) selon le masque
controle_mot()
If masque_valide = "OUI" Then
'le mot est valide pour un masque
ajoute_valide()
EndIf
EndIf
EndWhile
EndWhile
EndSub
Sub ajoute_valide
''récupération des indices des mots de recherche valides
If (texte_position < texte_longueur) then
'pour chaque caractère valide du répertoire
texte_position = texte_position + 1
caractère = Text.GetSubText(texte,texte_position,1)
controle_caractère()
Else
'en fin de mot
If (masque_position < masque_longueur) then
'pour caractère restant dans masque
caractère = " "
controle_caractère()
Else
'fin du controle des caractères
valide_caractère ="NON"
EndIf
EndIf
EndWhile
If (DEBUG) Then
TextWindow.WriteLine ("DEBUG/controle_mot/caractère-valide:" + valide_caractère + "-test:" + test_caractère)
EndIf
If (test_caractère = "FAUX") Then
'dernier caractère ne correspond pas
If (masque_strict = "=") Then
masque_valide = "NON"
Goto controle_mot_fin
EndIf
If (masque_strict = "!") Then
masque_valide = "OUI"
Goto controle_mot_fin
EndIf
masque_valide = "NON"
Goto controle_mot_fin
EndIf
'dernier caractère correspond
If (masque_strict = "=") Then
masque_valide = "OUI"
Goto controle_mot_fin
EndIf
If (masque_strict = "!") Then
masque_valide = "NON"
Goto controle_mot_fin
EndIf
masque_valide = "OUI"
controle_mot_fin:
EndSub
Sub controle_caractère
'controle caractère par caractère selon le masque
valide_caractère = "NON"
test_caractère = "FAUX"
If (masque_position < masque_longueur) Then
'pour chaque caractère du masque
masque_position = masque_position + 1
masque_test = Text.GetSubText(masque_mot,masque_position,1)
Else
If (Text.GetSubText(masque_mot,masque_position,1) = "*") then
'fin du masque avec * (caractères quelconque à suivre)
masque_test = "*"
Else
'fin du masque
masque_test = " "
EndIf
EndIf
Sub test_masque
'test caractère spéciaux du masque
If (masque_test = ".") Then
'masque répétition dernier caractère
valide_caractère = "OUI"
masque_test = masque_précédent
texte_position = texte_position - 1
Goto test_masque_fin
EndIf
If (masque_test = "=" Or masque_test = "!") Then
'masque identique ou différent
masque_strict = masque_test
Goto test_masque_fin
EndIf
If (masque_test = "+" Or masque_test = "-") Then
'masque obligatoire ou exclu pour caractère suivant
valide_caractère = "OUI"
masque_précédent = masque_test
Goto test_masque_fin
EndIf
If (masque_test = "*") Then
'masque aucun ou n'importe quel caractère
test_caractère = "VRAI"
test_précédent()
Goto test_masque_fin
EndIf
If (masque_test = "?") Then
'masque n'importe quel caractère
If (caractère = " ") then
test_caractère = "FAUX"
Else
test_caractère = "VRAI
EndIf
test_précédent()
Goto test_masque_fin
EndIf
If (masque_test = "#") Then
'masque chiffre (0 à 9)
If Text.IsSubText ("0123456789",caractère) then
test_caractère = "VRAI"
Else
test_caractère = "FAUX"
EndIf
test_précédent()
Goto test_masque_fin
EndIf
If (masque_test = "£") Then
'masque lettre (alphabet)
If Text.IsSubText ("ABCDEFGHIJKLMNOPQRSTUVWXYZ",caractère) then
test_caractère = "VRAI"
Else
test_caractère = "FAUX"
EndIf
test_précédent()
Goto test_masque_fin
EndIf
'PAS de masque et caractère différent
test_caractère = "FAUX"
test_précédent()
test_masque_fin:
EndSub
Sub récupère_mots
'récupération des mots du répertoires
répertoire_position = 0
While (répertoire_position < trouvé_liste[trouvé_nombre])
'pour chaque mot de la référence valide
répertoire_position = répertoire_position + 1
trouvé_mot[trouvé_nombre][répertoire_position] = répertoire_mot[répertoire_position]
trouvé_longueur[trouvé_nombre][répertoire_position] = répertoire_longueur[répertoire_position]
If (DEBUG) Then
TextWindow.Writeline ("DEBUG/récupère_mots/mot(" + répertoire_position + ") mot:" + répertoire_mot[répertoire_position] + "/longueur=" + répertoire_longueur[répertoire_position])
EndIf
trouvé_valide[trouvé_nombre][répertoire_position] = valide_nombre[répertoire_position]
récupère_valides()
valide_nombre[répertoire_position] = 0
EndWhile
EndSub
Sub récupère_valides
'récupération des correspondance répertoire/recherche
valide_position = 0
While (valide_position < valide_nombre[répertoire_position])
'pour chaque mot valide de la référence
valide_position = valide_position + 1
recherche_position = 0
If (trouvé_nombre = 0) Then
GraphicsWindow.BrushColor = "Red"
Else
GraphicsWindow.BrushColor = "LimeGreen"
EndIf
While (recherche_position < recherche_nombre)
'pour chaque mot recherchés
recherche_position = recherche_position + 1
If (recherche_position > 1) Then
GraphicsWindow.DrawText(colonne_position,ligne_position,",")
colonne_position = colonne_position + caractère_largeur
EndIf
colonne_position = (ligne_début * caractère_largeur)
'premier mot sur nouvelle ligne
ligne_position = ligne_position + ligne_hauteur
répertoire_position = 0
While (répertoire_position < trouvé_liste[trouvé_position])
If (répertoire_position > 0) Then
If (trouvé_valide[trouvé_position][répertoire_position] > 0) Then
'nouvelle ligne pour mot suivant
ligne_position = ligne_position + ligne_hauteur
EndIf
EndIf
'pour chaque mot du répertoire
répertoire_position = répertoire_position + 1
ligne_texte = Text.Append("/",trouvé_mot[trouvé_position][répertoire_position])
If (trouvé_valide[trouvé_position][répertoire_position] > 0) Then