Librairie viewer

Programmation d'applications complexes
Avatar de l’utilisateur
graph100
Messages : 1318
Inscription : sam. 21/mai/2005 17:50

Librairie viewer

Message par graph100 »

Je ne sais pas si sa va servir beaucoup : c un programme qui sert a voir le contenu de toutes les librairies utilisées par PB :

il ne faut pas selectionner de gros fichiers sinon sa plante ca ne sert que pour la librairie ( 0k --> 100k)

Code : Tout sélectionner

If OpenWindow(0, 0, 0, 700, 400, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "Librarie Viewer") = 0 Or CreateGadgetList(WindowID(0)) = 0
  MessageRequester("Attention", "Le programme ne peut être lancé")
  End
EndIf

If OpenPreferences("Librarie Viewer.pref")
  pure_directory.s = ReadPreferenceString("pure_repertoire", "")
  ClosePreferences()
EndIf
If pure_directory = ""
  If CreatePreferences("Librarie Viewer.pref")
    pure_directory = PathRequester("Repertoire de PureBasic", "C\:")
    WritePreferenceString("pure_repertoire", pure_directory)
    ClosePreferences()
  EndIf
EndIf

ExplorerListGadget(0, 10, 10, 220, 380, pure_directory + "\PureLibraries\", #PB_Explorer_FullRowSelect)
RemoveGadgetColumn(0, 3)
RemoveGadgetColumn(0, 2)
EditorGadget(1, 240, 10, 450, 380, "")

Repeat
  event = WaitWindowEvent()
  
  If event = #PB_Event_Gadget
    Select EventGadgetID()
      Case 0
        selec = GetGadgetState(0)
        If Selec <> -1
          name.s = GetGadgetText(0) + GetGadgetItemText(0, Selec, 0)
          
          text.s = "librarie:  " + name + Chr(13) + Chr(13)
          
          If OpenFile(0, name)
            string.s = ""
            Repeat
              string + ReadString() + Chr(13)
              pos = FindString(string, "ERUP", 0)
              pos1 = 0
              If pos
                pos1 = FindString(string, "ERUP", pos + 1)
              EndIf
            Until pos1 Or Eof(0)
            
            pos = FindString(string, "LIB3", 0)
            If pos = 0
              pos = FindString(string, "LIB2", 0)
            EndIf
            If pos
              ; nom de la librairie
              text + "Name:  "
              pos + 4
              posfin = Lof()
              For a = 1 To 5
                posfin_1 = FindString(string, Chr(a), pos)
                If posfin_1 < posfin And posfin_1 : posfin = posfin_1 : EndIf
              Next
              text + Mid(string, pos, posfin - pos) + Chr(13)
              
              ; nom des libraries window utilisées
              
              text + "Window Librarie:" + Chr(13)
              
              posfin + 2
              
              posfin_1 = Len(string)
              
              For a = 1 To 8
                posfin_2 = FindString(string, Chr(a), posfin)
                If posfin_2 < posfin_1 And posfin_2 : posfin_1 = posfin_2 : EndIf
              Next
              
              While posfin < posfin_1 And posfin_1
                pos = FindString(string, Chr(13), posfin)
                text + " - " + Mid(String, posfin, pos - posfin) + Chr(13)
                posfin = pos + 1
              Wend 
              
              ; nom de l'aide 
              
              text + Chr(13) + "Help:  "
              
              posfin + 1
              
              posfin_1 = Len(string)
              
              For a = 1 To 8
                posfin_2 = FindString(string, Chr(a), posfin)
                If posfin_2 < posfin_1  And posfin_2 : posfin_1 = posfin_2 : EndIf
              Next
              
              pos = FindString(string, Chr(13), posfin)
              text + Mid(String, posfin, pos - posfin) + Chr(13) + Chr(13)
              posfin = pos + 1
              
              ; nom des libraries Pure utilisées
              
              text + "Pure Librarie:" + Chr(13)
              
              posfin + 1
              
              posfin_1 = Len(string)
              
              For a = 1 To 8
                posfin_2 = FindString(string, Chr(a), posfin)
                If posfin_2 < posfin_1 And posfin_2 : posfin_1 = posfin_2 : EndIf
              Next
              
              librarie.s = Mid(string, posfin, posfin_1 - posfin)
              
              For pos = 1 To Len(librarie) - 1
                If Mid(librarie, pos + 1, 1) = Chr(13) And Mid(librarie, pos, 1) = Chr(13)
                  librarie = Mid(librarie, 1, pos)
                  Break
                EndIf
              Next
              
              nb = CountField(librarie, Chr(13))
              nb_1 = 1
              
              While posfin < posfin_1 And posfin_1 And nb <> nb_1
                nb_1 + 1
                pos = FindString(string, Chr(13), posfin)
                text + " - " + Mid(String, posfin, pos - posfin) + Chr(13)
                posfin = pos + 1
              Wend
              
              ; fonctions
              
              text + Chr(13) + "Functions and descriptions:" + Chr(13)
              
              string = Mid(string, posfin, Len(string) - posfin)
              
              pos = 1
              While FindString(string, "(", pos) And FindString(string, ")", pos)
                posfin = FindString(string, Chr(13), pos)
                text + " - " + Mid(string, pos, posfin - pos)
                pos = FindString(string, "(", posfin)
                posfin = FindString(string, Chr(13), pos)
                text + Mid(string, pos, posfin - pos) + Chr(13)
                pos = posfin + 1
              Wend
              
              SetGadgetText(1, text)
            Else
              SetGadgetText(1, text + string)
            EndIf
            
            CloseFile(0)
          EndIf
        EndIf
        
    EndSelect
  EndIf
  
Until event = #PB_Event_CloseWindow

End
Dorian
Messages : 489
Inscription : mar. 15/mars/2005 15:33

Message par Dorian »

J'ai un problème avec ton code sur cette ligne (119) :

nb = CountField(librarie, Chr(13))

CountField is not array or function :(

Ton code serais pas fait avec la 3.94 ?
Avatar de l’utilisateur
graph100
Messages : 1318
Inscription : sam. 21/mai/2005 17:50

Message par graph100 »

Ah zut désolé c une lib que j'ai faite :

Code : Tout sélectionner

ProcedureDLL CountField(string.s, separator.s) ; envoie le nombre de champs délimités par le caractere separator.s
  separator = Left(separator, 1)
  
  Repeat
    If Left(string, 1) = separator
      string = Right(string, Len(string) - 1)
    EndIf
  Until Left(string, 1) <> separator
  
  Repeat
    If Right(string, 1) = separator
      string = Left(string, Len(string) - 1)
    EndIf
  Until Right(string, 1) <> separator
  
  string2.s = RemoveString(string, separator)
  
  k = 1
  num = 0
  Repeat
    text1.s = StringField(string, k, separator)
    If text1 <> "" : num = num + 1 : EndIf
    text2.s = text2 + text1
    k = k + 1
  Until Len(text2) >= Len(string2)
  ProcedureReturn num
EndProcedure
Répondre