quinta-feira, 3 de setembro de 2020

DICAS 3065 -WINDEV TUTORIAL 88 -Licao 7.8-11-09-2020 11hrs-The FTP




https://youtu.be/afZ5zR0phEY


Bom Dia/Boa Tarde/Boa Noite


Esse Ao Vivo vai estrear as 11:00 do dia 11/09/2020 

DICAS 3065 -WINDEV TUTORIAL 88 -Licao 7.8-11-09-2020 11hrs-The FTP
Tutoriel WINDEV : Leçon 7.8. Programmation avancée - Le FTP


ASSUNTOS

VISAO GERAL FTP
ABRIR EXEMPLO PCSOFT 
    The FTP functions
CRIANDO UM NOVO EXEMPLO PARA COLOCAR REPOSITORIO WINDEV 
    FTP_AMARILDO
FTPCONECT
FTPListFile 
FTPDisconnect

Video original da Franca

https://youtu.be/7aP_s3jv6Zs


Playlist Windev Tutorial Amarildo
Playlist windev Franca PcSoft
Amarildo
Windev
WxSolucoes
Matos Informatica
Repositorio Windev
Site forum Google 
Video sobre 3 Mil Videos Windev 

https://youtu.be/3DshsXJ8I2M

PlayList Pedrosao
Video sobre Alfaserver servidor 



DICAS 2979 - WINDEV TUTORIAL 2 - 1.2- CRIAR JANELA E INSERIR TEXTO E EXIBIR
DICAS 2980 - WINDEV TUTORIAL 3 - 2.1- VARIAVEIS PARTE 1
DICAS 2981 - WINDEV TUTORIAL 4 - 2.2- VARIAVEIS ESCOPO - PARTE 2
DICAS 2982 - WINDEV TUTORIAL 5 - 2.1- VARIAVEIS OPERADORES PARTE 3
DICAS 2983 - WINDEV TUTORIAL 6 - 2.1.D - VARIAVEIS STRINGS PARTE 4
DICAS 2984 - WINDEV TUTORIAL 7 - 2.1.E - VARIAVEIS ARRAYS PARTE 5
DICAS 2985 - WINDEV TUTORIAL 8 - 2.2.A - CONDICOES IF-SWITCH PARTE 1
DICAS 2986 - WINDEV TUTORIAL 9 - 2.2.B - CONDICOES PARTE 2
DICAS 2987 - WINDEV TUTORIAL 10 - 2.3.A - LOOP PARTE 1
DICAS 2988 - WINDEV TUTORIAL 11 - 2.3.B - LOOP EXEMPLOS PARTE 2
DICAS 2989 - WINDEV TUTORIAL 12 - Lesson 2.4. The procedures - PARTE 1
DICAS 2990 - WINDEV TUTORIAL 13 - Leçon 2.4.b. Procedures Parametros - PARTE 2
DICAS 2991 - WINDEV TUTORIAL 14 - PROCEDURES REFERENCIA - PARTE 3
DICAS 2992 - WINDEV TUTORIAL 15 - PROCEDURES OPCIONAIS OU OBRIGATORIAS - PARTE 4
DICAS 2993 - WINDEV TUTORIAL 16 - PROCEDURES EXEMPLOS - PARTE 5
DICAS 2994 - WINDEV TUTORIAL 17 - PERGUNTAS E RESPOSTA - PARTE 1
DICAS 2995 - WINDEV TUTORIAL 18 - PERGUNTAS E RESPOSTA - PARTE 2
DICAS 2996 - WINDEV TUTORIAL 19 - WINDEV E OS BANCOS DE DADOS
DICAS 2997 - WINDEV TUTORIAL 20 - PROJETO E ANALISE - CRIACAO
DICAS 2998 - WINDEV TUTORIAL 21 - PROJETO E ANALISE - ARQUIVOS DADOS CLIENTE - PARTE 2
DICAS 2999 - WINDEV TUTORIAL 22 - PROJETO E ANALISE - ARQUIVOS DADOS CRIACAO ARQUIVO PEDIDO - PARTE 3
DICAS 3000 - WINDEV TUTORIAL 23 - PROJETO E ANALISE - IMPORTANDO CVS-ARQUIVO TEXTO - PARTE 4
DICAS 3001 - WINDEV TUTORIAL 24 - PROJETO E ANALISE - IMPORTANDO ARQUIVO PRODUTO - PARTE 5
DICAS 3002 - WINDEV TUTORIAL 25 - PROJETO E ANALISE - LINK - PARTE 6
DICAS 3003 - WINDEV TUTORIAL 26 - RAD COMPLETO
DICAS 3004 - WINDEV TUTORIAL 27 - VISAO GERAL
DICAS 3005 - WINDEV TUTORIAL 28 - Adicionar e Modificar Janelas PRODUTOS - PARTE A
DICAS 3006 - WINDEV TUTORIAL 29 - Adicionar e Modificar Janelas PRODUTOS Formulario - PARTE B
DICAS 3007 - WINDEV TUTORIAL 30 - Adicionar e Modificar Janelas PRODUTOS ALINHAR CAMPOS - PARTE C

