SPH Forum
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
-20%
Le deal à ne pas rater :
-20% Récupérateur à eau mural 300 litres (Anthracite)
79 € 99 €
Voir le deal

DICOrection TEMP-------

Aller en bas

DICOrection TEMP------- Empty DICOrection TEMP-------

Message par Admin Mar 25 Juin - 22:52

Code:
#src=0
#dst=1
#tmp=2



chemin$="f:\HexaScrabble 3_00d_demo_pret\dico-french\"

OpenWindow(0, 0, 0, 300, 500, "CheckBoxGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

PanelGadget    (0, 0, 0, 300, 500)

AddGadgetItem (0, 26,"Mots de 3 lettres et plus")

EditorGadget(2000, 10, 10, 276, 140, #PB_Editor_WordWrap)
EditorGadget(2001, 10, 160, 276, 140, #PB_Editor_ReadOnly | #PB_Editor_WordWrap)

ButtonGadget(2002, 80, 320, 130, 40,"Vérifier")
ButtonGadget(2003, 80, 370, 130, 40,"Ajouter")
ButtonGadget(2004, 80, 420, 130, 40,"Retirer")

SetActiveGadget(2000)



Repeat
  EventID = WaitWindowEvent()
  If EventID = #PB_Event_Gadget
   
    evg = EventGadget()
   
    If evg=2002
      ecrire=0
      Gosub lire
    EndIf
   
    If evg=2003
      ecrire=1
      Gosub lire
    EndIf
   
    If evg=2004
      ecrire=2
      Gosub lire
    EndIf
   
   
  EndIf
Until EventID = #PB_Event_CloseWindow
End

;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;


lire:

mot$ = GetGadgetText(2000)

mot$=LCase(mot$)


mot$=ReplaceString(mot$,"ß","ss")
mot$=ReplaceString(mot$,"à","a")
mot$=ReplaceString(mot$,"á","a")
mot$=ReplaceString(mot$,"â","a")
mot$=ReplaceString(mot$,"ã","a")
mot$=ReplaceString(mot$,"ä","a")
mot$=ReplaceString(mot$,"å","a")
mot$=ReplaceString(mot$,"ç","c")
mot$=ReplaceString(mot$,"è","e")
mot$=ReplaceString(mot$,"é","e")
mot$=ReplaceString(mot$,"ê","e")
mot$=ReplaceString(mot$,"ë","e")
mot$=ReplaceString(mot$,"ì","i")
mot$=ReplaceString(mot$,"í","i")
mot$=ReplaceString(mot$,"î","i")
mot$=ReplaceString(mot$,"ï","i")
mot$=ReplaceString(mot$,"ð","o")
mot$=ReplaceString(mot$,"ñ","n")
mot$=ReplaceString(mot$,"ò","o")
mot$=ReplaceString(mot$,"ó","o")
mot$=ReplaceString(mot$,"ô","o")
mot$=ReplaceString(mot$,"õ","o")
mot$=ReplaceString(mot$,"ö","o")
mot$=ReplaceString(mot$,"ù","u")
mot$=ReplaceString(mot$,"ú","u")
mot$=ReplaceString(mot$,"û","u")
mot$=ReplaceString(mot$,"ü","u")
mot$=ReplaceString(mot$,"ý","y")
mot$=ReplaceString(mot$,"ÿ","y")
mot$=ReplaceString(mot$,"æ","ae")
mot$=ReplaceString(mot$,"œ","oe")

;    ; debug mot$
;    ; debug Len(mot$)
;    ; debug("===")

len=Len(mot$)
len2=1
b$=""
cmb=0
Dim mot$(100000)
;Dim mot(10000)
;mot(0)=1

While len2<=len
  a$=Mid(mot$,len2,1)
  ;      ; debug a$
 
  If Asc(a$)>=97 And Asc(a$)<=122
    b$+a$
    ;        ; debug b$
  Else
    If b$<>""; And Len(b$)>=3
            ;; debug b$
      cmb+1
      mot$(cmb)=b$
      b$=""
    EndIf
  EndIf
  len2+1
Wend

If b$<>""; And Len(b$)>=3
        ;        ; debug b$
  cmb+1
  mot$(cmb)=b$
EndIf

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   

; debug cmb

cmb2=0
cmb3=0
cmb_no=0

For i=1 To cmb
  If Len(mot$(i))>=3
    AddGadgetItem(2001, -1, mot$(i))
    cmb2+1
    ;;;;;;;;;;;;;;;;;;;;;;;;;;
    a$=Left(mot$(i),1)
    x=Len(mot$(i))
    mot_ref$=Mid(mot$(i),2,x-1)
    ; debug mot_ref$
   
   
    If ReadFile(#dst, chemin$+"dico-"+a$+Str(x)); : ;beep_(1500,50)
      While Eof(#dst) = 0                      ; loop as long the 'end of file' isn't reached
                                                ;        ; debug a$+ReadString(#dst)
                                                ;        ; debug mot$(i)
        e$=ReadString(#dst)
        d$=a$+e$
        ;        ; debug d$
       
        If d$=mot$(i)
          ;          End
          cmb3+1
         
          If ecrire=2
            CloseFile(#dst)
            If OpenFile(#dst, chemin$+"dico-"+a$+Str(x)); : ;beep_(1500,50)
              If CreateFile(#tmp, chemin$+"_dico-"+a$+Str(x)); : ;beep_(1500,50)
                ; debug ("===")

                While Eof(#dst) = 0                          ; loop as long the 'end of file' isn't reached
                  f$=ReadString(#dst)
                  ; debug f$
                  If f$<>mot_ref$
                    WriteStringN(#tmp, f$)
                  EndIf
                Wend
                    ;End
                CloseFile(#dst)
                CloseFile(#tmp)
                DeleteFile(chemin$+"dico-"+a$+Str(x))
                RenameFile(chemin$+"_dico-"+a$+Str(x), chemin$+"dico-"+a$+Str(x))
              EndIf
            EndIf
            Goto ok61
           
          EndIf
         
         
         
         
          Goto ok60
        EndIf
      Wend
      cmb_no+1
     
      ;;;;;;;;;;;;;;;;;;;;;;;;;;
      If ecrire=1
        ;        Beep_(1500,200)
        ;        ; debug mot$(i)
        ;        ; debug mot_ref$
        ;        ; debug "dico-"+a$+Str(x)
       
        CloseFile(#dst)
       
        If OpenFile(#tmp, chemin$+"dico-"+a$+Str(x))
            length = Lof(#tmp)                      ; Lit la taille en octets du fichier
            FileSeek(#tmp, length) 
          WriteStringN(#tmp, mot_ref$)
          CloseFile(#tmp)
        EndIf
        Goto ok61
      EndIf
      ;;;;;;;;;;;;;;;;;;;;;;;;;;
     
      ok60:
      CloseFile(#dst)
      ok61:
    EndIf
    ;;;;;;;;;;;;;;;;;;;;;;;
   
  EndIf
Next

If cmb=1
  If cmb3>0
    AddGadgetItem(2001, -1, d$+" : mot référencé")
  Else
    If ecrire=1
      AddGadgetItem(2001, -1, a$+mot_ref$+" : mot référencé")
    Else
      AddGadgetItem(2001, -1, a$+mot_ref$+" : mot non référencé")
      ;    AddGadgetItem(2001, -1, d$+" : mot non référencé")
    EndIf
   
  EndIf
 
Else
  If ecrire=2
    AddGadgetItem(2001, -1, Str(cmb3)+" mot(s) retiré(s)")
  Else
    AddGadgetItem(2001, -1, Str(cmb3)+" mot(s) référencé(s)")
  EndIf
 
  If ecrire=1
    AddGadgetItem(2001, -1, Str(cmb_no)+" mot(s) référencé(s)")
  Else
    AddGadgetItem(2001, -1, Str(cmb_no)+" mot(s) non référencé(s)")
  EndIf
 
EndIf

AddGadgetItem(2001, -1, "-")
;RemoveGadgetItem(2001, CountGadgetItems(0)-2)





Return

Admin
Admin

Messages : 66
Date d'inscription : 04/09/2015

https://sphforum.kanak.fr

Revenir en haut Aller en bas

Revenir en haut

- Sujets similaires

 
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum