Yannick
Nombre de messages : 8635 Age : 53 Localisation : Bretagne Date d'inscription : 15/02/2010
| Sujet: Exploration de dossiers Jeu 4 Juil 2013 - 22:58 | |
| Je pense que cela a déjà été fait mais en voulant améliorer "Mon FTP" au niveau de l' exploration de fichier, je suis arrivé à çà : - Code:
-
' ****************************************************************************** ' EXPLORATION DE FICHIER PAR YGERONIMI ' pour insertion dans un programme ' ******************************************************************************
dim obj%,clic% dim champ%,liste%,bouton% dim Path$(100),Mon_dossier$,Path_pos%,New_path$ label clic
' ------------------------------------------------------------------------------ font_name 0,"arial"
obj%=obj%+1 O_Alpha(obj%,0,1,10,10,0,0,"Dossier local")
obj%=obj%+1 : Champ%=obj% O_Edit(obj%,0,1,25,10,0,500,"",0)
obj%=obj%+1 : bouton%=obj% O_Button(obj%,0,1,24,520,22,22,"...",1) font_bold obj% :hint bouton%,"choix du dossier de départ"
obj%=obj%+1 : liste%=obj% O_List(obj%,0,1,50,10,200,530,"",1) cursor_point obj%
end ' ------------------------------------------------------------------------------ clic: clic%=number_click if clic%=bouton% :init_path():end_if if clic%=liste% :new_dir(item_index$(liste%)):end_if return ' ------------------------------------------------------------------------------ sub init_path() obj%=obj%+1 O_Open_Dialog(obj%,champ%,"","",1) Path$(0)=file_extract_path$(Text$(champ%)) clear liste% if Path$(0)<>"_" or Path$(0)<>"" explore() else message "Aucune sélection !" end_if end_sub ' ------------------------------------------------------------------------------ sub explore() dim_local T_path$,sep%,x% T_path$=Path$(0) for x%=1 to 100 sep%=instr(T_path$,"\") Path$(x%)=left$(T_path$,sep%-1) if len(T_path$)>0 T_path$=right$(T_path$,len(T_path$)-sep%) Path_pos%=x% if T_path$="" exit_for end_if else exit_for end_if next x% Remplir_liste(Path$(0)) end_sub ' ------------------------------------------------------------------------------ sub Remplir_liste(D$) dim_local item$,dep% clear liste% dir_change D$
if D$<>Path$(0):dep%=2 :else:dep%=1:end_if if dep%=2:item_insert liste%,1,".../...":end_if item$=file_extract_name$(file_find_first$) if item$<>"_" File_or_Dir(item$) if ForD%=1:item_add liste%,item$:else:item_insert liste%,dep%,item$ :end_if item$=file_extract_name$(file_find_next$) end_if while item$<>"_" if item$<>"_" File_or_Dir(item$) if ForD%=1:item_add liste%,item$:else:item_insert liste%,dep%,item$ :end_if item$=file_extract_name$(file_find_next$) end_if end_while file_find_close end_sub ' ------------------------------------------------------------------------------ sub File_or_Dir(param$) if variable("ForD%")=0 then dim ForD% ForD%=0 dim_local c%,c$,i$ i$=param$ for c%=1 to len(i$) c$=left$(i$,1) if len(i$)>0 i$=right$(i$,len(i$)-1) else exit_for end_if if c$=".":ForD%=1:end_if next c% end_sub ' ------------------------------------------------------------------------------ sub new_dir(ND$) dim_local i$,x% i$=ND$ : New_path$="" if i$=".../..." Path_pos%=Path_pos%-1 Path$(Path_pos%+1)="" for x%=1 to path_pos% New_path$=New_path$+Path$(x%)+"\" next x% text champ%,New_path$ Remplir_liste(New_path$) else File_or_Dir(i$) if ForD%=0 path_pos%=path_pos%+1 Path$(Path_pos%)=i$ for x%=1 to path_pos% New_path$=New_path$+Path$(x%)+"\" next x% text champ%,New_path$ Remplir_liste(New_path$) end_if end_if end_sub ' ______________________________________________________________________________ Sub O_Alpha(No%,P%,V%,T%,L%,H%,W%,C$) ALPHA No% if P% > 0 then Parent No%,P% If V% = 0 Then hide No% If H% > 0 Then Height No%,H% If W% > 0 Then Width No%,W% If T% > 0 Then Top No%,T% If L% > 0 Then Left No%,L% if C$<>"" then Caption No%,C$ End_Sub ' ------------------------------------------------------------------------------ Sub O_Edit(No%,P%,V%,T%,L%,H%,W%,T$,Ch%) EDIT No% if P% > 0 then Parent No%,P% If V% = 0 Then hide No% If H% > 0 Then Height No%,H% If W% > 0 Then Width No%,W% If T% > 0 Then Top No%,T% If L% > 0 Then Left No%,L% If T$<>"" Then Text No%,T$ If Ch%=1 Then On_Change No%,Change End_Sub ' ------------------------------------------------------------------------------ Sub O_Button(No%,P%,V%,T%,L%,H%,W%,C$,Cl%) BUTTON No% if P% > 0 then Parent No%,P% If V% = 0 Then hide No% If H% > 0 Then Height No%,H% If W% > 0 Then Width No%,W% If T% > 0 Then Top No%,T% If L% > 0 Then Left No%,L% if C$<>"" then Caption No%,C$ if Cl%> 0 then on_click No%,Clic cursor_point No% End_Sub ' ______________________________________________________________________________ Sub O_List(No%,P%,V%,T%,L%,H%,W%,F$,Cl%) LIST No% if P% > 0 then Parent No%,P% If V% = 0 Then hide No% If H% > 0 Then Height No%,H% If W% > 0 Then Width No%,W% If T% > 0 Then Top No%,T% If L% > 0 Then Left No%,L% if F$<>"" if file_exists F$ then file_load No%,F$ end_if if Cl%> 0 then on_click No%,Clic End_Sub ' ______________________________________________________________________________ Sub O_Open_Dialog(No%,Out%,DD$,Filtre$,O%) dim_local F$ If Object_Exists(No%)=0 OPEN_DIALOG No% End_if if DD$<>"" then Dir_Dialog No%,DD$ if filtre$<>"" then Filter No%,Filtre$ F$=File_name$(No%) if variable("File$")=0:Dim File$:End_If if F$<>"_" if O%=1 then text out%,F$ if O%=2 then Caption Out%,F$ if O%=3 then item_add Out%,F$ if O%=4 then file_load Out%,F$ if O%=5 then File$=F$ end_if Delete No% End_Sub
Dernière édition par ygeronimi le Ven 5 Juil 2013 - 0:25, édité 1 fois (Raison : Petite modif) | |
|