Klaus
Nombre de messages : 12331 Age : 75 Localisation : Ile de France Date d'inscription : 29/12/2009
| Sujet: 2.39 du 27 mai 2013: ajour fonction SelectFileToOpen Lun 27 Mai 2013 - 18:27 | |
| Nouvelle version: KGF.dll V2.39 du 27/05/2013Nouveauté: nouvelle fonction SelectFileToOpenModules modifiés: KGF.dll KGF_SUB.bas KGF.chm, KGF.doc, KGF.pdfCette fonction est bâtie sur le même modèle que OpenFile, mais peut faire uns sélection multiple de fichiers simultanément, et elle retourne la liste des fichiers sélectionnés dans un mémo (qui peut être caché). Mon programme de mise à jour de site FTP l'utilise maintenant: - Code:
-
' update_site_FTP.bas
labels() constantes() variables() environnement() form0() ecran()
end
sub labels() label close0, connecter, deconnecter, sortir label sel_server, mod_server, del_server, new_server label sel_dir, upload, add_file, rem_file end_sub
sub constantes() dim KGF$ : KGF$ = "KGF.dll" dim ini$ : ini$ = "update_site_FTP.ini" end_sub
sub variables() dim dossier$, connecte%, home% dim no%, no1%, no2%, s$, i%, s1$, idx%, f%, n% dim no_server%, no_dir%, no_files% end_sub
sub form0() full_space 0 caption 0,"Update site FTP" on_close 0,close0 no% = no% + 1 : main_menu no% : no1% = no% no% = no% + 1 : sub_menu no% : parent no%,no1% : no2% = no% caption no%,"Fichier" no% = no% + 1 : sub_menu no% : parent no%,no2% caption no%,"Connecter" : on_click no%,connecter no% = no% + 1 : sub_menu no% : parent no%,no2% caption no%,"Déconnecter" : on_click no%,deconnecter no% = no% + 1 : sub_menu no% : parent no%,no2% caption no%,"-" no% = no% + 1 : sub_menu no% : parent no%,no2% caption no%,"Sortir" : on_click no%,sortir
end_sub
sub ecran() no% = no% + 1 : container no% : no_server% = no% top no%,10 : left no%,10 : width no%,400 : height no%,180 caption no%,"Site FTP" no% = no% + 1 : combo no% : parent no%,no_server% : ' +1 top no%,20 : left no%,100 : width no%, 200 : on_click no%,sel_server no% = no% + 1 : dlist no% : ' +2 no% = no% + 1 : alpha no% : parent no%,no_server% top no%,50 : left no%,10 : caption no%,"Site FTP:" no% = no% + 1 : edit no% : parent no%,no_server% : ' +4 top no%,50 : left no%,100 : width no%,200 no% = no% + 1 : alpha no% : parent no%,no_server% top no%,80 : left no%,10 : caption no%,"Identifiant:" no% = no% + 1 : edit no% : parent no%,no_server% : ' +6 top no%,80 : left no%,100 : width no%,200 no% = no% + 1 : alpha no% : parent no%,no_server% top no%,110 : left no%,10 : caption no%,"Mot de passe:" no% = no% + 1 : edit no% : parent no%,no_server% : ' +8 top no%,110 : left no%,100 : width no%,200 no% = no% + 1 : button no% : parent no%,no_server% top no%,140 : left no%,100 : width no%,60 caption no%,"MàJ" : on_click no%,mod_server no% = no% + 1 : button no% : parent no%,no_server% top no%,140 : left no%,230 : width no%,30 caption no%,"-" : on_click no%,del_server no% = no% + 1 : button no% : parent no%,no_server% top no%,140 : left no%,270 : width no%,30 caption no%,"+" : on_click no%,new_server load_server() no% = no% + 1 : container no% : no_dir% = no% top no%,200 : left no%,10 : width no%,400 : height no%,180 caption no%,"Dossiers:" no% = no% + 1 : list no% : parent no%,no_dir% : ' +1 top no%,20 : left no%,10 : width no%,380 : height no%,150 on_click no%,sel_dir no% = no% + 1 : memo no% : hide no% : ' +2
no% = no% + 1 : container no% : no_files% = no% top no%,200 : left no%,510 : width no%,660 : height no%,180 caption no%,"Fichiers:" no% = no% + 1 : list no% : parent no%,no_files% : ' +1 top no%,20 : left no%,10 : width no%,600 : height no%,150 no% = no% + 1 : open_dialog no% : ' +2 no% = no% + 1 : memo no% : hide no% : width no%,1000 : ' +3 no% = no% + 1 : button no% : parent no%,no_files% top no%,20 : left no%,620 : width no%,30 caption no%,"+" : on_click no%,add_file no% = no% + 1 : button no% : parent no%,no_files% top no%,60 : left no%,620 : width no%,30 caption no%,"-" : on_click no%,rem_file
no% = no% + 1 : button no% : top no%,230 : left no%,420 caption no%,"<<<<<" : on_click no%,upload
end_sub
sub environnement() KGF_initialize(KGF$) dossier$ = dir_current$ + "\" if file_exists(dossier$+ini$)=0 file_open_write 1,dossier$+ini$ file_writeln 1,"MonSite,MonServeur,MonID,MonMotDePasse" file_close 1 end_if end_sub
sub load_server() file_open_read 1,dossier$+ini$ while file_eof(1)=0 file_readln 1,s$ item_add no_server%+2,s$ KGFDelimitedTextExtract(s$,",",1) item_add no_server%+1,KGFDelimitedTextExtract$ end_while file_close 1 idx% = 1 SelectComboBoxItem(handle(no_server%+1),1) aff_server(item_read$(no_server%+2,item_index(no_server%+1))) end_sub
sub aff_server(s$) KGFDelimitedTextExtract(s$,",",2) text no_server%+4,KGFDelimitedTextExtract$ KGFDelimitedTextExtract(s$,",",3) text no_server%+6,KGFDelimitedTextExtract$ KGFDelimitedTextExtract(s$,",",4) text no_server%+8,KGFDelimitedTextExtract$ end_sub
close0: if variable("KGF_res%")=1 then dll_off return sel_server: idx% = item_index(no_server%+1) aff_server(item_read$(no_server%+2,idx%)) return
mod_server: s$ = text$(no_server%+1)+","+text$(no_server%+4)+","+text$(no_server%+6)+","+text$(no_server%+8) s1$ = text$(no_server%+1) item_delete no_server%+1,idx% item_delete no_server%+2,idx% item_insert no_server%+1,idx%,s1$ item_insert no_server%+2,idx%,s$ SelectComboBoxItem(handle(no_server%+1),idx%) aff_server(item_read$(no_server%+2,idx%)) file_save no_server%+2,dossier$+ini$ return
del_server: if message_confirmation_yes_no("Voulez-vous vraiment supprimer le serveur "+text$(no_server%+4)+" ?")=1 item_delete no_server%+1,idx% item_delete no_server%+2,idx% if count(no_server%+1)=0 item_add no_server%+1,"MonSite" item_add no_server%+2,"MonSite,MonServeur,MonID,MonMotDePasse" end_if if idx%>count(no_server%+1) then idx% = count(no_server%+1) SelectComboBoxItem(handle(no_server%+1),idx%) aff_server(item_read$(no_server%+2,idx%)) file_save no_server%+2,dossier$+ini$ end_if return
new_server: s$ = text$(no_server%+1)+","+text$(no_server%+4)+","+text$(no_server%+6)+","+text$(no_server%+8) item_add no_server%+1,text$(no_server%+1) item_add no_server%+2,s$ idx% = count(no_server%+1) SelectComboBoxItem(handle(no_server%+1),idx%) aff_server(item_read$(no_server%+2,idx%)) file_save no_server%+2,dossier$+ini$ return
connecter: if connecte%=1 then CloseFTP() IdentifyMyFTP(text$(no_server%+4),text$(no_server%+6),text$(no_server%+8)) OpenFTP(0) load_folders() connecte% = 1 return
sub load_folders() GetCurrentFolderFilesOnFTP(no_dir%+2) clear no_dir%+1 home% = 0 for i%=1 to count(no_dir%+2) s$ = item_read$(no_dir%+2,i%) f% = 1 if (s$=".") or (s$="..") if s$="." s$ = ".." else f% = 0 end_if else if mid$(s$,len(s$)-4,1)="." then f% = 0 if mid$(s$,len(s$)-3,1)="." then f% = 0 if mid$(s$,len(s$)-2,1)="." then f% = 0 end_if if f%=1 then item_add no_dir%+1,s$ if s$="index.html" then home% = 1 next i% if home%=1 then item_delete no_dir%+1,1 end_sub
sel_dir: s1$ = item_index$(no_dir%+1) ChangeFTPFolder(s1$) load_folders() GetActiveFTPDirectory() if home%=1 caption no_dir%,"Dossiers:" else caption no_dir%,"Dossiers: "+GetActiveFTPDirectory$ end_if return
deconnecter: if connecte%=1 CloseFTP() connecte% = 0 clear no_dir%+1 caption no_dir%,"Dossiers:" end_if return sortir: if connecte%=1 message "Attention ! Vous êtes encore connecté !" return end_if terminate return upload: if connecte%=1 if count(no_files%+1)>0 n% = count(no_files%+1) for i%=1 to n% s$ = item_read$(no_files%+1,1) item_delete no_files%+1,1 display UploadFileToFTP(s$,1) next i% message "fini." end_if end_if return add_file: SelectFileToOpen("","",no_files%+3) if SelectFileToOpen=1 for i%=1 to count(no_files%+3) item_add no_files%+1,item_read$(no_files%+3,i%) next i% end_if return rem_file: if item_index(no_files%+1)>0 then item_delete no_files%+1,item_index(no_files%+1) return
#INCLUDE "KGF_SUB.bas"
| |
|