===


Indice Ftp 

Blog - Curso/194/... Ftp - Atualizar Sistema Cliente - Parte 1/... 
Blog - Curso/195/... Ftp - Atualizar Sistema Cliente - Parte 2/... 
Blog - Curso/196/... 174/3 Bandeja Windows - tirado da Barra de Tarefas 
Blog - Curso/197/... Ftp - Atualizar Sistema Cliente - Parte 3/... 
Blog - Curso/198/... Ftp - Ajustes Parte 4/... 
Blog - Curso/199/... Ftp - Conectar Parte 5/... 
Blog - Curso/200/... Ftp - Criando Tabela Local e Remoto Parte 6/... 
Blog - Curso/201/... Ftp - Mostrar Arquivos Na Tabela Local - Parte 7/...
Blog - Curso/202/... Ftp - Mostrar Arquivos Na Tabela Remoto - Parte 8/... 
Blog - Curso/203/... Gauge - Progresso - Barra de Status
Blog - Curso/204/... Barra de Progresso Visual
Blog - Curso/205/... Ftp - Ajustes - Parte 9/... 
Blog - Curso/206/... Ftp - Transfrindo Servidor - FtpSend - Parte 10/... 
Blog - Curso/207/... Ftp - Transferindo Para Local - FtpGet - Parte 11/... 
Blog - Curso/208/... Ftp - Fechando Conexao - FtpDisconnect - Parte 12/... 
Blog - Curso/209/... Zip - Compactar Arquivo - ZipAddFile / ZipCreate 
Blog - Curso/210/... Zip - Descompactar Arquivo - zipOpen zipExtractFile 
Blog - Curso/211/... Table - Ajustar Altura e y da Tabela Manualmente 
Blog - Curso/212/... Ftp - Criando Diretorio Servidor - FTPMAKEDIR - Parte 13/... 
Blog - Curso/213/... Ftp - Eliminando Diretorio Servidor - FTPRemoveDir - Parte 14 

Novo Curso Ftp 1 - 


=======================
PROCEDURE _01_CONECTAR(sRECEBE_endereco_SERVIDOR is string="",sRECEBE_USUARIO is string="", ... 
                       sRECEBE_SENHA is string="",sSRECEBE_PORTA is string="")
// CRIADO VARIAVEL PARA VERIFICAR RETORNO CONECAO FTP
// CREATED VARIABLE TO CHECK RETURN FTP CONNECTION
// CRÉÉ UNE VARIABLE POUR VÉRIFIER LA CONNEXION FTP DE RETOUR
// VARIABLE CREADA PARA VERIFICAR LA CONEXIÓN FTP DE VUELTA
sMensagem is string=""

gnConnectionID = FTPConnect(sRECEBE_endereco_SERVIDOR,sRECEBE_USUARIO,sRECEBE_SENHA)
IF ErrorOccurred THEN
// Erro durante a conexão
//  Error during the connection
// Erreur lors de la connexion
// Error durante la conexión
sMensagem=""ERRO FTP""+ErrorInfo()
ELSE
sMensagem="OK"+CR+"CONEXAO ID:"+gnConnectionID
END
RESULT sMensagem
// RETORNNADO O RESULTADO DA CONEXAO
// RETURN CONNECTION RESULT
// RETOURNER LE RÉSULTAT DE LA CONNEXION
// RESULTADO DE LA CONEXIÓN DEVUELTA


// 1 - Endereço FTP: corresponde ao site FTP ao qual o aplicativo deve se conectar. Ex: 192.108.10.2
// 1 - FTP address: corresponds to the FTP site to which the application must connect. Ex: 192.108.10.2
// 1 - Adresse FTP: correspond au site FTP auquel l'application doit se connecter. Exemple: 192.108.10.2
// 1 - Dirección FTP: corresponde al sitio FTP al que debe conectarse la aplicación. Ejemplo: 192.108.10.2

