PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • This lesson will teach you the following concepts
  • Overview
  • Handling text or CSV files
  • Overview
  • Practical example
  • Handling directories
  • Practical example
  • Handling XML files
  • Overview
  • Practical example
  • Handling XLS files
  • Practical example
Lesson 7.3. Handling external files
This lesson will teach you the following concepts
  • Handling text files (CSV , ...).
  • Handling directories.
  • Handling XML files.
  • Handling XLS files.

Estimated time: 20 mn
Previous LessonTable of contentsNext Lesson
Overview
WINDEV allows you to easily handle the most common data formats:
  • text files (INI, CSV, ...),
  • XML files,
  • XLS files, ... Several families of WLanguage functions can be used to read and create these files. This allows you to easily read data generated by another software in your WINDEV applications or to create files that require a specific formatting.
Furthermore, several WLanguage functions can be used to handle the directories containing the files.
In this chapter, we will focus on:
  • Text files (text files, INI files and CSV files),
  • XML files,
  • XLS files,
  • the management of directories.
Handling text or CSV files

Overview

The external files are also called text files or files with direct access. In most cases, this type of file contains text but it can also contain binary information such as images, sounds, ...
In this lesson as in the entire WINDEV documentation, we will be talking of external files.
WINDEV allows you to handle the external files by programming. The WLanguage functions can be used to create, read ... external files. All functions can easily be identified: they all start with the letter"f".
The notion of "record" does not necessarily exist in an external file. To handle an external file, you must know its structure, which means how the data is organized inside the file.
The CSV files are text files that use a specific structure. Therefore, they can be handled like the text files.
The .INI files are also text files that use a specific structure. To handle them, WINDEV includes two specific functions: INIRead and INIWrite.

Practical example

  • Open the unit example named "Handling text files".
  • Run the test of "WIN_Text_File" window. This window groups the different operations that can be performed on the external files with WINDEV.
The different window buttons propose to:
  • Create a text file.
  • Read and write in a text file.
  • Handle existing files (copy, deletion, read information, ...).
  • Copy a text file.
Handling directories
Several WLanguage functions are used to handle the directories and their files.

Practical example

  • Open (if necessary) the unit example named "Handling directories" and run the test of corresponding window.
  • This window groups the operations that can be performed on disks and directories:
    • create a directory,
    • find out the current directory,
    • check the existence of a directory,
    • list the directories,
    • copy and create a directory, ...
See Functions for managing external files for more details.
Handling XML files

Overview

XML (Extensible Markup Language) is a markup language, which means a language that presents information enclosed in tags. XML is a metalanguage that is used to invent new tags to isolate the elementary information that may be found in a Web page.
XML is used to structure a document containing data. A HFSQL data file containing several items and records can be exported to an XML file for example (XML* functions).
WINDEV supports:
The XML file can also be handled in the code editor directly. You must:
  1. Drop the XML file from the file explorer to the project explorer, "XML and XSD descriptions" folder.
  2. Drop the XML file from the project explorer to the code editor. The xmlDocument variable is automatically created as follows:
    <Variable Name> is xmlDocument, description =  <Document Name>
  3. You now have the ability to access the variable nodes by their names. These names are automatically proposed by the mechanism for automatic completion of the code editor.

Practical example

  • Open the unit example named "Reading and writing in XML format".
  • Run the test of "WIN_HandleXML" window. This window is used to:
    • create an XML file. This file is created by the XML functions.
    • read an XML file.
  • Study the code associated with each button.

Note

We won't go into details about all the features proposed by the XML functions.
See XML functions for more details.
Handling XLS files
To handle the Excel files, WINDEV proposes:
  • the xlsXXX functions. These functions are used to read the data found in the different worksheets of an Excel file.
  • the advanced variables (xlsDocument, xlsRow, xlsColumn, xlsCell).

Practical example

A quick test of these functions?
  • To check the use of xlsXXX functions, open the training example named "The Excel functions".
  • Run the test of "WIN_XLSFunction" window. This window is used to:
    • import data coming from an Excel worksheet.
    • export data from a Table control to Excel.
    Go back to the editor and study the code of different buttons.
  • To check the use of advanced variables, open the unit example named "XLS type".
  • Run the test of "WIN_XLS_Type" window.
  • Go back to the editor and study the code of different buttons.

Note

We won't go into details about all the features proposed by the XLS functions and the advanced types.
See Functions for managing XLS files for more details.
Previous LessonTable of contentsNext Lesson
Minimum version required
  • Version 23
Comments
Click [Add] to post a comment