Je ne pige pas vraiment son fonctionnement, et surtout, je n'arrive pas à l'adapter.
Si j'ai bien compris, le
sert à rechercher le caractère de search jusqu'à un espace ?
Voilà mon code, un texte est automatiquement inscrit dans l'editor, ce texte contient 3 liens web dont 2 .zip et 1 .com
search ="
http:"
Lorsque l'on clique sur GO, l'imputrequester demande ce qu'on cherche,
je veux que lorsqu'on tape .zip par exemple, qu'il affiche les 2 liens
http://..........zip (et pas le dernier .com)
Code : Tout sélectionner
Enumeration
#ARS
#Affiche
#BT_Gaz
#BT_Copy
#BT_Ferme
#BT_Clear
#BT_Min
#Font_Affiche
EndEnumeration
Declare sort()
Global Dim mot$(255) ; mots a rechercher
Global Dim posi(255,255) ; position ou les mots on ete trouve
Global Dim pos(255) ; pour chaque mots combien de positions on ete trouvées
Global word,occ$
a$=""
Procedure OpenWindow_ARS()
If OpenWindow(#ARS, 142, 341, 525, 371, "Chercheur par Ar-S", #PB_Window_SystemMenu|#PB_Window_TitleBar)
If CreateGadgetList(WindowID(#ARS))
EditorGadget(#Affiche, 3, 40, 520, 310)
SetGadgetText(#Affiche,"http://momodd/54152312/mohairbo.zip456sszsdhttp://unautrelien.com/unrepertoire/fichier.zipt22dzzzz24http://dernierlien.com")
ButtonGadget(#BT_Copy, 3, 350, 519, 20, "Copy", #BS_FLAT)
ButtonGadget(#BT_Gaz, 3, 5, 165, 30, "GO", #BS_FLAT)
ButtonGadget(#BT_Ferme, 508, 1, 15, 15, "X", #BS_FLAT)
ButtonGadget(#BT_Min, 492, 1, 15, 15, "-", #BS_FLAT)
ButtonGadget(#BT_Clear, 170, 5, 165, 30, "Clear", #BS_FLAT)
; Gadget Fonts
SetGadgetFont(#Affiche, LoadFont(#Font_Affiche, "Arial", 9, 0))
; Gadget Colors
PureCOLOR_SetGadgetColor(#Affiche, $40FF00, $0)
PureCOLOR_SetButtonColor(#BT_Copy, #PureCOLOR_SystemColor, $2CD1EF)
PureCOLOR_SetButtonColor(#BT_Gaz, #PureCOLOR_SystemColor, $A9FCF5)
PureCOLOR_SetButtonColor(#BT_Ferme, #PureCOLOR_SystemColor, $A9FCF5)
PureCOLOR_SetButtonColor(#BT_Min, #PureCOLOR_SystemColor, $A9FCF5)
PureCOLOR_SetButtonColor(#BT_Clear, #PureCOLOR_SystemColor, $A9FCF5)
; Window Backcolor
PureCOLOR_SetWindowColor(#ARS, $B9FAFD)
EndIf
EndIf
EndProcedure
Procedure sort()
For m=0 To word
totalpos=totalpos+pos(m) ;totalise les occurence trouvées
Next
; SetGadgetText(#Affiche,Str(totalpos)+Chr(10))
occ$=""
lastpos=0 ; derniere position dans la chaine
minpos=999999999
Repeat
minpos=999999999
For m=0 To word
For ocur=1 To pos(m)
If posi(m,ocur)>lastpos ; la position de l'ocurence actuelle est plus lointaine que la derniere occurence placee dans la chaine
If posi(m,ocur)<minpos ; l'ocurence est la plus petite trouvee pour l'instant ou c'est la premiere trouvée
minpos=posi(m,ocur) ; on la defini comme position la plus basse
toadd$=Chr(m+1)+Chr(ocur+1) ; on defini l'ajout a la chaine (+1 for non null characters)
EndIf
EndIf
Next
Next
lastpos=minpos
occ$=occ$+toadd$
Until Len(occ$)=totalpos*2
EndProcedure
OpenWindow_ARS()
;{- Event loop
Repeat
Event = WaitWindowEvent()
Select Event
; ///////////////////
Case #PB_Event_Gadget
EventGadget = EventGadget()
EventType = EventType()
If EventGadget = #Affiche
ElseIf EventGadget = #BT_Copy
ElseIf EventGadget = #BT_Gaz
search$=InputRequester("Question","caractère à trouver","")
st=0
a$ = GetGadgetText(#Affiche)
If a$
Repeat
fnd=FindString(a$," http",st)
If fnd
mot$(word)=Mid(a$,st,fnd-st)
MessageRequester("01",mot$(word))
word=word+1
st=fnd+1
Else
MessageRequester("blop","ça chie")
EndIf
Until fnd=0
mot$(word)=Mid(a$,st,Len(a$)-(st-1))
MessageRequester("02",mot$(word))
; recherche les mots
For m=0 To word
st=1 ; on met le depart de la recherche a 0
fnd=0
p=0
Repeat
fnd=FindString(a$,mot$(m),st)
If fnd
p=p+1
posi(m,p)=fnd
st=fnd+1
EndIf
Until fnd=0
pos(m)=p
Next
sort()
For a= 1 To Len(occ$) Step 2
occ2$=occ2$+Mid(occ$,a,1) ; cree une chaine contenant uniquement les mots dans l'ordre sans leur positions
Next
; cree le masque de recherche
For a=0 To word
tofind$=tofind$+Chr(a+1)
Next
st=0
; End
Else
MessageRequester("Information", "Vide.", 0)
EndIf
ElseIf EventGadget = #BT_Ferme
End
ElseIf EventGadget = #BT_Min
ElseIf EventGadget = #BT_Clear
SetGadgetText(#Affiche," ")
EndIf
; ////////////////////////
Case #PB_Event_CloseWindow
EventWindow = EventWindow()
If EventWindow = #ARS
CloseWindow(#ARS)
Break
EndIf
EndSelect
ForEver
End
;