// 2 - Nome de usuário: se este nome não for especificado, uma conexão "anônima" será usada
// 2 - User name: if this name is not specified, an "anonymous" connection will be used
// 2 - Nom d'utilisateur: si ce nom n'est pas précisé, une connexion "anonyme" sera utilisée
// 2 - Nombre de usuario: si no se especifica este nombre, se utilizará una conexión "anónima"

// 3 - Senha do usuário: usada apenas se a conexão não for anônima
// 3 - User password: used only if the connection is not an anonymous connection
// 3 - Mot de passe utilisateur: utilisé uniquement si la connexion n'est pas une connexion anonyme
// 3 - Contraseña de usuario: se usa solo si la conexión no es anónima

// Uma variável global de janela: "gnConnectionID" é usada
// A window global variable: "gnConnectionID" is used
// Une variable globale de fenêtre: "gnConnectionID" est utilisée
// Se utiliza una variable global de ventana: "gnConnectionID"

// Esta variável contém o identificador da conexão com o servidor FTP
// This variable contains the identifier of the connection to the FTP server
// Cette variable contient l'identifiant de la connexion au serveur FTP
// Esta variable contiene el identificador de la conexión al servidor FTP

// As funções FTPXXXX do WINDEV usam este identificador
// The FTPXXXX functions of WINDEV use this identifier
// Les fonctions FTPXXXX de WINDEV utilisent cet identifiant
// Las funciones FTPXXXX de WINDEV utilizan este identificador

// Conexão com o servidor FTP
// Connection to the FTP server
// Connexion au serveur FTP
// Conexión al servidor FTP

// A conexão é estabelecida
// The connection is established
// La connexion est établie
// Se establece la conexión

// ----------------------------------------------------------------
// As funções FTPXXXX devem ser utilizadas entre a conexão e a desconexão do servidor
// The FTPXXXX functions must be used between the connection and disconnect from the server
// Les fonctions FTPXXXX doivent être utilisées entre la connexion et la déconnexion du serveur
// Las funciones FTPXXXX deben usarse entre la conexión y la desconexión del servidor

// Nota: Uma conexão com um servidor FTP é fechada por FTPDisconnect
// Note: A connection to an FTP server is closed by FTPDisconnect
// Remarque: une connexion à un serveur FTP est fermée par FTPDisconnect
// Nota: FTPDisconnect cierra una conexión a un servidor FTP

=======================
PROCEDURE _02_FTP_LIST_FILE()
FTPListFile(gnConnectionID,"*.*","_02_LISTA_RETORNA",ftpFile+ftpDirectory)
IF ErrorOccurred THEN
Error("Erro ao navegar pelos arquivos encontrados no servidor FTP",ErrorInfo())
RETURN
END
// Uma variável global de janela: "gnConnectionID" é usada
// A window global variable: "gnConnectionID" is used
// Une variable globale de fenêtre: "gnConnectionID" est utilisée
// Se utiliza una variable global de ventana: "gnConnectionID"

// Esta variável contém o identificador da conexão com o servidor FTP
// This variable contains the identifier of the connection to the FTP server
// Cette variable contient l'identifiant de la connexion au serveur FTP
// Esta variable contiene el identificador de la conexión al servidor FTP

// As funções FTPXXXX do WINDEV usam este identificador
// The FTPXXXX functions of WINDEV use this identifier
// Les fonctions FTPXXXX de WINDEV utilisent cet identifiant
// Las funciones FTPXXXX de WINDEV utilizan este identificador

// Um procedimento "_02_LISTA_RETORNA" é usado por FTPListFile
// A "_02_LISTA_RETORNA" procedure is used by FTPListFile
// Une procédure "_02_LISTA_RETORNA" est utilisée par FTPListFile
// FTPListFile utiliza un procedimiento "_02_LISTA_RETORNA"

// Para cada arquivo ou diretório, o WLanguage é executado
// For each file or directory, the WLanguage runs 
// Pour chaque fichier ou répertoire, le WLangage s'exécute
// Para cada archivo o directorio, se ejecuta WLanguage

// este procedimento com o nome do arquivo, a data de modificação, etc.
// this procedure with the file name, the modification date, etc.
// cette procédure avec le nom du fichier, la date de modification, etc.
// este procedimiento con el nombre del archivo, la fecha de modificación, etc.

