PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • Example: Transferring a file and managing a progress bar
  • Example: Transferring a directory to the root of an FTP account and managing a progress bar
Example: Transferring a file and managing a progress bar
WINDEVJava
This example sends a file from the current computer to the FTP server. The Transfer_Progress procedure is used to manage the progress of the transfer in the current window, displayed on the current computer.
nConnection is int
nConnection = FTPConnect("ftp.cdrom.com", "GUEST", "")
 
IF FTPSend(nConnection, "C:\autoexec.bat", "/autoexec.tmp", "Transfer_Progress") = False THEN
  Info("The transfer failed")
END
// -- ProgBar_Transfer procedure: managing the current transfer
PROCEDURE Transfer_Progress(nTotal, nCurrent)
Message("Transfer in progress...")
ProgressBar(nCurrent, nTotal)
// Is the transfer completed?
IF nCurrent = nTotal THEN
Message("Transfer completed")
Info("Transfer completed")
END
RETURN True
Example: Transferring a directory to the root of an FTP account and managing a progress bar
WINDEVJava
This example is used to send a full directory found on the current computer to the FTP server. The ManageProgress procedure is used to manage the progress of the transfer in the current window, displayed on the current computer.
HourGlass()
ResSend is boolean
ResConnect is int = FTPConnect(sAddressFTPServer,"MyFTPAccount","MyPassword",21, False)
IF ResConnect = -1 THEN
HourGlass(False)
Error("Connection error: " + CR + ErrorInfo())
RETURN
END
 
// Connection successful: sending the gallery
// FTPMakeDir(ResConnect,"/"+TABLE_Galleries.Gallery_Name)
ResSend = FTPSend(ResConnect, CompleteDir(LocalDirectoryOfGalleries) +  ...
TABLE_Galeries.Gallery_Name, ...
"/", "ManageProgress", ftpBinaryMode)
 
IF ResSend = False THEN
HourGlass(False)
Error("Error while sending the gallery: " + CR + ErrorInfo())
RETURN
END
 
FTPDisconnect(ResConnect)
ProgressBar()
HourGlass(False)
Info("Gallery transferred")
// -- ManageProgress procedure: managing the current transfer
PROCEDURE ManageProgress(nTotal_size, nTransferred_size)
 
ProgressBar(nTransferred_size, nTotal_size, "Transferring the gallery...", PastelRed)
RETURN True
Minimum version required
  • Version 9
Comments
FTPSEND
s_arquivo_endereco_local is string=ftp_conf.endereco_local+TABLE_local.COL_nome_arquivo // "d:\erpmatos\Atualizacao\matosnfe.jpg"
s_arquivo_endereco_remoto is string=ftp_conf.endereco_remoto+TABLE_local.COL_nome_arquivo // "/web/_Windev_Erp_matos/matosnfe.jpg"
// TRANSFERENCIA
IF FTPSend(n_conexao,s_arquivo_endereco_local,s_arquivo_endereco_remoto,_transferencia) = False THEN
Info("erro transferencia")
END
// TRANSFERENCIA
// ESSA PROCEDURE ESTA LINKADA AO FTPSEND
PROCEDURE _transferencia(nTotal, nCurrent)
Gauge(nCurrent,nTotal) // vai gerar uma barra de progresso status
// tem de estar com status de mensagem na windows ativa
RESULT True
De matos AMARILDO
04 Jan. 2016