// Neste exemplo, o procedimento usado é: "_02_LISTA_RETORNA" (procedimento local para esta janela)
// In this example, the procedure used is: "_02_LISTA_RETORNA" (local procedure for this window)
// Dans cet exemple, la procédure utilisée est: "_02_LISTA_RETORNA" (procédure locale pour cette fenêtre)
// En este ejemplo, el procedimiento utilizado es: "_02_LISTA_RETORNA" (procedimiento local para esta ventana)

=======================
PROCEDURE _02_LISTA_RETORNA(sFileName,nFileSize <useful>,sAttribute,sModifDate <useful>,sModifTime <useful>)

// É um arquivo ou um diretório
// Is it a file or a directory
// Est-ce un fichier ou un répertoire
// ¿Es un archivo o un directorio?
IF sAttribute = "D" THEN
// Diretório ou subdiretório
// Directory or sub-directory
// Répertoire ou sous-répertoire
// Directorio o subdirectorio
Trace("Diretorio"+sFileName)
ELSE
// Arquivo
// File
// Fichier
// Expediente
Trace("Arquivo:"+sFileName)
END

// Continue a navegar pelos arquivos
// Continue to browse the files
// Continuer à parcourir les fichiers
// Continuar explorando los archivos
RESULT True



=======================
PROCEDURE _99_DESCONECTAR()

// Uma variável global de janela: "gnConnectionID" é usada
// Esta variável contém o identificador da conexão com o servidor FTP
// As funções FTPXXXX do WINDEV usam este identificador
// Nota: Uma conexão com um servidor FTP é fechada por FTPDisconnect

// A window global variable: "gnConnectionID" is used
// This variable contains the identifier of the connection to the FTP server
// The FTPXXXX functions of WINDEV use this identifier
// Note: A connection to an FTP server is closed by FTPDisconnect

// Une variable globale de fenêtre: "gnConnectionID" est utilisée
// Cette variable contient l'identifiant de la connexion au serveur FTP
// Les fonctions FTPXXXX de WINDEV utilisent cet identifiant
// Remarque: une connexion à un serveur FTP est fermée par FTPDisconnect

// Se utiliza una variable global de ventana: "gnConnectionID"
// Esta variable contiene el identificador de la conexión al servidor FTP
// Las funciones FTPXXXX de WINDEV utilizan este identificador
// Nota: FTPDisconnect cierra una conexión a un servidor FTP

IF YesNo(No,"Quer encerrar a conexão com o servidor FTP?")=Yes THEN
// Desconectar do servidor FTP
// Disconnect from the FTP server
// Se déconnecter du serveur FTP
// Desconectarse del servidor FTP
FTPDisconnect(gnConnectionID)
IF ErrorOccurred THEN
Error("Incapaz de fechar a conexão FTP",ErrorInfo())
RETURN
END
Info("La conexión al servidor FTP ha terminado.A conexão com o servidor FTP acabou")
END

=======================
IF EDT_ENDERECO_servidor ~= "" THEN
Error("Especifique o servidor FTP para contatar")
ReturnToCapture(EDT_ENDERECO_servidor)
END
IF EDT_NOME_USUARIO ~= "" THEN
Error("Especifique o usuario FTP a ser usado")
ReturnToCapture(EDT_NOME_USUARIO)
END

// CONECTANDO O FTP E PEGANDO O RETORNO
// CONNECTING FTP AND TAKING RETURN
// CONNEXION FTP ET RETOUR
// CONECTAR FTP Y VOLVER

STC_MENSAGEM=_01_CONECTAR(EDT_ENDERECO_servidor,EDT_NOME_USUARIO,EDT_SENHA,EDT_PORTA)
=======================

_02_FTP_LIST_FILE()
=======================
_99_DESCONECTAR()




























Lesson 7.8. The FTP
This lesson will teach you the following concepts
  • Presenting the FTP functions of WINDEV.
Lesson duration

Estimated time: 20 mn
Previous LessonTable of contentsNext Lesson
Overview
The FTP (File Transfer Protocol) is a standard protocol used to transfer files from a computer to another one. One of the computers must be an FTP server.
Several WLanguage commands allow you to transfer files by using this protocol with a server. These programming functions start with "FTP".
WINDEV only proposes "client" functions for the FTP. A standard FTP server is required.
The unit example named "The FTP functions" presents the operations that can be performed on the files found on an FTP server.
  • Open the unit example named "The FTP functions". This example presents the main features that can be used on an FTP server.
Connecting to an FTP server
FTPConnect is used to connect to an FTP server. An FTP account (user name and password) is required to access an FTP server.
  • Display the WLanguage events associated with the "Connection" Button control in "WIN_FTP":
    1. Select the "Connection" Button control.
    2. Press F2 to display the associated WLanguage code:
      // 1 - FTP address: corresponds to the FTP site
      // to which the application must connect. Ex: 192.108.10.2
      sFTPAddress is string = EDT_FTP_Server
      // 2 - User name: if this name is not specified,
      // an "anonymous" connection will be used
      sUserName is string = EDT_User
      sUserPWD is string = EDT_Password
      // Connection to FTP server
      gnConnectionID = FTPConnect(sFTPAddresssUserName, ...
      sUserPWD)
      IF ErrorOccurred THEN
      // An error occurred during the connection
      Error("The connection to the FTP server: " + ...
      sFTPAddress + " failed"ErrorInfo())
      RETURN
      END
      // The connection is established
      Info("The connection to the FTP server is established", ...
      "connection identifier: " + gnConnectionID)
Remark: You also have the ability to specify the port number for connecting to the FTP server ("21" by default) as well as the connection mode ("True" for a "passive" connection, "False" for an "active" connection).
See Standard FTP functions for more details.
Send a file
To send a file to an FTP server, all you have to do is use FTPSend.
Let's see a code sample that can be used:
// When connecting to the server with FTPConnect, we have
// retrieved the connection number in the gnConnectionID variable
// Transfer the "C:\MyDocuments\File.DOC" file to
// the "Temp" directory found on the server.
bResult is boolean = FTPSend(gnConnectionID, ...
"C:\MyDocuments\File.DOC""/Temp")

Caution!

Pay great attention to the case (uppercase/lowercase characters) for the name of directories on the server. Indeed, some FTP servers operate under UNIX and are "case sensitive", which means that the case is taken into account for the name of files and directories.
For example, a directory named "MyDirectory" is found on the FTP server. If you try to access "mydirectory", an error such as "Path not found" will be returned by the FTP server because the case is incorrect.
Listing the files found on an FTP server
FTPListFile is used to list the files found on an FTP server. This function is using a "callback" procedure. The procedure is run for each file or directory found.
  • Display the WLanguage events associated with the "List" Button control in "WIN_FTP":
    1. Select the "List" Button control.
    2. Press F2 to display the associated WLanguage code:
      FTPListFile(gnConnectionID,"*.*", ...
      "CallBackFTPListFile"ftpFile+ftpDirectory)

      // Check the function execution
      IF ErrorOccurred THEN
      Error("Error while browsing the files found on the FTP server"ErrorInfo())
      RETURN
      END
    3. In the example, the procedure called is used to display the files found in a trace window.
      PROCEDURE CallBackFTPListFile(sFileNamenFileSize <useful>, ...
      sAttributesModifDate <useful>, sModifTime <useful>)
       
      // Is it a file or a directory
      IF sAttribute = "D" THEN
      // Directory or subdirectory
      Trace("Directory: " + sFileName)
      ELSE
      // File
      Trace("File: " + sFileName)
      END
       
      // Continue to browse the files
      RESULT True
Retrieving a file
To get a file from an FTP server, all you have to do is call FTPGet.
Let's see a code sample that can be used:
// When connecting to the server with FTPConnect, we have
// retrieved the connection number in the gnConnectionID variable
// Download the "/Document/File.DOC" file found
// on the FTP server to the "D:\Temp" directory on
// the current computer
bResult is boolean = FTPGet(gnConnectionID, ...
"/Document/File.DOC""D:\Temp")
Disconnecting from an FTP server
To disconnect from an FTP server, use FTPDisconnect.
  • Display the WLanguage events associated with the "Disconnection" Button control in "WIN_FTP":
    1. Select the "Disconnection" Button control.
    2. Press F2 to display the associated WLanguage code:
      IF YesNo(No"Do you want to close the connection to the FTP server?") = Yes THEN
      // Disconnect from the FTP server
      FTPDisconnect(gnConnectionID)
      IF ErrorOccurred THEN
      // Error while closing the connection
      Error("Unable to close the FTP connection"ErrorInfo())
      RETURN
      END

      // The connection is ended
      Info("The connection to the FTP server is ended")
      END
Other FTP functions are available but we won't go into details about them in this tutorial. They are mainly used to:
  • create, delete, modify directories on the FTP server,
  • create, delete, modify files on the FTP server,
  • retrieve information about a directory and/or a file,
  • ...
See Standard FTP functions for more details.


Nenhum comentário:

Postar um comentário

Teste

Teste
teste