Windev Tutorial
Windev Tutorial
Summary 3
Simple operations on the variables.................................................................................................................... 48 Procedure result................................................................................................................................................... 76
Tips .................................................................................................................................................49 Practical example: Using a procedure................................................................................................................ 77
Details of variable type: the String variables...................................................................................................... 49 Project used............................................................................................................................................77
The String type........................................................................................................................................49 Implementation......................................................................................................................................77
Practical example...................................................................................................................................50 Creating and using a procedure............................................................................................................80
Details of another variable type: the arrays....................................................................................................... 54 Conclusion............................................................................................................................................................. 81
Declaration.............................................................................................................................................54
Filling an array and accessing the elements.........................................................................................54 Lesson 2.5. Questions/Answers
Advanced arrays.....................................................................................................................................55 Questions/Answers.............................................................................................................................................. 83
How to view the element to which the current event belongs?............................................................83
Lesson 2.2. The conditional statements How to print the source code?...............................................................................................................83
Overview................................................................................................................................................................ 57 How to perform a "find and/or replace"?..............................................................................................83
The IF and SWITCH statements........................................................................................................................... 57 What is the meaning of "+" and "-" signs in the code editor?................................................................84
The IF statement.................................................................................................................................... 57 Is it possible to identify the person who wrote a code line?.................................................................84
The SWITCH statement..........................................................................................................................58 Is it possible to find out the code line number?....................................................................................84
Practical example: Using the IF and SWITCH statements................................................................................. 59 Is there a method to easily display the syntax or the help about a function?......................................85
Project used............................................................................................................................................59 What are the useful shortcuts in the code editor?...............................................................................85
Creating the window...............................................................................................................................60 How to communicate with the user?.....................................................................................................86
Creating the window controls for the conditional IF statement...........................................................60
Conditional IF statement.......................................................................................................................61
Creating the window controls for the conditional SWITCH statement.................................................62 Part 3 - My first database
SWITCH statement.................................................................................................................................62
4 Summary Summary 5
Lesson 3.4. The full RAD Lesson 4.4. Multicriteria search
What is RAD?......................................................................................................................................................119 Overview.............................................................................................................................................................. 172
Generating RAD..................................................................................................................................................120 Creating the query used to find orders............................................................................................................. 173
Application test...................................................................................................................................................123 Creating the query................................................................................................................................173
Query test.............................................................................................................................................175
Using parameters in the query............................................................................................................ 176
Part 4 - Full application with data Test of query with parameters.............................................................................................................179
Creating the interface used to perform a multicriteria search.......................................................................180
Modifying the Tab control.....................................................................................................................180
Lesson 4.1. Overview Creating the controls used to configure the criteria and to display the result...................................181
Overview of application created in this section...............................................................................................128
Projects supplied................................................................................................................................................128 Lesson 4.5. Printing the content of a Table control
Example project................................................................................................................................... 128 Overview..............................................................................................................................................................193
Corrected projects............................................................................................................................... 129 Printing the content of a Table control..............................................................................................................194
Direct print via the AAF (Automatic Application Feature)...................................................................194
Lesson 4.2. Addition and modification windows Creating an automatic report on Table control...................................................................................196
Overview..............................................................................................................................................................131
Creating a window used to list the products.....................................................................................................131 Lesson 4.6. Printing an order
Creating the window.............................................................................................................................131 Overview..............................................................................................................................................................199
Creating controls..................................................................................................................................132 Creating the "Order form" report.......................................................................................................................199
Window test..........................................................................................................................................135 Creating the query............................................................................................................................... 200
Creating a "Product form" window....................................................................................................................137 Creating the report based on a query................................................................................................ 203
Creating the window.............................................................................................................................137 Modifying the "Order form" report.......................................................................................................210
Creating edit controls...........................................................................................................................137 Displaying the printed report from a menu option..........................................................................................212
Creating buttons...................................................................................................................................140 Creating the popup menu....................................................................................................................212
Improving the window interface..........................................................................................................140 Associating the popup menu with the Table control...........................................................................213
Displaying the form from the list of products......................................................................................144 Print test 214
Managing the product modification.................................................................................................................146
Modifying the product image...............................................................................................................146 Lesson 4.7. Printing a list of customers
Validate the product modifications.....................................................................................................147 Overview.............................................................................................................................................................. 216
Test of product modification................................................................................................................149 Creating the report............................................................................................................................................. 216
Creating a new product......................................................................................................................................150 Starting the report print by programming........................................................................................................223
Adding a button....................................................................................................................................150
Addition into the data file.....................................................................................................................151 Lesson 4.8. Statistics: Chart and Pivot Table controls
Test of product addition.......................................................................................................................152 Overview..............................................................................................................................................................227
Viewing the records..............................................................................................................................153 Displaying data in a Chart control.....................................................................................................................227
Selecting the data that will be displayed in the Chart control............................................................227
Lesson 4.3. Simple search and record browse Creating the Chart control.................................................................................................................. 230
Overview..............................................................................................................................................................155 Creating summary tables with the Pivot Table control...................................................................................234
Modifying the window: using a Tab control......................................................................................................156 Creating the Pivot Table control.......................................................................................................... 235
Creating the Tab control.......................................................................................................................156 Testing the Pivot Table control.............................................................................................................237
Modifying the Tab control.....................................................................................................................158
Implementing the search..................................................................................................................................160
Area for displaying the information found...........................................................................................160
Exact-match search..............................................................................................................................161
Generic search.....................................................................................................................................165
Browsing forms.....................................................................................................................................167
Window test..........................................................................................................................................170
6 Summary Summary 7
Lesson 4.9. Sending an email Lesson 4.14. Deploying the application
Overview..............................................................................................................................................................240 Overview..............................................................................................................................................................286
A window for sending emails............................................................................................................................. 241 Creating the executable.....................................................................................................................................286
Creating the window.............................................................................................................................241 Creating the setup..............................................................................................................................................291
Creating the controls used to configure the sending..........................................................................241 Installing an application....................................................................................................................................294
Creating the controls used to type the email characteristics.............................................................243 The different types of deployment....................................................................................................................296
Sending the email................................................................................................................................245 Overview .............................................................................................................................................. 296
Improving the window........................................................................................................................................ 247 Setup with network update................................................................................................................. 296
Closing the window..............................................................................................................................247 Setup with Internet update................................................................................................................. 298
Formatting............................................................................................................................................247 Multisite setup..................................................................................................................................... 298
Non-modal opening of window............................................................................................................248
Lesson 4.15. Distributing "Reports and Queries" with your applications
Lesson 4.10. Identifying the user: the user groupware Overview of "Reports and Queries"...................................................................................................................301
Overview..............................................................................................................................................................251 Starting "Reports and Queries".........................................................................................................................301
Integrating the user groupware.........................................................................................................................252 Distributing "Reports and Queries" with your applications.............................................................................301
Configuring the user groupware........................................................................................................................255 Configuring project.............................................................................................................................. 302
Creating users and groups.................................................................................................................. 255 Configuring analysis............................................................................................................................ 302
Defining the rights................................................................................................................................257 Configuring reports............................................................................................................................. 303
Application test.................................................................................................................................... 259 Configuring queries............................................................................................................................. 304
Disabling the management of user groupware...............................................................................................260 Creating the executable and distributing the application................................................................. 304
Installing and using "Reports and Queries".....................................................................................................306
Lesson 4.11. Re-use code via the external components Installing the application.................................................................................................................... 306
Overview..............................................................................................................................................................262 Application test.................................................................................................................................... 308
Teamwork............................................................................................................................................ 263 Conclusion........................................................................................................................................................... 310
The huge projects................................................................................................................................ 263
The databases accessed by several projects.................................................................................... 263 Lesson 4.16. Managing multiple languages
The processes used in several projects............................................................................................. 263 What is a multilingual application?..................................................................................................................312
The ability to distribute a feature or set of features........................................................................... 263 Choosing the project languages........................................................................................................................312
Multi-product external component..................................................................................................... 263 Localizing the analysis.......................................................................................................................................314
Step by step.........................................................................................................................................................264 Localizing the project elements........................................................................................................................ 316
Step 1 : Creating an external component........................................................................................... 264 Localizing an image..............................................................................................................................317
Step 2 : Using the external component.............................................................................................. 268 Localizing controls...............................................................................................................................318
Distributing an external component................................................................................................................. 271 Localizing a programming message....................................................................................................318
Standard distribution...........................................................................................................................271 Localizing menus.................................................................................................................................319
Professional distribution......................................................................................................................272 The translation tools...........................................................................................................................................320
Direct input of translations................................................................................................................. 320
Lesson 4.12. Consuming a Webservice Translation with WDMSG and WDTRAD..............................................................................................321
Overview.............................................................................................................................................................. 274 Other elements to translate: the framework messages.....................................................................321
Practical example................................................................................................................................. 274 Programming the change of language.............................................................................................................322
Importing a Webservice..................................................................................................................................... 274 Adding a menu option......................................................................................................................... 322
Consuming a Webservice.................................................................................................................................. 277 Programming....................................................................................................................................... 322
Project test........................................................................................................................................... 323
Lesson 4.13. Monitor the evolution of your applications
Overview..............................................................................................................................................................280
The dashboard....................................................................................................................................................280
Automatic tests..................................................................................................................................................281
8 Summary Summary 9
Lesson 4.17. SCM Part 6 - Optimizing and debuging a project
Introduction ........................................................................................................................................................325
SCM (Source Code Manager).............................................................................................................................325
Principle of SCM.................................................................................................................................. 325 Lesson 6.1. Overview
Creating the repository........................................................................................................................ 326 Overview..............................................................................................................................................................366
Integrating a project in SCM..............................................................................................................................327 Opening project................................................................................................................................... 366
Adding the project into SCM................................................................................................................327
Opening a project from SCM............................................................................................................... 329 Lesson 6.2. Project audits
Configuring SCM...................................................................................................................................331 What is an audit?................................................................................................................................................368
Handling the project via SCM............................................................................................................................331 Static audit..........................................................................................................................................................368
Modifying a project parameter............................................................................................................331 Procedure not run................................................................................................................................370
Modifying a project window................................................................................................................ 332 Orphan element...................................................................................................................................371
Checking the checked-out element back in....................................................................................... 335 Cleaning the project.............................................................................................................................372
Synchronizing the project................................................................................................................... 336 Dynamic audit.....................................................................................................................................................372
Offline mode........................................................................................................................................ 336
SCM administrator...............................................................................................................................337 Lesson 6.3. Performance profiler
Disconnecting from SCM.................................................................................................................... 338 Overview.............................................................................................................................................................. 377
Conclusion ..........................................................................................................................................................338 Starting the performance profiler..................................................................................................................... 377
Studying the result.............................................................................................................................................378
10 Summary Summary 11
Lesson 7.3. Handling external files Lesson 7.8. The FTP
Overview..............................................................................................................................................................400 Overview..............................................................................................................................................................421
Handling text or CSV files...................................................................................................................................400 Connecting to an FTP server..............................................................................................................................421
Overview .............................................................................................................................................. 400 Sending a file......................................................................................................................................................422
Practical example................................................................................................................................ 400 Listing the files found on an FTP server............................................................................................................423
Handling directories...........................................................................................................................................401 Retrieving a file...................................................................................................................................................424
Practical example.................................................................................................................................401 Disconnecting from an FTP server....................................................................................................................424
Handling XML files..............................................................................................................................................402
Overview .............................................................................................................................................. 402 Lesson 7.9. The OOP
Practical example................................................................................................................................ 403 Concepts..............................................................................................................................................................426
Handling XLS files...............................................................................................................................................403 The classes.......................................................................................................................................... 426
Practical example................................................................................................................................ 404 The objects.......................................................................................................................................... 426
The members...................................................................................................................................... 426
Lesson 7.4. Dynamic compilation The methods........................................................................................................................................ 426
Overview..............................................................................................................................................................406 Concept of inheritance........................................................................................................................ 426
Example...............................................................................................................................................................406 Constructor and Destructor.................................................................................................................427
Data encapsulation..............................................................................................................................427
Lesson 7.5. Windows event Example ...............................................................................................................................................427
Introduction.........................................................................................................................................................409 Creating an object-oriented program..................................................................................................427
Practical example................................................................................................................................ 409 Simple example..................................................................................................................................................428
Optional events proposed by WINDEV..............................................................................................................409 Declaring a class................................................................................................................................. 428
Windows events.................................................................................................................................................. 410 Describing the methods...................................................................................................................... 429
Example: Detect the click on a List Box control..................................................................................411 Declaring and handling the objects................................................................................................... 430
UML diagram.......................................................................................................................................................431
Lesson 7.6. The threads
Definition.............................................................................................................................................................414
Example...............................................................................................................................................................414 Part 8 - Appendices
Lesson 7.7. The sockets
Appendices 1. Vocabulary
Overview.............................................................................................................................................................. 416
Server application: for a simplified server........................................................................................................ 416 Main terms used.................................................................................................................................................436
Creating the socket..............................................................................................................................416
Exchanging data...................................................................................................................................416
Appendices 2. Using SQL data
Closing the socket................................................................................................................................ 417 Overview..............................................................................................................................................................443
Client application................................................................................................................................................ 417 Creating the project............................................................................................................................................443
Connecting to the server...................................................................................................................... 417 Creating the analysis..........................................................................................................................................445
Exchanging data................................................................................................................................... 417 Generating the analysis..................................................................................................................................... 447
Ending the communication.................................................................................................................. 417
Practical example...............................................................................................................................................418 Conclusion
Example test.........................................................................................................................................418
Studying the code used.......................................................................................................................418
12 Summary Summary 13
Introduction
Preliminary points
Caution: This is a tutorial. We advise you to refer to the online help when using WINDEV.
The purpose of this tutorial is to help you discover WINDEV, get familiar with the editors and learn
the WINDEV concepts.
This tutorial does not cover all the features in WINDEV.
Spend at least a few hours to follow this tutorial and learn WINDEV: it is a good investment!
If you try to start developing an application without following this tutorial, you will lose time, much
more than the few hours spent on this tutorial.
As WINDEV is constantly evolving, the images of the windows in the tutorial may differ from the
windows displayed in the product during the various operations.
Tutorial overview
This tutorial has been designed to progressively teach you how to use WINDEV. By following this
tutorial:
• you will discover the main concepts explained informally; these are the concepts you must
learn and understand.
• you will also be asked to perform operations that illustrate the concepts just explained.
As you progress through the tutorial, if you want to take a closer look at a concept or if you want to
get more details about a programming function, see the online help (accessible from the editors).
The size of a lesson is not necessarily proportional to its relevance...
And don’t forget to take a look at the examples supplied with WINDEV: they are very instructive!
14 Summary Introduction 15
:
15
Legend of the symbols in this tutorial ▶ The help can be displayed:
• in an Internet browser, if you have access to Internet:
This symbol indicates the duration of the lesson. Please note that the actual time
may vary according to your level of experience.
An example is available to complement the lesson. The examples are available in the
WINDEV home page (Ctrl + <).
This symbol introduces a "Tip": reading the associated text is strongly recommended.
The tutorial may have evolved since this document was printed. Feel free to
consult the online version (http://doc.windev.com).
16 Introduction
16 : Introduction 17
:
17
If you are familiar with WINDEV 24
We advise you to check the online help on Internet rather than the local online
help. Indeed, the online help on Internet is updated on a regular basis. If you are familiar with WINDEV 24, following this tutorial can only beneficial: it’s a good opportunity
The online help of WINDEV, WEBDEV and WINDEV Mobile on Internet is available to "review" the WINDEV features!
Remark
from any computer equipped with an Internet access, without the product being
necessarily installed.
What is WINDEV used for?
Each Web user can add comments about the documentation pages: personal
notes, examples, links, ... WINDEV is an IDE (Integrated Development Environment). It allow you to develop applications in
many fields:
Note: If you have no access to Internet, you have the ability to start the local help from the product: • Stock management, inventory, product tracking,
1. On the "Home" pane, in the "Environment" group, expand "Options" and select "General • Adjustment and monitoring of machines on an assembly line,
options of WINDEV". • Taking orders for fast processing in a temporary outlet (fairs, schools, booth, ...),
2. In the "Help" tab, select: • Customer forms,
• the access mode to the help. • Help with making snap decisions on a cell phone,
• Checking the identity of visitors at an event: trade fair, presentation of products, ...
• On-call doctors or vets,
• Taking information in a temporary outlet: trade fair, street poll, stadium, ...
WINDEV is an integrated development environment that includes all the tools required to develop
an application.
Unlike other programming languages, there is no need to find and add modules to be able to
design, check and install an application.
The 5GL (5th Generation Language) of WINDEV, named WLanguage, will surprise you by its
simplicity: a few hours are all you need to get the hang of it, a week is usually all it takes to fully
master its potential!
No more programming hassle, WLanguage is available in English and in French!
• the help content: WINDEV, WEBDEV and WINDEV Mobile common help or help only for the
product currently used.
18 Introduction
18 : Introduction 19
:
19
PART 1
Discovering
WINDEV
20 Introduction
20 :
Lesson 1.1. Discover WINDEV
• Starting WINDEV.
Estimated time: 5 mn
1. Menu of editors, displayed in ribbon format (we’ll see how to use it in the next paragraph).
2. Current editor (window editor in this case). This space allows you to see the element currently
created or modified in WYSIWYG (What You See Is What You Get).
3. Panes. The WINDEV interface includes several horizontal and vertical panes allowing you to
quickly access different types of information. For example:
• the "Project explorer" pane (displayed on the right) is used to list all project elements by
category.
• the search pane (displayed at the bottom) is used to perform searches in the entire project
and in its elements.
These panes can be hidden by pressing Ctrl + W if necessary.
4. Bar of opened documents. This bar is used to quickly see all opened elements. A simple click
on the button corresponding to the element displays it in its own editor.
24 Part 1: Discovering WINDEV Part 1: Discovering WINDEV 25
The menu bar (ribbon) in details The option area (3)
The menu bar of WINDEV is presented like a ribbon. This ribbon includes panes in which the
different options of editors are grouped.
We are going to take a closer look at the main ribbon elements, as well as how we will be using it
in this tutorial.
The options displayed in the ribbon differ according to the selected pane. Several types of options
are available:
• Options to check.
• Buttons to click.
• Button with arrow used to expand the options. Two types of buttons with arrow are available:
• the buttons with arrow used to expand a menu.
The different ribbon elements • the buttons with arrow used to expand a menu (click on the arrow) or to perform a default
action (click on the button icon).
The ribbon includes 3 areas: The options are organized by group. Each group of options has a name and it can also include a
• the button area, on the left (1). group button . This button is used to perform a specific action according to the current group:
• the pane area, at the top (2). display the description of current element, display the help, ...
• the option area (3). In this tutorial, to identify a menu option, we will be talking about panes and groups. For example:
Let’s take a closer look at these areas. To display the help, on the "Home" pane, in the "Online help" group, click "Help".
The button area (1)
The environment colors
The button area groups the quick access buttons. These buttons are used
to perform the most usual operations, common to all editors: save, open, The environment is using a light theme by default.
create, ... Several other themes are also available:
The product logo is used to display the "About" window, the custom menus • Light theme, grey ribbon. In this mode, the menu bar is not colored anymore: it is grayed.
and the drop-down menus found in the former interface of editors. • Gray theme. In this mode, the environment and the interface windows are displayed on a light
The arrow at the top right of the button area allows you to find the toolbars gray background.
and drop-down menus of the old editor interface. • Dark theme. In this mode, the environment and the interface windows are displayed on a black
or dark gray background.
The pane area (2) ▶ To modify the theme used by the environment:
1. On the "Home" pane, in the "Environment" group, expand "Options" and select "General
options of WINDEV".
The different ribbon panes are used to access the options of different editors for the current 2. In the "Editor" tab, in the "Themes" area, select the theme to use.
project. Several types of panes are available: 3. Validate. The theme will be taken into account during the next start of WINDEV.
• the current pane: The name of the pane appears in bold and is underlined by an orange line.
• the popup panes, specific to the current element: The pane name is displayed in blue. ▶ To improve the readability of this manual, the light theme will be used for the different images
• the available panes: The pane name is displayed in black. that illustrate the operations to perform.
▶ To continue this lesson, we are going to close the current project:
1. On the "Home" pane, in the "General" group, expand "Close" and select "Close the project".
2. Save the modified elements if necessary.
3. The WINDEV home page is displayed.
Remark
Windows are used to display or type information on the screen. The user can
This lesson will teach you the following concepts directly act on the windows via controls, buttons, ...
Important
In this section, we will focus on the creation of simple windows. The "WD My
First Windows" project is an empty project that was already created. The project
creation will be presented in another lesson.
Answer
created in this part (as well as the ones created in part 2). To open the corrected
project, in the home page, click "Tutorial" and select "My first windows (Answer)".
Remark
• a window starts with "WIN_",
• a Button control starts with "BTN_",
• etc.
This window allows the user to type his first name and to display a welcome message with the
If you do not want to use this code style, you can simply disable it: on the
"Display" button.
"Project" pane, in the "Other actions" group, expand "Code style" and uncheck
You may think this is too basic but we advise you to create this window. You may well be surprised "Use code style".
by how intuitive and easy it is to use the WINDEV editor. Furthermore, this window will teach you
principles that are fundamental for the rest of this tutorial.
7. In this example, we want to use a shorter window name: replace "WIN_My_first_window" by
Creating the window "WIN_Welcome".
▶ To create the window:
1. Click among the quick access buttons of the WINDEV menu:
2. The window for creating a new element is displayed. This window is used to create all
elements that can be associated with a project. 8. Click "OK" to validate the information shown in the save window.
3. Click "Window" then "Window". The window creation wizard starts. Entering and displaying the value
4. Select "Blank" in the list of "standard" windows displayed on the left. The "Phoenix" skin
template is selected by default in the list of skin templates on the right. You can choose another To type and display the value, you must create:
skin template proposed in the list. • a control where the user will type his first name. Therefore, this type of control is an "edit
control".
Skin templates allow you to quickly create outstanding interfaces. A skin • a Button control to display the first name entered.
Remark
template defines the window style as well as the style of all controls that will
be used in this window. Thus, there is no risk of obtaining an ugly interface.
5. Validate the window creation wizard ("OK" button). The window is automatically created in the
editor. The window for saving an element is displayed. This window is used to specify:
• The element title. For a window, this title will be displayed in the title bar of window.
• The element name. This name corresponds to the logical element name. This name will be
used to handle the element by programming.
• The element location. This location corresponds to the directory in which the element is
saved.
are also available among the Business controls. The different controls can Remark: You also have the ability to manually enlarge the input area of control:
be tested directly: simply click the "GO" icon that appears when the control is 1. Select the control.
hovered over. 2. Position the mouse cursor above one of the handles found on the right of control (small
square). The mouse cursor turns into arrow.
2. In the search box at the top of the list of preset controls, enter "Simple text Edit". The 3. Click with the left mouse button and keep the button down during the move used to enlarge
corresponding control appears in the list. the control.
3. Click the "Simple text Edit" control. The control currently created follows the mouse 4. Release the mouse button once the control was resized.
movement.
4. Move the mouse toward the position where the control will be created in the window (at the ▶ To create the "Display" Button control:
top of window for example). To drop the control in the window, simply click again. 1. On the "Creation" pane, in the "Usual controls" group, click .
5. Right-click the control that was just created. The popup menu of control is displayed. Select 2. Position the control in the window. Create the Button control at the desired location with a
"Description" from the popup menu. The description window of edit control is displayed. click (on the right of edit control for example).
6. Modify the control characteristics by entering the following information: 3. Click the control that was just created. The text displayed in the control becomes editable.
To quickly edit the control caption, you also have the ability to:
Tip
• Select the control.
• Press the Enter or Space key.
4. Type the caption: "Display". The name of the Button control automatically becomes "BTN_
Display".
5. You can see the name of the control:
• in the tooltip displayed when the control is hovered by the mouse cursor:
Remark
If you are using a 4K screen, the editor elements are automatically
zoomed. The zoom level used depends on the Windows display settings.
▶ We are going to display the text typed in a dialog box (a mini-window proposed by the system).
To do so, we will be using our first WLanguage function: Info.
Remark
Main WLanguage conventions Therefore, in the code editor that is using the light theme:
• No ending character for end of line is used in WLanguage. • the WLanguage functions are colored in blue,
• The ’//’ characters are used to comment out code lines. These code • the character strings (between quotes) are colored in purple,
lines are not interpreted. They provide better code readability. • the names of controls are colored in cyan.
• In the WLanguage functions, the parameters passed to the function are
Remark
enclosed in brackets. Info displays the message passed in parameter on one or more lines. Our message is built
• The coma character corresponds to the separator. from the text "Hello " and from the value of "EDT_FirstName" control. The "," sign separates the
• WLanguage is not case sensitive. parameters of Info. Each parameter is displayed on a different line.
• The "space" characters are not interpreted.
Remark
• The dot is the decimal separator. In this example, the text is displayed in a system window but it can also be
• The name of WLanguage functions is in English. It is available in French. displayed it in a window created with WINDEV.
• The name of WLanguage functions is using a prefix in order to group the
functions by family ("Win" for the functions handling windows, "email" for
the functions handling emails, ...). ▶ Let’s now run the window test:
1. Click among the quick access buttons (or press F9).
1. Select the "Display" Button control with the mouse. 2. The window that was just created is automatically saved then it is started in execution.
2. Display the popup menu of control (right mouse click).
3. Select "Code". This option opens the WINDEV code editor. This editor is used to type all
WLanguage statements.
The code editor proposes different events for each type of control. These are
the WLanguage events related to the control.
3. Type your first name.
Remark
This is why the code style is so important. All elements handled in the application
code use the same standard so they can be easily identified when writing code.
Remark
Remark
• Compilation information: The information explains the compiler choices or cause problems when performing a search for example.
provides tips for improving the code. WINDEV proposes to manage an input mask for a control. The input mask is
• UI errors: The UI compilation errors inform you of the possible problems used to automatically format the value typed, without programming.
detected in your interfaces: images not found, truncated captions, ...
• Programming standard errors: These errors inform you when the ▶ To modify the input mask:
programming standard selected in the project description is not respected 1. Double-click the "First name" control. The control description window appears.
("Compilation" tab).
2. In the "General" tab, expand the "Input mask" list and choose "1st letter in caps.".
• Automatic test errors: These errors signal a problem when running automatic
tests.
Tips for improving the interface and the ergonomics will be presented in a next
chapter. window). The editor is redisplayed.
▶ Close the "WIN_Welcome" window displayed in the editor: on the "Home" pane, in the "General"
group, click "Close".
Remark
Describing the data files in the analysis does not mean that they are created.
Two types of controls have been used in this lesson: an Edit control and a Button The data files are physically created when running the application.
control.
WINDEV proposes more than fifty controls. Several unit examples are available,
allowing you to discover the use of each type of control. One or more WINDEV projects can be linked to the same analysis. In this case, we talk of shared
▶ To open a unit example: analysis. For example, an application for business management can be divided into several
executable modules. Each module is using the same analysis (at run time, each executable can
1. Display the WINDEV home page (press Ctrl + <).
Remark
▶ Close the project: on the "Home" pane, in the "General" group, expand "Close" and select "Close
the project".
After these exercises, let’s talk about the main WINDEV concepts and about the terminology
specific to WINDEV.
Main concepts
Project 2 Project N
WINDEV allows you to easily create an application. But what is an Application?
An application is a tool used to automatically perform tasks, actions. An application includes an
executable program (or a set of executable programs), libraries, data files, ...
An executable program is a file made of elements that can be directly handled by the user Classes Style Windows Classes Style Windows
sheet and controls sheet and controls
(windows, printed reports, ...). It is started by the end user of an application.
Terminology
To create an executable, WINDEV proposes to create a project. A project links and organizes the
different program elements. The executable program will be created from the project. As already seen, a WINDEV project (linked to an analysis if necessary) is used to create an
application. Before we actually start working with WINDEV, let’s go back to the vocabulary used
in WINDEV. Indeed, several terms are specific to WINDEV and they may not have the same
If your application is using data, WINDEV allows you to define the database structure via the significance as the the ones used in the other tools.
analysis. The WINDEV analysis contains the description of the data files (also known as "Tables" in
several databases). These data files will contain the application data. The following terms are used in the analysis:
• Data file: The analysis is used to describe the structure of database files. A "Data file"
corresponds to a "table" in some databases.
In WINDEV, "Table" represents a graphic object used to see the content of a data file in a table
and/or to enter rows. A table can be used to type the order details for example.
• What is a variable?
• The different types of variables.
• The scope of variables.
• The String type in details.
• The Array type in details.
Estimated time: 1 h
In a programming language, a variable is used to store data. These memory sections contain The variable must be declared (which means created) before it can be used.
strings, numbers, etc. • Example of simple declaration:
The variables are used to perform calculations, to perform comparisons or to store information Price is currency
that will be used later.
• Price represents the variable name.
• is is used to declare the variable. The everyday language is used in WLanguage.
• currency corresponds to the variable type.
• Example of multiple declaration:
LastName, FirstName are strings
In WLanguage, the " character (double quote) is the character used to delimit a
Remark
character string. In the above example, the doubles quotes are used to assign
the Doe value to the LastName variable.
The variable content can be read and handled: all you have to do is use the name given to the
variable to access it.
The following example is used to read and display the content of Price variable on the screen:
A variable is represented by:
• a name: Name given to the variable so that it can be used by the language. Info(Price)
• a type: Nature of data stored in the variable (see The types of variables).
• a value: Information stored in the variable.
• a scope: Limit for using the variable in the program (see The scope of variables). The scope is
mainly defined by the location where the variable is declared.
Use the type corresponding to the information that must be stored. Therefore,
you will optimize the memory and you will avoid calculation or process errors Local scope
when using variables in the WLanguage functions. Local means that the variable has a limited visibility in the code. The variable is visible in the
process where it was declared. This makes it possible to restrict the use of variable to the process.
Most of these types of variables will be used in this tutorial.
See the online help regarding the relevant type for more details. Summary scope diagram
Other types are available, such as arrays, structures, dates, times, ... Each level accesses the variables of
Advanced variables are also available. These advanced types group all higher levels.
Remark
Project
characteristics of the element currently used in a single variable.
Advanced types can be used to handle XML documents, emails, XLS files, ...
This type of variable will be used later in this tutorial. Global variables
Global procedures
Processes
Two types of scope are available:
• Global.
Local variables
• Local.
Global scope A variable is global when it is declared:
• in the "Initializing" event of the project (or in the "Declaration" event of the set of procedures).
Global means that the variable has an extended visibility in the code. The variable is visible The variable is global to the project.
outside the location where it was declared. Several levels are available:
• in the "Global declarations" event of the window, page or report. The variable is global to the
• Project and Set of procedures, element (window, page or report) where it was declared.
• Window, Mobile Window, Page, Report. In all other cases, a variable is local to the process or event where it is declared.
Several mathematical operators can be used to perform calculations on variables: • It is very convenient to name the variables with long names (and to avoid short names such
as i, j, k, ...). When reading the program again, you will be able to easily remember the variable
• + to perform an addition. purpose.
• - to perform a subtraction. • To define the name of variables, all Unicode characters (including the accented characters) are
• * to perform a multiplication. accepted. Meaning improved readability! Caution: some characters are not allowed: space, =,
• / to perform a division. dot, comma, ...
• It is very important to give the proper type to the variable according to its use. For example, to
Other operators can be used to perform calculations: store several digits, you may have to:
• ++ to increment from 1 (add 1 to the variable). • use a numeric variable if this variable must be used for calculations.
• - - to decrement from 1 (subtract 1 from the variable). • use a string variable if this variable must be used to store digits without performing
• += to assign by adding a value. calculations (to store the social security number for example).
• += to assign by subtracting a value.
Details of variable type: the String variables
Examples:
The String variables are the most often used types of variables.
// Declaration of variables Let’s present in details some features available for this type of variable.
Cnt is int
V1 is int The String type
Res is numeric
The String type is used to store and handle characters and character strings.
// Assignment
Cnt = 10 We have already seen how to initialize a string variable:
V1 = 3 LastName is string
// Assign a string variable
// Use of operators LastName = "Doe"
Cnt = Cnt + 3 // Cnt is equal to 13
Cnt ++ // Cnt is equal to 14 There is no need to declare the string length: this length automatically adapts when using the
Cnt -= 8 // Cnt is equal to 6
Cnt = Cnt * V1 // Cnt is equal to 18
variable.
Res = Cnt / 5 // Res is equal to 3.6
To initialize a string variable with a text on several lines, use the following syntax:
Comparison operators are also available:
<Variable name> = [
• < less than. <Text of line 1>
• > greater than. <Text of line 2>
• <= less than or equal to. ]
• >= greater than or equal to. For example:
Tip
• <> different from. MyString is string
• = equal to. MyString = [
Other operators are available. See the online help for more details (keyword: "Operators"). Example of
multi-line string
]
In addition to the main comparison operators, several powerful operators are used to manage the
extractions and concatenations in advanced mode.
Some examples: This window is used to:
• " + ": to concatenate strings. • find a string inside another one.
• " ~= ": to check the flexible equality. • compare two strings.
Specific WLanguage functions are used to perform various operations: search, extraction, size,
switch to uppercase characters, ... ▶ Create a new blank window:
Examples: 1. Click among the quick access buttons. The window for creating a new element is
displayed: click "Window" then "Window". The window creation wizard starts.
str is string 2. Select "Blank" and the "Phoenix" skin template.
str = "WINDEV is a great tool"
// Extract a sub-string from left 3. Validate. The window is automatically created in the editor. The window for saving an element
Info(Left(str, 6)) // Displays "WINDEV" is displayed.
// Extract a sub-string from right 4. Specify the element title: "Variables". The element name ("WIN_Variables") is automatically
Info(Right(str, 4)) // Displays "tool" proposed.
5. Click on the "OK" to validate the information displayed in the save window.
The different WLanguage functions can be nested. A WLanguage function can
be used as parameter of another WLanguage function. ▶ To create the edit control containing the string:
Remark
For example: 1. On the "Creation" pane, in the "Usual controls" group, click .
2. Click the location where the edit control will be created (at the top, in the middle of the
Info(Middle(Left(str, 13), 8, 2)) // Displays "is" window for example).
3. Right-click the control and select "Description".
4. In the "General" tab, specify:
See the help about the character strings and about the functions for handling character strings for • The control name: "EDT_Text".
more details.
• The control caption: "Text".
Practical example 5. Select the "Content" tab. This tab is used to define the default value of edit control. Type
"WINDEV is a great tool".
To handle the different concepts of this lesson, we are going to create different windows. These 6. Validate the description window. The text typed is directly displayed in the control.
windows will be created in the "WD My first windows" project.
▶ The control content is truncated in the editor. To display the control properly:
▶ Open the "WD My First Windows" project if necessary.
To do so, in the home page (Ctrl + <), click "Tutorial" and select "My first windows (Exercise)". 1. Select the control.
Caution: WINDEV proposes to open the local copy or overwrite the project with the source 2. Enlarge the control in width with the sizing handles in order for the content to be entirely
version. To continue working on your project started in the previous section, choose "Open the displayed.
local copy".
3. Modify the content of edit control (by replacing WINDEV by WD for example) and click "Find a 3. Validate the message.
string". The WINDEV word is not found. 4. In the edit control, type "WINDEV" in uppercase characters and click "Compare two strings".
4. Close the window. The WINDEV word is found. Validate the message.
5. Modify the content of edit control (by replacing WINDEV by WINDEV for example) and click
"Compare two strings". The WINDEV word is also found. Validate the message.
6. Close the window.
Tip
Specific WLanguage functions are used to handle the arrays and their elements. These functions // Initialization with
start with "Array". // the names of the days of week
arrDay = ["Monday", "Tuesday", "Wednesday", ...
"Thursday", "Friday", "Saturday", "Sunday"]
Declaration
The declaration of an Array variable is performed as follows:
<Array name> is array of <Type of array elements> See the online help for more details (keyword: "Array").
For example: Advanced arrays
arrString is array of strings Advanced arrays are also available: array with several dimensions, array of arrays, associative
arrInt is array of int
array, array of structures, array of objects, ...
See the online help for more details (keyword: "Array").
Filling an array and accessing the elements
During its declaration, the array is empty. The elements are added by Add via the following syntax:
Add(<Array name>, <Element value>)
Example:
// Create an array of strings
MyArray is array of strings
// Add elements
Add(MyArray, "WINDEV")
Add(MyArray, "WEBDEV")
Add(MyArray, "WINDEV Mobile")
// Display the content of third element
Trace(MyArray[3]) // Displays "WINDEV Mobile"
WLanguage code example: The following code selects a number at random and displays a
message according to the value.
Tot is Currency
// Selects a number at random between 100 and 4000
Tot = Random(100, 4000)
IF Tot>2000 THEN
Info("The amount is greater than 2000")
ELSE
Info("The amount is less than or equal to 2000")
END
Remark: Several code lines can be run during the process corresponding to a condition. In this
case, the following syntax must be used:
IF <Expression to check> THEN
Code line 1
Code line N
ELSE
Code line 1
Code line N
END
In our example, ..Day is used on the D variable to get the day of the date.
The online help of a function or property can be displayed at any time by
pressing F1. See "How to access the online help ?" for more details.
Tip
control).
3. Click the control that was just created. The text displayed in the control becomes editable. IF MySelf = True THEN
Type the caption: "Close".
4. Press Enter to validate the input.
• The Check Box control is a 2-state control: checked/unchecked. It corresponds in
▶ This Button control is used to close the window. We are going to type the corresponding
programming to a Boolean variable. If the control is checked, its value is set to True ; if the
WLanguage code:
control is unchecked, its value is set to False.
1. Select the "Close" Button control.
• This code tests the value of the Check Box control.
2. Press F2: the code editor displays the events associated with the control.
• If Check Box control is checked, Button control BTN_Close becomes visible using
3. Write the following WLanguage code in the "Click BTN_Close" event: ..Visible.
Close() • If the Check Box control is unchecked, the Button control BTN_Close becomes invisible.
4. Close the code window (click X at the top right corner of code editor).
Close is used to close the current window.
4. Close the code window (click X at the top right corner of code editor).
2. In the window in execution, click the check box. The "Close" button becomes visible.
3. Click the "Close" button: the window is closed and the window editor is displayed.
Creating the window controls for the conditional SWITCH statement
Two controls must be created: 5. Write the following WLanguage code:
• a Radio Button control used to select the value to check.
SWITCH RADIO_Abbreviated_Titles
• a Button control used to run the test. // Mr
CASE 1
▶ To create the Radio Button control: Info("You’ve selected Mr")
1. On the "Creation" pane, in the "Usual controls" group, expand "Radio button" (click the arrow). // Mrs
The list of default Radio Button controls appears. CASE 2
Info("You’ve selected Mrs")
2. In the search box at the top of the list of controls, enter "Title". Click the first proposed control // Miss
(with "M"). CASE 3
3. Click inside the window to create the control (below the Check Box control created Info("You’ve selected Miss")
beforehand for example). // Other
CASE 4
▶ To create the "Test" Button control: Info("You’ve selected Other")
END
1. On the "Creation" pane, in the "Usual controls" group, click .
2. Click the location where the control will be created (on the right of Radio Button control, for Let’s take a look at this WLanguage code:
example). • RADIO_Abbreviated_Titles corresponds to the name of the Radio Button control.
3. Click the control that was just created. The text displayed in the control becomes editable. • The Radio Button control is a control proposing several options (4 in our case). A single
Type the caption: "Test". option can be checked at a time. The Radio Button control corresponds in programming to
4. Press Enter to validate the input. an Integer variable. Each menu option is associated with a value. If this option is checked,
the Radio Button control takes for value the identifier of checked option.
SWITCH statement • This code tests the value of the Radio Button control. A message is displayed according to
In our example, the "Test" button is used to check the selected value and display a message. the value of Radio Button control.
6. Close the code window (click X at the top right corner of code editor).
▶ We are going to enter the WLanguage code associated with the "Test" Button control:
1. Select the "Test" Button control.
2. Press F2.
3. Write the following WLanguage code in the "Click BTN_Test" event:
SWITCH RADIO_Abbreviated_Titles
Estimated time: 1 h
Tip
FOR Subscript = Start Value TO End Value
Process to run Example:
END LOOP(10)
// Process to run
For example, the following code runs the process 2000 times: END
FOR Cnt = 1 TO 2000
// Process to run
END
Remark: An increment step of subscript can be defined via the STEP keyword. For example, the The WHILE statement
following code runs the process 2000 times and the Cnt variable decreases by 10: The WHILE statement and the LOOP statement operate according to the same principle. The
FOR Cnt = 2000 TO 1 STEP -10 difference is that the test of exit condition is performed BEFORE running the loop code. This test
// Process to run is used to compare a variable. This variable starts from a start value and it is modified in the loop
END until it reaches the value that triggers the exit from the loop.
proposes to use the image catalog. This image catalog is started via the 5. Adapt the control size.
"Catalog" option (available by clicking the button). This catalog contains
6. Display the events associated with the control (F2).
hundreds of images, cliparts, ...
7. Write the following code in the "Click" WLanguage event:
// Moves the image horizontally by 300 pixels
FOR i = 1 TO 300
IMG_NoName1..X++
END
This code is used to modify the X coordinate of Image control (..X) in a loop from 1 to 300. At
each loop turn, the X coordinate is increased by one pixel.
This code is used to modify the X coordinate of Image control (..X). At each turn, a condition is checked.
8. Close the code window (click X at the top right corner of code editor). If this condition is true, the program exits from the loop. In our case, the condition is as follows:
• the position of the Image control is 0,
▶ Let’s now create a Button control to move the image until it reaches the right border of the
window. To do so, we will be using the WHILE statement of WLanguage. • the position of the Image control is less than 0 (used to manage the case where the user
presses the button several times).
1. On the "Creation" pane, in the "Usual controls" group, click .
2. Click the location where the control will be created (for example, to the right of the "FOR When typing this code, the LOOP statement may be underlined by a green
statement" control).
Remark
line and a warning may appear in the pane of compilation errors.
3. Click the control that was just created. The text displayed in the control becomes editable. This warning reminds you that an exit statement must be found in the
Type the caption: "WHILE statement". loop code to avoid an infinite loop.
4. Press Enter to validate the input.
5. Adapt the control size.
8. Close the code window (click X at the top right corner of code editor).
6. Display the events associated with the control (F2).
7. Write the following code in the "Click" WLanguage event: Window test
// Moves the image horizontally until you reach the window side ▶ Let’s now run the window test:
WHILE IMG_NoName1..X < WinInWidth() - IMG_NoName1..Width
IMG_NoName1..X++ 1. Click among the quick access buttons (or press F9).
END 2. The created window is started in execution.
3. Click the different buttons.
This code is used to modify the X coordinate of Image control (..X) until a condition is true. In our
case, this condition is as follows: the position of the Image control (..X) must correspond to the
width of the window minus the width of the Image control.
When a code line is too long to be displayed in the window of code editor, you
Tip
Scope of procedures
Remark
The procedures comply with the scope rules presented for the variables (see
Estimated time: 1 h
"The scope of variables").
Global procedure
Local procedure
To create a local procedure, you must:
1. Select the element associated with the procedure (window, page, etc).
2. Create a local procedure (via the "Project explorer" pane, expand the element name, "Local
procedures" folder).
3. Give a name to the procedure.
4. Type the code of local procedure. The procedure code has the following format:
PROCEDURE <Name of local procedure>()
You have the ability to pass from 0 to several values in parameter to a procedure. These values • The WLanguage code used to call the procedure is:
can have any type (as with the variables). T is int
The parameter is specified in the procedure declaration in the format of a variable. For example, T = 12 // T is equal to 12 before the call
for the Multiply10 procedure, the WLanguage procedure code is: Test_address(T)
// T is equal to 24 after the call
PROCEDURE Multiply10(P)
P=P*10 To avoid modifying the value of the variable corresponding to the parameter, the parameters must
be passed by value. Passing parameters by value allows you to handle a copy of parameter value.
P is the parameter expected by the procedure. If the procedure code modifies the variable value, the value of the variable corresponding to the
parameter is not modified.
To specify the parameter role in the procedure, you have the ability to typecast To force a parameter to be passed by value to a procedure, the LOCAL keyword must be used
the parameter in the procedure declaration. in front of the parameter name in the procedure declaration. This keyword indicates that the
Remark
For example, to use numeric values only, you have the ability to declare: following parameter will not be modified by the procedure.
PROCEDURE Multiply10(P is numeric) Example:
• The WLanguage code of the procedure is:
PROCEDURE Test_value(LOCAL P1)
// Local indicates that the parameter will be passed by value
P1 = P1 * 2
other parameters can be passed by value. All you have to do is used the LOCAL
keyword in front of each parameter passed by value. This window is as follows:
When declaring a procedure, the optional parameters are the last parameters windows will be created in the "WD My first windows" project.
(they are always specified after all mandatory parameters).
▶ Open the "WD My First Windows" project if necessary.
To do so, in WINDEV’s home page (Ctrl + <), click "Tutorial" and select "My first windows
In the following example, the Multiplication procedure is using an optional parameter, Nb2. This (Exercise)".
optional parameter is indicated after the mandatory parameters, by specifying its default value. In
this example, the default value of optional parameter is set to 10. Implementation
▶ Create a new blank window:
PROCEDURE Multiplication(Nb1 is int, Nb2 is int=10)
MyResult is int 1. Click among the quick access buttons. The window for creating a new element is
MyResult = Nb1 * Nb2 displayed: click "Window" then "Window". The window creation wizard starts.
RESULT MyResult 2. Select "Blank" and the "Phoenix" skin template.
The code used to call the procedure is as follows: 3. Validate. The window is automatically created in the editor. The window for saving an element
is displayed.
res is int 4. Specify the window title: "Procedures". The window name ("WIN_Procedures") is automatically
res = Multiplication(6) proposed.
// Res is equal to 60
5. Click "OK" to validate the information shown in the save window.
In this example, the second parameter was not specified. Therefore, its default value will be used. ▶ To create the edit control corresponding to the price BT:
1. On the "Creation" pane, in the "Usual controls" group, expand "Edit" (click the arrow). The list
Procedure result of available edit controls is displayed. In the search box at the top of the list, enter "Currency".
Select the "Currency Edit" control and position the control in the window.
The procedures can return one or more results. The result can be typecasted. The RESULT keyword 2. Right-click the control and select "Description".
must be used to return a value.
3. In the description window:
See the online help for more details (keyword: Result).
• Type the control name: "EDT_PriceBT".
• Type the caption: "Price BT".
4. Validate.
8. Validate.
▶ To create the "Calculate" Button control:
1. On the "Creation" pane, in the "Usual controls" group, click .
2. Click the location where the control will be created (below the Combo Box control for
example).
3. Click the control that was just created. The text displayed in the control becomes editable.
Type the caption: "Calculate".
4. Display the next step of the wizard. 4. Press Enter to validate the input.
5. Keep the default options. Display the next steps. ▶ The amount IOT will be calculated via the code of the "Calculate" Button control.
6. In the "Initial content" step, type the list of possible VAT values: 1. Display the code of "Calculate" control ("Code" from the popup menu).
• 5.5 2. Write the following WLanguage code in the "Click BTN_Calculate" event:
• Press the Enter key.
SWITCH COMBO_VAT..DisplayedValue
• 10 // 5.5 %
• Press the Enter key. CASE 5.5
EDT_PriceIOT = EDT_PriceBT * 1.055
• 20. // 10 %
CASE 10
EDT_PriceIOT = EDT_PriceBT * 1.1
// 20 %
CASE 20
EDT_PriceIOT = EDT_PriceBT * 1.2
END
This code calculates the amount IOT by using the value selected in the Combo Box control
(returned by ..DisplayedValue).
▶ To create the procedure for calculating the amount IOT: This code calls the Calc_IOT procedure to calculate the amount IOT. Two parameters are passed to
the procedure: the price BT and the VAT rate. The result returned by the procedure is assigned to
1. Click the window background.
the EDT_PriceIOT control.
2. Display the events associated with the window (F2).
4. Close the code window (click X at the top right corner of code editor).
3. In the code editor, on the "Code" pane found in the ribbon, in the "Procedures" group, expand
"New" and select "New local procedure". ▶ Let’s now run the window test:
4. In the window that is displayed, type the name of local procedure ("Calc_IOT") and validate 1. Run the window test ( among the quick access buttons). Give a price BT. Select the
("Add" button). different values in the Combo Box control and click "Calculate".
5. The new procedure local to the window is automatically created and its code is displayed in 2. The amount IOT is displayed.
the code editor. 3. Close the test window.
6. Write the following WLanguage code:
PROCEDURE Calc_IOT(PriceBT, VATRate) Conclusion
cyIOT is currency
cyIOT = PriceBT * (1 + VATRate/100) This section allowed you to get familiar with the main concepts of WLanguage programming in
RESULT cyIOT
WINDEV. Several other features are available. Some of them will be presented in this tutorial.
Let’s take a look at this WLanguage code: WLanguage is a very powerful language that allows you to develop applications that use:
• The Calc_IOT procedure expects 2 parameters: the price before tax and the VAT rate. • the Object-Oriented Programming (OOP),
• This procedure declares a currency variable. This variable is used to store the calculated • the MVP (Model View Presenter),
price IOT. • a 3-tier programming,
• This procedure calculates the price IOT and returns the calculated value. • advanced types (XML, Email, ...), ...
7. Close the code window (click X at the top right corner of code editor). See the online help regarding the relevant topic for more details.
The functions for performing searches or replacements (in the code, in the interface, ...) can be
accessed from the "Home" pane, in the "Find" group or in the "Find - Replace" pane (Ctrl + F):
Estimated time: 10 mn
Then, you have the ability to define the different characteristics of the search to perform.
For WLanguage functions that require names of data files, controls, windows or reports, the
assisted input is used to display the list of project elements corresponding to the parameter of the
function currently typed.
Examples of assisted input for HReadFirst: the <Wizard> option is used to start a code wizard.
This wizard asks you questions regarding the function use and it automatically generates the
corresponding code.
A help page is associated with each WLanguage function and property. This help page can be
Press Ctrl + * (on the numeric keypad) to expand the WLanguage entire code. A click performed directly accessed from the editor by pressing F1 on the name of requested function or property.
on the "-" or "+" symbol allows you to collapse or expand the corresponding code section. What are the useful shortcuts in the code editor?
Is it possible to identify the person who wrote a code line? • To display the events of a control, method, class, procedure or report block, press F2 while on
Press F6 to display information (name and creation/modification date) about each code line. the name of the desired element.
• Ctrl + F2 is used to go back to the initial process or event.
Is it possible to find out the code line number? To move from one process/event to another, press F2 repeatedly. To go back to the initial
process or event, press Ctrl + F2 the same number of times.
In the code editor, to enable (or not) the numbering of code lines, on the "Display" pane, in the
• Ctrl + L deletes the current line.
"Help for edit" group, click "Display line numbers" (shortcut: Ctrl + Shift + G).
• Ctrl + D duplicates the current line (or the selected lines) on the line below.
• Tab (tab key) and Shift + Tab are used to manage the indent for the selected lines.
• Ctrl + / converts the selected lines into comments, Ctrl + Shift + / removes the comments
(Caution: / key on the numeric keypad).
• Ctrl + R is used to automatically re-indent the displayed code.
My first database
5. Stop the test of this window and go back to the code editor to study the code of each Button
control.
In a next section, we will concentrate on the development of the elements (windows, reports, ...) • Vocabulary used.
found in an application with data that will be developed from A to Z, from the interface creation to • The different modes for accessing the databases.
the final distribution. You will see the main points for developing an application.
In this section, we are going to create a database used to manage orders.
The same type of database will be used in part 4 of this tutorial to develop a full application. The
database used is HFSQL Classic, the free database supplied with WINDEV. The HFSQL Client/
Server database will be presented later in this tutorial.
Estimated time: 5 mn
are supplied with WINDEV. They can be accessed from the HFSQL Control • the transactions,
Center. • the replication,
• the triggers.
WINDEV can handle most of the database formats (nearly all of them). The most common formats See the online help for more details about implementing these features.
are:
• HFSQL, the database system supplied with WINDEV. The HFSQL database is available in In the different sections of this tutorial, we will be using a HFSQL Classic database then a HFSQL
Classic mode or in Client/Server mode. Client/Server database.
• Oracle, SQL Server, MySQL, xBase, SQL Azure, ...
• AS/400, Access, Sybase, Informix, ... The different modes for accessing the databases
• Any database accessible in SQL language in Windows.
• Text (ASCII files).
Native Connector (Native Access)
Several methods can be used to access data: A Native Connector is using a database format directly and exclusively. This optimized type of
• Native Connector (also called Native Access), access is developed specifically for each database format.
• OLE DB access, In WINDEV, a Native Connector is available for the following databases:
• Direct ODBC access, • HFSQL Classic or Client/Server (standard).
• ODBC access via OLE DB. • xBase (standard).
• Access (standard).
• XML (standard).
• SQLite (standard).
• Oracle (optional).
• AS/400 (optional).
• SQL Server (optional).
• Sybase (optional).
• Informix (optional).
• DB2 (optional).
• Progress (optional).
• MySQL (optional and free).
• PostgreSQL (optional and free).
• MariaDB (optional and free).
• SQL Azure (optional and free).
Other Native Connectors will be available soon, contact our sales department for more details!
The WLanguage SQL* and HRead* functions can be used with this type of access. The code is
portable and independent of the database.
92 Part 3: My first database Part 3: My first database 93
Direct ODBC access
An access via ODBC is using a multi-database access standard. The ODBC layer must be installed
Lesson 3.3. Project and analysis
on your computer. In most cases, this layer is already installed in the recent Windows versions.
This can be checked in the control panel of Windows by selecting "ODBC data source" (or "ODBC
administrator" according to the Windows version used).
This lesson will teach you the following concepts
Caution: some databases may not be accessible via this method. If you want to use this type of
access, check whether an ODBC driver exists and install this driver if necessary. • Creating a project.
Only the WLanguage SQL* functions can be used with this type of access. • Creating an analysis.
OLE DB access
An access via OLE DB uses a multi-database access standard. This type of access is based on
MDAC (Microsoft Data Access Component).
Estimated time: 40 mn
Important
If you are using an OLE DB access, MDAC must necessarily be installed on the
user computers (version 2.6 or later).
Some databases may not be accessible via this method. If you want to use this type of access,
check whether an OLE DB driver exists.
The WLanguage SQL* and HRead* functions can be used with this type of access.
ODBC access via OLE DB
In summary, it is a "mix" of OLE DB and ODBC. This is the "heaviest" method and the least efficient
one in term of performance. It should not be used on small databases.
The WLanguage SQL* and HRead* functions can be used with this type of access.
4. The first step of the wizard allows you to select the operating system for which the project is
intended. Select "Windows platform" and go to the next step of the wizard ("Next").
5. For this lesson, we are going to create a "blank" project. You can also create a project based
on an existing example, provided with WINDEV. Select "Create a blank project" and go to the
next step of the wizard.
6. WINDEV then proposes to specify the platform description. Keep the default options Go to the next step.
("Windows 32-bit executable" and "Executable with windows"). Go to the next step of the wizard. 12. Click the "Database" step. We are now going to specify the information regarding the
7. The wizard proposes to type the name of project, its location and its description. In our case, database.
this project will be named "WD My First Database". 13. Select "Yes, create a new database" and validate. The analysis creation wizard starts.
8. WINDEV proposes to create this project in the "\My projects\WD My First Database" directory.
You can keep this location or modify it via the [...] button. For the project summary, type "The To better understand the lessons found in this section and to optimize your
purpose of project is to manage the customers and their orders".
Remark training, we advise you to create the "WD My First Database" project.
A corrected example can be accessed at any time to check the validity of
operations performed.
To open this corrected project, in WINDEV’s home page (Ctrl + <), click "Tutorial"
and select "My first database (Answer)".
7. The window for creating a new element is displayed. We are now going to create the data file
containing the orders.
Remark
very impressive because it allows you to manage several types of Customer data files. You also have the ability to create a data file from the data model editor: in the
ribbon, on the "Analysis" pane, in the "Creation" group, click "New file".
4. Check the following items: CustomerID, Company, LastName, FirstName, Address, ZipCode,
City, StateDep, Country, Phone, Cell, Email.
5. Validate the wizard.
We are going to create the items of the "Orders" data file. In the description window of data file,
you will notice that an item was automatically created: "OrdersID". This item corresponds to the
automatic file identifier. This item consists of the letters "ID" and the name of the data file.
We are going to create the other items of this data file.
▶ First, we are going to create the "Date" item. This item will contain the order date.
1. In the description window of items, double-click in the "Name" column of first empty row. This
column automatically becomes editable. Type "Date".
2. Click the "Caption" column. The item name is automatically displayed. We are going to modify
the item caption by clicking on it: type "Order date". In the "Type" column, the "Text" type is
automatically selected. Expand the list and select the "Date" type.
To create the identifier (an identifier is a unique key), you have the ability to
create a numeric item whose type is "Automatic identifier". 3. This item will be a key item (index) in our data file: the keys are used to accelerate the
Remark
Remark
window of items and indexes opens up.
• unique key: the value of this key will be unique in the entire data
file (i.e. in all the data file records).
• key with duplicates: the value of this key can be found several
times in the data file.
5. You must also define the search direction of the key. The search direction is used to define
the default sort for this item. In our case, when a browse is performed on this key, the default
sort order will be "ascending".
▶ We are now going to create the "Status" item that is used to find out the order status.
1. Position the cursor on a new table row. Enter:
• the name: Status
• the caption: Order status
• the type: Radio Button, List Box, Combo Box. In the window that appears, you can select
the type of control created by default for this item. It will be a radio button in this case. 3. Validate the description window of the control linked to the item.
Validate the window. 4. Similarly:
2. In the lower section of the screen, click the link to display the parameters of the control • Position the cursor on a new table row and create the item "TotalBT". This item is a
linked to the selected item. "Currency" item.
• Position the cursor on a new table row and create the item "TotalIOT". This item is a
"Currency" item.
5. That’s it, the description of "Orders" data file is complete. Validate the description window of
The information typed in the new window that is displayed will be automatically used when items.
creating windows linked to the data file. You will find here the control type and the caption. 6. The "Orders" data file appears in the data model editor. It is possible to enlarge the displayed
We are going to type the following options in the "Content" tab: data file. Simply click the data file, select the black handle at the bottom of the data file and
• Click the "Content" tab. move the mouse down.
• Click the "+" button to add the first option.
• The option 1 corresponds to Pending. Type "Pending" in the edit control found on the right.
• Click the "+" button to add the second option.
• Type "Validated" instead of "Option 2".
• Click the "+" button again.
• Type "Canceled" instead of "Option 3".
From the CSV file containing the data, WINDEV will create:
• the description of data file in the analysis,
• the HFSQL data file with the data found in the CSV file.
▶ To import a CSV file into the analysis:
1. In the ribbon, in the "Analysis" pane, in the "Creation" group, expand "Import" and select
"Import the descriptions of files/tables".
To import a CSV file (or any other file) into the analysis, you also have the ability
8. Don’t forget to check "The first row contains the names of columns".
Tip
to Drag and Drop the CSV file (from the Windows explorer) to the data model
editor. This will be presented in the next paragraph. 9. Go to the next step.
10. The structure of data file that will be created is displayed.
2. The wizard for importing files starts.
3. Go to the next step.
4. Select the format of files to import. In this case, select "Text file".
Only the description of the "Product" data file was imported into the analysis of
Caution!
our project. The data found in the "Product" data file was not imported into the
project.
In the wizard:
• The cardinalities are as follows: PaymentMode (0,n), Orders (1,1).
• The link key corresponds to the "Code" item.
We are now going to modify the relation file that was created by WINDEV. Indeed, this relation file
will contain the order lines. We are going to:
3. Go to the next step. The wizard proposes to create a relation file. Keep "Create the relation • Modify the name of the data file.
file automatically" and go to the next step. • Modify the name of its items.
4. The wizard proposes the unique key of the Product data file. Select "Reference". Go to the • Add items to find out the quantity of products ordered and the total of order line.
next step.
5. Validate the key creation by going to the next step. ▶ First, we are going to rename the data file. We already did something similar when we changed
6. Keep the default options regarding the integrity rules and go to the next step. the caption of the imported data file. However, in this case, not only the caption will be
7. The wizard proposes the unique key of the Orders data file to use: "OrdersID". Go to the next modified: we will also rename the physical file linked to the data file description.
step. 1. Select the "Product_Orders" data file.
8. Validate the key creation by going to the next step. 2. In the popup menu (right mouse click), select "Description of data file".
9. Keep the default options regarding the integrity rules and go to the next step.
10. Click "Finish". The relation file is automatically created in the data model editor.
This type of key is used to browse the data file according to complex criteria or
to perform specific searches on several items at the same time.
The generation is automatically proposed when closing the data model editor while modifications • Go to the next step.
have been performed. • The wizard proposes to save the existing data files, don’t change anything and go to the next
step.
You also have the ability to generate the analysis manually. That’s what we are going to do. • The wizard proposes to type the passwords for protecting the data files modified by the
automatic modification. Keep the default options and go to the next step.
▶ To generate the analysis: • The list of data files to modify is displayed. Validate the wizard.
1. In the ribbon of the data model editor, on the "Analysis" pane, in the "Analysis" group, click • The data files are updated.
"Generation".
2. The analysis generation is automatically started. ▶ Close the data model editor.
The descriptions of data files found in the analysis have been modified.
To update the data files of the application, WINDEV automatically starts the procedure for The main steps for creating an analysis have been presented.
modifying the data files. This operation is used to update the data files (".fic" files) according to
their description in the analysis. When your analysis is described and generated, you also have the ability to:
• Create a full application via RAD (Rapid Application Development). We will create the
application corresponding to the analysis in this way in the next lesson.
Create a full custom application. This method will be used to develop a full application based on a
database in the part 4 of this tutorial. This application will be based on an analysis corresponding
to the one that was created in this part.
This lesson will teach you the following concepts As already seen, to develop an application in WINDEV, you must create a project and an analysis
(if necessary). The analysis contains the definition of the structures of data files used in the
processes.
• What is RAD?
• Generating RAD. The RAD module of WINDEV is based on this analysis. The RAD module includes a wizard allowing
• Project test. you to choose the application template to generate (the RAD pattern) and the main options
regarding the operating mode of your application.
WINDEV is supplied with several "RAD patterns" allowing you to generate several
Remark
application templates. You also have the ability to create your own RAD patterns.
See the online help for more details (keyword: "RAD pattern").
Estimated time: 20 mn
The windows, the reports, the queries and the code generated by RAD can be customized. You
also have the ability to modify the types of controls, the default values, ...
The RAD can also be used to generate several types of windows, it is the window RAD. The Window
RAD is available when a new window is created in your application.
Let’s see how to use the Project RAD module.
Remark
the analysis items only. The code required for these windows to operate must be
written by the developer.
See the online help for more details (keyword: "RID").
Select the pattern that will be used for RAD generation: "Simple RAD" for example. Go to the
next step of the wizard.
2. All data files found in the analysis will be taken into account:
7. Go to the next step. Specify whether the automatic menu will be included in the application.
Answer "Yes: Include the ’?’ menu".
8. Go to the next step. The RAD generation wizard is ended. Validate. The wizard for generating
the automatic menu starts.
Remark
The automatic menu is a help menu suited for your applications. This menu
allows the users of your applications to easily access several features. Let’s now run the test of generated application.
▶ To run the application test:
1. Click among the quick access buttons. The application starts.
▶ The different options proposed by the wizard for generating the automatic menu are as follows:
2. In the menu, select "Customers/Prospects .. List of Customers/Prospects".
3. The list of customers is displayed.
4. To add a new person, click the "New" button. An input form is displayed.
When creating the ’?’ menu, the option "? .. Help for AAFs (Automatic Application
Features)" automatically added into your application:
Remark
UI errors may appear in the "Compilation errors" pane. These errors signal
Remark
interface problems, especially in the reports (captions too long for example). To
correct these errors, the reports must be modified.
Full application
with data
Estimated time: 5 mn
126 Part 4: Full application with data Part 4: Full application with data 127
Overview of application created in this section ▶ To display the analysis linked to the project, click among the quick access buttons. The data
model editor is displayed:
In this section, we are going to create an application that handles data files in HFSQL Classic
format.
This application for order management will be used to:
• View, enter and modify products,
• Print reports,
• Display statistics,
• Manage use levels,
• Send emails,
• ...
The development of this application will allow us to present the deployment and the distribution of
application to the end users.
You will see the main points for developing an application.
Projects supplied
This analysis contains the description of 5 data files:
• Customer,
Example project
• Orders,
The creation of project and analysis was presented in the previous section. We won’t go back • OrderLine,
to it. We are going to work with a project that already contains an analysis and data files filled • Product,
beforehand. The application analysis is an improved version of the analysis that was created in
• PaymentMode.
the previous section.
This analysis is straightforward and it is used to manage orders.
▶ To open this project in WINDEV:
▶ Close the data model editor (click the cross in the top right corner of menu).
1. Display the WINDEV home page (Ctrl + <).
2. In the home page, click "Tutorial" and select "Full application (Exercise)". Corrected projects
You don’t know which result to get? Or you don’t have time to perform all operations? A corrected
Before we start developing the application, let’s take a look at the analysis associated with the project is available for the application
"WD Full application" project.
The application that we are going to create being quite long (it is a full application that will allow
you to discover the main features of WINDEV), two corrected projects are available:
• A corrected project corresponding to lessons 4.2 to 4.4. This project contains all windows
developed in these lessons.
To use this corrected project:
1. Display the WINDEV home page if necessary (Ctrl + <).
2. In the home page, click "Tutorial" and select "Full application (With windows)".
• A corrected project corresponding to lessons 4.5 to 4.9. This project contains the entire
application.
To use this corrected project:
1. Display the WINDEV home page if necessary (Ctrl + <).
2. In the home page, click "Tutorial" and select "Full application (Answer)".
128 Part 4: Full application with data Part 4: Full application with data 129
Lesson 4.2. Addition and modification Overview
We are going to create the different windows used to list, add and modify products. These
windows operations will allow you to discover several topics regarding the management of data files and
they will also allow you to use some WINDEV features.
▶ If the "WD Full Application" project was not opened in the previous lesson:
1. Display the WINDEV home page (Ctrl + <).
This lesson will teach you the following concepts
2. In the home page, click "Tutorial" and select "Full application (Exercise)".
• Creating a menu window used to list the products. A corrected project is available. This project contains the different windows
Answer
• Creating a product form. created in this lesson. To open the corrected project, in the home page, click
"Tutorial" and select "Full application (With windows)".
• Managing the product addition and modification.
Remark
case, this code will also be common to all application windows.
The window template named WINTPL_Template was created for this
example. This template contains a logo that will be displayed in all
windows:
2. The new window is displayed in the editor. The window for saving an element is displayed.
130 Part 4: Full application with data Part 4: Full application with data 131
3. In this window, specify the window title: "Menu". ▶ To create the Table control:
1. On the "Creation" pane, in the "Data" group, expand "Table and list box" and select "Table
(Vertical)". The control currently created follows the mouse movement.
2. Click inside the window: the Table control creation wizard starts.
3. The Table control that is currently created must display the records found in the "Product"
data file. In the wizard, select "Display the data found in a file or in an existing query".
4. The window name (that will be used in programming) is automatically deduced from the
window title. If this name does not suit you, you have the ability to modify it and to specify a title
that differs from the window name.
5. Validate.
Remark
This window was named "Menu" because it is the main window of our
application. It will be used as menu but it will also display information.
What is a Table?
Do not confuse "Table" and "Table control".
• We refer to an SQL database as a Table.
• A Table control is used to view data in a table. In this case, the data can be
typed or it can come from a data file (or from a table).
Remark
The Table control of WINDEV is used to view or modify data: Go to the next step.
• in memory: it is referred to as a memory Table control or Table control filled 5. The wizard proposes the list of items found in the "Product" data file.
by programming. By default, all items are checked in order to be displayed in the Table control. In our case, we
• coming from data files or queries: it is referred to as a browsing Table are going to display all items EXCEPT for the "ProductID" identifier that corresponds to the
control. automatic identifier of data file.
• coming from WLanguage variables: it is referred to as a Table control on Uncheck "ProductID".
source.
132 Part 4: Full application with data Part 4: Full application with data 133
6. Then, the wizard proposes to select the sort item. This item will be used to sort the data Window test
displayed in the Table control. The items proposed in the wizard correspond to the items defined
as key items in the analysis. The products will be sorted according to their caption. Click on the ▶ We are now going to run the test of the window that was just created.
"Caption" row. 1. Click among the quick access buttons.
2. The window is automatically displayed with its data at run time.
3. You have the ability to scroll the products with the scrollbar (or with the keyboard arrows).
▶ Let’s imagine that we are the end user to see the capabilities of Table control at run time.
Some remarks:
• First of all, the Table control has the same aspect at run time and in the editor: this is the
WYSIWYG concept ("What You See Is What You Get").
• Small logos appear at the top of columns:
• the double arrow indicates that the column can be sorted ("Reference" or "Caption" column
for example).
Let’s take a look at the control that was just created: the data is already displayed in the control,
even in the editor. This concept is called "Live data": the content of data files found on the Click the "Caption" column twice for example: the data is displayed according to a different
development computer is used in the windows or reports handled in the editor. This feature is very order. An arrow on the left of columns indicates that the column is sorted as well as the sort
useful to define the size of controls found in a window for example. direction.
• the magnifier indicates that a search can be performed in the column.
134 Part 4: Full application with data Part 4: Full application with data 135
Click the magnifier of "Reference" column for example. An input area is displayed, allowing
you to type the sought reference. Type "REF-010". The product corresponding to this reference Several controls propose default AAFs. If these features must not be proposed
Remark
is automatically displayed. (for security or confidentiality reasons), they can be disabled in the editor or by
programming.
See the online help for more details (keyword: "Automatic Application Features").
Now that the list of products is displayed, you may want to modify a product. To do so, we are going
to create a window used to display the product details.
▶ Close the window via the cross found at the top of the screen. The WINDEV editor is
redisplayed.
• A popup menu is available for the Table control and for each one of its columns. This popup
menu can be displayed: Creating a "Product form" window
• via a right mouse click on the column of Table control.
• via a click on the arrow found at the extremity of column headers.
Creating the window
• This popup menu is used for example to export the content of Table control in Excel format (or
OpenOffice.org Calc), in Word format (or OpenOffice.org Writer), to print, ... ▶ To create a window used to display the product details:
1. Open the "WD Full Application" project if necessary.
2. Create a new blank window.
• Click among the quick access buttons.
• The window for creating a new element is displayed: click "Window" then "Window".
• The window creation wizard starts.
• In the "Based on a template" tab, choose "Use: WINTPL_Template" and validate the wizard.
3. The save window is displayed. Type the window title: "Product form". The name ("WIN_
Product_form") is automatically proposed.
4. Validate the save window.
Creating edit controls
We are going to create a window used to display the characteristics of the product selected in the
Table control. This type of window is called a "Form" because it corresponds to a descriptive form
of requested element.
In our case, this window will be used to display the content of the different items found in the
"Product" data file.
▶ To create the controls in the window:
1. Display the "Analysis" pane if necessary: on the "Home" pane, in the "Environment" group,
expand "Panes" and select "Analysis". The different data files described in the "WD Full
Application" analysis appear in the pane.
In just a few minutes, we have presented some features that are automatically included in the
Table control. No programming is required to propose these features to your users. These features
are called "AAF" (Automatic Application Features).
136 Part 4: Full application with data Part 4: Full application with data 137
2. Click the icon on the left of "Product" data file: the items found in the data file are listed. • Display the "Link" tab of description window:
3. With the mouse, select all items displayed in the pane (except for the "ProductID" item). You
have the ability to use the multi-selection by holding the Ctrl key down.
4. Drag and Drop these items to the window that was just created. This tab shows that the current edit control is linked to the "Reference" item found in the "Product"
data file.
6. Close the description window.
7. Save the window.
▶ Reposition the controls in the window and resize the window in order to get the following
interface:
5. Different controls are automatically created in the window. These controls are automatically
linked to the corresponding item in the data file. To check this:
• Select the "Reference" control for example.
• Display the popup menu (right mouse click) and select "Description".
138 Part 4: Full application with data Part 4: Full application with data 139
Creating buttons 2. In the ribbon, display the "Alignment" pane of WINDEV. This pane contains all alignment
options available for the controls.
The "WIN_Product_form" window will be used to add a new product or to modify a product found
in the list.
We are going to add a validation button and a cancelation button.
▶ To create the Button control to validate the data entered:
1. On the "Creation" pane, in the "Usual controls" group, expand "Button" (click the arrow found
below ). 3. We want the outside and inside borders of controls to be aligned. Click "Justify (Ins. and
2. The list of preset buttons is displayed. Out.)".
3. Click "Validate": the Button control shape appears under the mouse pointer. If you don’t know which alignment to choose, hover the different options
4. Then, click on the right of edit controls to create the Button control. proposed by the "Alignment" pane of WINDEV. When hovering an option with
the mouse cursor, the controls selected in the window are automatically
Remark
▶ Add the Button control to cancel the input using the same principle.
positioned and/or resized according to the hovered option.
1. On the "Creation" pane, in the "Usual controls" group, expand "Button" (click the arrow found
If the positioning suits you, all you have to do is click the option.
below ).
If the positioning does not suit you, all you have to do is hover the alignment
2. In the list of preset buttons, click "Cancel": the Button control shape appears under the
options: the controls move back to their initial position.
mouse pointer.
3. Then click below the "Validate" Button control to create the control.
Managing anchors
Improving the window interface ▶ Let’s see the visual aspect of our window:
This window being quite simple, let’s try to improve its interface. Several details can become very 1. On the "Modification" pane, in the "Preview" group, click "Preview". This runtime mode is used
annoying for the user so let’s try to sort them out right now. to display the window interface. The different codes are not run.
2. Enlarge the window via the sizing handle found at the bottom of window. The position of
Aligning controls controls is not modified and the window displays a large empty area. Two methods can be used
▶ One of the first optimizations consists in aligning the controls and in giving them the same size: to solve this problem:
1. Select the "Caption" control then all edit controls found in the window (hold the Ctrl key • Forbid the window from being resized.
down while clicking the different controls for example). The first selected control will be used as • Manage the anchors, which means manage the behavior of controls when resizing the
reference for the size of other controls. window. That’s what we are going to do.
140 Part 4: Full application with data Part 4: Full application with data 141
2. The edit controls must increase in width:
• Select the 4 edit controls.
• Display the popup menu (right mouse click) and select "Anchor".
• In the window for defining anchors, select "Width" ( ).
• Validate.
3. We are going to test the operating mode of this window in preview:
• On the "Modification" pane, in the "Preview" group, click "Preview".
• Enlarge the window: the controls follow the enlargement in width.
• We must now define the operating mode during the enlargement in height.
4. The "Description" control can contain a product description that is more or less important.
3. Close the preview: click the "Close" button or the cross found in the top right corner of This is the most important window control: it must occupy the maximum available space. Apply
window. an anchor in width and height to it ( ).
5. The "Price BT" control is automatically bordered by a red line: the window editor signals an
How to manage anchors in a window? anchoring problem. Indeed, if the "Description" control stretches to the bottom, the "Price BT"
To manage the anchors: control must move to the bottom accordingly.
6. Open the anchoring window for the "Price BT" control. The best anchor is automatically
Remark
1. In the editor, reduce the window to its minimum size. All outside window
borders must be "stuck" to a control. proposed: "width and bottom" (a green checkmark is displayed). Select the proposed anchor
2. Study the controls one by one and ask yourself the following question : and validate.
"How will the control react when the window is enlarged?". Then, apply the 7. We are going to test the operating mode of this window in preview:
corresponding anchor. • On the "Modification" pane, in the "Preview" group, click "Preview".
• Enlarge the window: the controls follow the enlargement in width and in height.
▶ For this window, we are going to define the anchors together:
1. The "Validate" and "Cancel" Button control must be anchored to the right.
• Select these two controls.
• Display the popup menu (right mouse click) and select "Anchor".
• In the window for defining anchors, select "Right".
• Validate.
• Small red arrows appear in the editor, indicating that the controls are anchored to right.
142 Part 4: Full application with data Part 4: Full application with data 143
Displaying the form from the list of products
The assisted code input (also called "completion") is going to help you: as soon
Now, let’s see how to display the form of the product selected in the list of products. The principle as you type the opening bracket "(", a drop-down list proposes the name of all
Remark
is straightforward: the user will select the product in the Table control and display the product existing windows found in the project. Simply select the name of the window
details via a Button control. with the keyboard or mouse.
▶ We are going to modify the "WIN_Menu" window to create a modification Button control: If the window name is not displayed in the list, it means that this window was
not saved beforehand.
1. Position the cursor on the "Menu" window: click "WIN_Menu" in the open documents bar:
5. Let’s take a look at this WLanguage code: Open is used to open the "WIN_Product_form"
window. This function was already presented in the first part of this tutorial.
6. Save the modifications by clicking among the quick access buttons.
2. At this time, the Table control occupies the entire window. Enlarge the window to the right via 7. Close the code window (click X at the top right corner of code editor).
the sizing handles.
3. Reduce the size of Table control: We are now going to modify the "WIN_Product_form" window to display the selected product in the
• Hold the Shift key down. Table control.
• Reduce the Table control via its sizing handles.
▶ Open the "WIN_Product_form" window in the editor: click the corresponding button in the open
documents bar.
Remark
Pressing the Shift key allows you to ignore the anchoring options of
controls during the resize operation. ▶ To display the product data:
1. Display the events associated with the window:
• Perform a right mouse click in the area found beside the window (called "Home area").
4. We now have space on the right to create the Button control that will allow us to view the • Select "Code" from the popup menu that is displayed.
selected product in the Table control. • The code editor appears. The WLanguage events associated with the window are
▶ To create the Button control to view the product: displayed.
1. On the "Creation" pane, in the "Usual controls" group, expand "Button" (click the arrow found 2. Enter the following WLanguage code in the event "End of initialization of WIN_Product_form":
below ). // Assigns the content of items to the controls
2. Enter "Modify" in the search box at the top of the list of preset Button controls. Click "Modify FileToScreen()
button". The shape of the control appears under the mouse pointer. Then, click on the right of
FileToScreen is used to display in the controls the data found in the data file, for the current
the Table control to create the Button control.
record. In our case, the current record will be the record selected in the Table control of "WIN_
Menu" window.
3. Close the code window.
4. Save the window (Ctrl + S).
▶ Display the "WIN_Menu" window in the editor: click the corresponding button in the open
documents bar.
3. Right-click the control that was just created. Select "Code" from the menu that is displayed. ▶ Run the window test ( among the quick access buttons).
4. In the code window that appears, write the following WLanguage code in the "Click" event: • In the list of products, click one of the products with the mouse.
Open(WIN_Product_form) • Click the "Modify" button.
• The detailed product window is displayed.
▶ Close the different test windows using the "X" at the top right of the windows.
144 Part 4: Full application with data Part 4: Full application with data 145
Managing the product modification 5. In the code window that appears, write the following WLanguage code in the "Click" event:
fImageSelect(
We are now going to modify the "WIN_Product_form" window in order to manage the product
modification.
We are going to:
• allow the user to modify the product image.
• add Button controls to save or cancel changes made in the product form.
Modifying the product image 6. The code editor proposes a code wizard.
The user will be able to modify the product image in the Product form. To do so, we are going to • Click "Wizard for function fImageSelect".
create a "Modify" Button control below the product image. This control will open a file picker to • The code wizard starts.
select the desired image.
WINDEV proposes several code wizards that will generate the
Remark
▶ First of all, display (if necessary) the "WIN_Product_form" window in the editor: click the corresponding code lines via simple questions. Don’t hesitate to use
corresponding button in the open documents bar. them, you will avoid syntax errors.
▶ To create the Button control to modify the image:
1. On the "Creation" pane, in the "Usual controls" group, expand "Button". Enter "Modify" in the 7. Keep all the default options proposed by the wizard and validate. The corresponding
search box at the top of the list of preset Button controls. Click "Modify button". WLanguage code is automatically entered.
2. The shape of the control appears under the mouse pointer. Click in the window, below the sFile is string
product image.
3. If necessary, resize the Button control (using the handles) so that the control has the same // Opens the image picker
width as the Image control. sFile = fImageSelect(“”, “”, “Select an image...”)
When resizing the control, an automatic magnetism effect simplifies the // If a file was selected
alignment of Button control with the Image control. IF sFile <> “” THEN
// Assigns the image to the Image control
IMG_Visual = sFile
END
This WLanguage code is used to assign the selected file to the Image control in the window.
9. Close the code editor (click the cross in the top right corner of code window).
This feature will be checked when the management of modifications performed in the form is
completed.
4. Right-click on the Button control. Select "Code" from the menu that is displayed. ▶ First of all, display (if necessary) the "WIN_Product_form" window in the editor: click the
corresponding button in the open documents bar.
146 Part 4: Full application with data Part 4: Full application with data 147
▶ We will now write the WLanguage code associated with the "Validate" Button control. Test of product modification
1. Right-click the Button control and select "Code" from the popup menu.
▶ To check the modification of a product:
2. Write the following code in the "Click" WLanguage event:
1. Run the project test ( among the quick access buttons).
ScreenToFile()
HModify(Product)
Close()
Remark
windows that use a lot more controls: a single code line performs all assignments! • when creating the executable.
• HModify is used to update the file data for the current record. • in the "Project explorer" pane: all you have to do is select the requested
window, display the popup menu and select "First project window".
3. Save the modifications by clicking among the quick access buttons.
When a first project window is defined, a small red 1 appears in front of the
4. Close the code window (click X at the top right corner of code editor).
window name in the "Project explorer" pane.
▶ The modifications performed in the "WIN_Product_form" window must be taken into account
in the Table control used to list the products. To do this, we will simply modify the WLanguage 3. The project starts in test mode and the first window is displayed.
code associated with the "Modify" Button control in "WIN_Menu". 4. Select a product from the product list (for example the first one) and click "Edit".
1. Display the "WIN_Menu" window in the editor: click the corresponding button in the button 5. The details of the selected product are displayed in the form window.
bar.
6. Modify the price of 100.23 Dollars and enter 200.00 Dollars, then click the "Validate" button.
2. Select the "Modify" Button control and open the code editor (F2).
7. When going back to the list of products, you will notice that the price was updated for this
3. Modify the "Click" event as follows: product.
Open(WIN_Product_form) 8. Display the product details again.
TableDisplay(TABLE_Product, taCurrentSelection)
9. Click the "Modify" button below the image. The image picker is displayed. Select an image
Let’s study this code: and validate. The image is displayed in the form.
• TableDisplay is used to update the Table control. 10. Click the "Cancel" button. The image modification was ignored in the data file.
• The taCurrentSelection constant is used to specify that the Table control must be updated 11. Click the cross to close the application.
from the position of selection bar.
4. Save the modifications by clicking among the quick access buttons.
5. Close the code window (click X at the top right corner of code editor).
148 Part 4: Full application with data Part 4: Full application with data 149
Creating a new product Addition into the data file
The principle for creating a product is as follows: ▶ We are now going to modify the window of product form to manage the addition of a new
record.
• In the product list window, we will add a "New" Button control that will open the "Product form"
window. 1. Open the "WIN_Product_form" window in the editor.
• Then, we will modify the code of "Product form" window to manage the addition into the 2. We will modify the WLanguage code associated with the "Validate" Button control:
Product data file. • Right-click on the "Validate" Button control and select "Code" in the popup menu.
• In the "Click" event, replace the existing WLanguage code with the following:
Adding a button
ScreenToFile()
▶ To add a "New" Button control into "WIN_Menu": IF Product..NewRecord THEN
HAdd(Product)
1. Display the "WIN_Menu" window in the editor: click the corresponding button in the open ELSE
documents bar. HModify(Product)
2. On the "Creation" pane, in the "Usual controls" group, expand "Button" and select "New END
button". Close()
3. The shape of the control appears under the mouse pointer. Click in the window: the Button Let’s take a look at this WLanguage code:
control is created.
• ..NewRecord is used to find out whether the current record must be created.
4. Position the Button control above the "Modify" Button control (if necessary, reposition the
• If HReset was called beforehand, the property returns True (click on "New product") and
"Modify" Button control).
the record must be created by HAdd.
• Otherwise, the current record already exists and it must be modified by HModify.
• HAdd adds the record into the data file. This function takes the values in memory and
writes the content of file items into the data file itself. The indexes are immediately and
automatically updated. In this case, it is the "Product" data file that is updated.
The test code of new record can be replaced by HSave. This function is
used to check whether the record is already found in the data file, and
it allows you to add it or to modify it. The code becomes:
Remark
5. Modify the WLanguage code of this control:
• Right-click on the "New" Button control and select "Code" in the popup menu. ScreenToFile()
HSave(Product)
• Write the following code in the "Click" WLanguage event: Close()
HReset(Product)
Open(WIN_Product_form)
TableDisplay(TABLE_Product, taCurrentRecord)
3. Save the modifications by clicking among the quick access buttons.
Let’s study this code: 4. Close the code window (click X at the top right corner of code editor).
• HReset initializes the item variables in the "Product" data file with the default values to
manage a new record.
• Open is used to open the product form to type the new record.
• TableDisplay is used to re-display the Table control. The taCurrentRecord constant is
used in this code: the Table control is re-displayed from the current record.
6. Save the modifications by clicking among the quick access buttons.
7. Close the code window (click X at the top right corner of code editor).
150 Part 4: Full application with data Part 4: Full application with data 151
Test of product addition This window informs the user that a duplicate was found: indeed, the reference (that is a unique
key) is identical for two products. This window is used to modify the reference value: type "REF-
▶ To check the product addition: 338" for example.
1. Run the project test ( among the quick access buttons). This window is one of the windows for automatic management of HFSQL errors.
2. In the list of products, click the "New" button.
3. Enter a new product with the following characteristics: Several errors may occur when adding or modifying a record: duplicate error,
• Reference: REF-337 integrity error, password error, ...
• Caption: Surf WD WINDEV proposes several modes for managing these errors:
• Description: Surf with WINDEV colors • the automatic mode: for each error that occurred when managing database
• Price: 150 records, a specific page is displayed to the user. This window allows the user
Remark
to modify his data directly.
• the advanced programmed mode: a procedure or a custom window for
error management is called whenever an error occurs when managing the
database records.
The example "WD Detecting HFSQL Errors", supplied with WINDEV, allows you
to check these different modes for error management. This example can be
opened via the WINDEV home page (Ctrl + <), "Open an example" option.
3. Sort the elements by reference (click the header of the "Reference" column) and the two
added records appear.
152 Part 4: Full application with data Part 4: Full application with data 153
Lesson 4.3. Simple search and record Overview
We have managed the addition and modification of records. It’s fine. But it would be even better to
browse be able to find a record (to modify it for example). That’s what we are going to do now.
We are going to modify the main window of "WD Full Application" application to use tab panes.
• The first tab pane will display the product list and manage the addition and modification of
products (these operations have been performed in previous lessons).
This lesson will teach you the following concepts • The second tab pane will propose to find a customer by name. The customer form will be
displayed in the same tab pane.
Two search modes will be implemented:
• Managing the search for records.
• an exact-match search,
• Browsing records.
• a generic search.
Estimated time: 30 mn
Then, you will have the ability to browse the records found in the data file from the customer
displayed.
Answer
created in this lesson. To open the corrected project, in WINDEV’s home page
(Ctrl + <), click "Tutorial" and select "Full application (With windows)".
154 Part 4: Full application with data Part 4: Full application with data 155
Modifying the window: using a Tab control 3. Create a Tab control in a window:
• On the "Creation" pane, in the "Containers" group, expand "Tab and associated" and select
In this example, the search will not be performed in a new window: the WIN_Menu window will be "Tab".
used. At this time, this window displays the list of products. • Click in the window to create the Tab control.
We will use Tab controls to display various data in this window. Tab controls are used to group • Position the Tab control at the top left of window.
information by theme. The user can directly access a theme by clicking the requested "pane".
• A Tab control is created with two panes by default. The Tab control occupies the entire
This system is used in all description windows of WINDEV. available space in the window.
Creating the Tab control 4. Select the controls in the home area of the window and move them to pane 1 of the Tab
control.
▶ To display the data of the "WIN_Menu" window in a Tab control: 5. A green border appears when hovering controls on the Tab control. This border indicates that
1. Display the "WIN_Menu" window if necessary: the controls placed on the current pane will be automatically associated with the pane.
• from the open documents bar. 6. Enlarge (if necessary) the window and the Tab control to display the Table control and the
• by double-clicking its name the "Project explorer" pane. buttons in the Tab control.
2. Select the window controls and move them to the home area of window. This may seem
"strange", but it will make it easier to work on the Tab control and then associate the controls Handling controls in a Tab control
with the desired tab pane. • To check whether all controls are associated with the current tab pane, click
Remark
another tab pane: all controls associated with the tab pane disappear.
• To resize the Tab control while ignoring the anchors defined for the controls
found in the pane, press the Shift key during the resize operation.
156 Part 4: Full application with data Part 4: Full application with data 157
Modifying the Tab control
As soon as an image can be displayed in a control or window, WINDEV
Remark
▶ Modify the name of Tab control: proposes to use the image catalog. This image catalog is started via the
1. Double-click the Tab control that was just created: the control description window appears. "Catalog" option (available by clicking the button). This catalog contains
2. Modify the control name. The control is named "TAB_Viewing". hundreds of images, cliparts, ...
3. Validate the control description window.
5. Click the button on the right of "Image" control. Select "Catalog" from the popup menu
▶ Two panes are created by default. We are going to modify their caption directly: that is displayed. The window of image catalog is displayed.
1. Select the Tab control. 6. Type "Product" in the search area. Click the magnifier to start the search.
2. Click "Pane 1". The pane becomes editable: type the "List of products" caption. Press Enter to
validate.
3. Click "Pane 2". The pane is displayed. Click "Pane 2" again. Type the caption: "Finding 7. Select and validate ("OK").
customers". Press Enter to validate. 8. The screen for configuring the generated image is displayed. This screen is used to modify
the characteristics of the image to generate: size, lightness, ... Keep the default options and
▶ We will associate an image with each pane of the Tab control. To do so: validate.
1. Display the description window of Tab control (double-click the control for example). The 9. The image is generated in the project directory and the corresponding file is automatically
"General" tab of the description window allows you to configure the characteristics of each associated with the current element.
pane in the Tab control. The list of panes is displayed on the left. For each selected pane, its 10. In the Tab control description window, click "Finding customers" in the list of static panes.
characteristics can be modified in the right section of screen. 11. Click the button on the right of "Image" control. Select "Catalog" from the popup menu
2. In the description window, select the "List of products" pane. that is displayed. The window of image catalog is displayed.
12. In the search area, specify "Person". Click the magnifier to start the search.
13. Select, among the proposed images, the icon representing two persons ( ) and validate.
14. Keep the options found in the setting screen of generated image and validate.
15. Validate the description window of Tab control.
▶ A new control was just created: we must now manage its anchoring in the window. When
3. The pane characteristics are displayed. the window is enlarged, the Tab control must also be enlarged in order to occupy the entire
available space. Therefore, the control must stretch to the right and to the bottom.
1. Select the Tab control.
2. Display the popup menu (right mouse click) and select "Anchor".
3. In the window for defining the anchor, select and validate.
4. Save the window by clicking among the quick access buttons.
4. We are going to associate an image to the tab pane via the WINDEV image catalog.
158 Part 4: Full application with data Part 4: Full application with data 159
Implementing the search ▶ We are going to align the controls and give them the same size:
1. Select the "City" control then all edit controls found in the window (keep the Ctrl key down
The "WIN_Menu" window was entirely created. We can now focus on the content of the Tab control while clicking the different controls for example). The first selected control will be used as
pane for finding customers. reference for the size of other controls.
This Tab control pane will be divided into several areas: 2. On the "Alignment" pane, in the "Inside and outside" group, click "Justify (Ins. and Out.)".
• An area for typing the sought elements.
• An area for displaying the information found.
• An area containing the browse buttons.
6. The controls are automatically created in the Tab control pane. These controls are
automatically linked to the corresponding item in the data file.
7. Save the window (Ctrl + S).
3. All controls are moved to the bottom.
160 Part 4: Full application with data Part 4: Full application with data 161
▶ To create the search control: 8. The "FullName" item will also be used to sort the list of customers displayed in the Combo
1. Create a Combo Box control: on the "Creation" pane, in the "Usual controls" group, click Box control. Select the "FullName" item.
"Combo box".
2. Click the "Finding customers" pane, between the tab pane and the control "Identifier of
Customer".
3. The Combo Box control creation wizard for is displayed. We will create a Combo Box control
based on the "Customer" data file.
4. Select "Display the data found in a file or in an existing query".
162 Part 4: Full application with data Part 4: Full application with data 163
15. Select the Combo Box control and resize it (via the handles) in order for the full customer ▶ Let’s run a window test:
name to be displayed. 1. Run the window test ( among the quick access buttons).
2. Click the "Finding customers" tab pane if necessary.
3. Select a value in the Combo Box control and click on "Exact-match Search".
FileToScreen and ScreenToFile perform the reverse operation: the data ▶ To create the search control:
found in the file items is displayed in the corresponding controls. 1. Display (if necessary) the "Finding customers" pane tab of "WIN_Menu" in the editor.
2. Create an edit control: on the "Creation" pane, in the "Usual controls" group, click .
3. In the window, click below the Combo Box control ("Sought customer"). The edit control is
7. Close the code editor. created.
8. Save the window (Ctrl + S). 4. This control is named "EDT_Sought_Name" and its caption is "Sought name".
164 Part 4: Full application with data Part 4: Full application with data 165
▶ To create the Button control to launch the generic search: 3. Enter a value in the edit control (for example "BEEF") and click "Generic search".
1. Create a Button control: on the "Creation" pane, in the "Usual controls" group, click .
2. Position the control beside the edit control that was just created.
166 Part 4: Full application with data Part 4: Full application with data 167
2. Display the popup menu (right mouse click) and select "Choose a style". ▶ Likewise, create 3 Button controls.
3. All styles defined for the buttons are displayed in the window. • The names of these controls are: "BTN_Previous", "BTN_Next" and "BTN_Last".
• These controls are respectively associated with the styles: "BTN_Previous", "BTN_Next" and
"BTN_Last".
• The WLanguage code corresponding to the "Click" event of "BTN_Previous" is:
// If no search is in progress
IF HOut(Customer) THEN
// Reads the last customer
HReadLast(Customer)
END
168 Part 4: Full application with data Part 4: Full application with data 169
In these different codes:
• HReadLast is used to read the last file record according to the key used for the last search. Lesson 4.4. Multicriteria search
• HReadNext reads the record whose key value is immediately greater than the one of current
record.
• HReadPrevious reads the record whose key value is immediately less than the one of current
record. This lesson will teach you the following concepts
In any case:
• HOut is used to find out whether the data file is empty. • Creating a query with parameters.
• FileToScreen is used to display the record on the screen. • Creating the interface used to select the search criteria.
• Passing parameters to a query.
The code in the "Next" and "Previous" Button controls contains additional lines • Displaying the query result in a Table control.
of code to:
Remark
• Check whether a search was already performed in the Customer data file
(test of HOut to find out whether the file reading has started).
• Read the first or last record if necessary. Indeed, the next or previous record
cannot be read if no reading was performed in the data file.
Estimated time: 40 mn
▶ Save the window by clicking among the quick access buttons.
Window test
▶ Let’s run a window test:
1. Run the window test ( among the quick access buttons).
2. Click the "Finding customers" tab pane if necessary.
3. Find a customer (perform a generic search on "BEEF" for example).
4. Browse the data file by clicking each one of the browse buttons.
5. Stop the test to go back to the editor.
170 Part 4: Full application with data Part 4: Full application with data 171
Overview Creating the query used to find orders
In the previous lesson, we have explained how to perform a search on a single criterion (the
customer name). In this lesson, we will give the user the ability to perform a multicriteria search. Creating the query
In our example, this search will be done on the "Orders" data file. The user will be able to select: ▶ The query editor will be used to create the query.
• the order status, 1. Click among the quick access buttons. The window for creating a new element is
• the payment mode, displayed: click "Query". The query creation wizard starts.
• the order dates taken into account.The interface of "WIN_Menu" window is as follows: 2. Select the "Select" option.
Indeed, this query will be used to select records. Go to the next step.
3. The query description window is displayed. To build the query, we are going to select the
elements that will be displayed in the result.
4. Double-click the items found in the analysis on the left of description window. The items
taken into account are displayed in the middle of the screen.
Remark: To display the items of different data files, simply click the arrow in front of the data
file name.
We want to display:
• information regarding the order. Expand the "Orders" data file (click the arrow ) and
This interface includes: double-click the items: OrdersID, Date, Status and TotalBT.
• controls used to select the search criteria. • information regarding the customer who placed the order. Expand the "Customer" data file
• Button controls used to start the search or print the result. (click the arrow ) and double-click the "FullName" item.
• a Table control used to display the search result. This Table control is based on a query. This • information regarding the payment mode of order. Expand the "PaymentMode" data file
query will be used to select the records to display. The Table control will list the search result. (click the arrow ) and double-click the "Caption" item.
The first step consists in creating the query used to select the records. The description window of query is as follows:
specified criteria.
This type of query is called a select query because the SELECT command is
used in SQL language.
created in this lesson. To open the corrected project, in WINDEV’s home page
(Ctrl + <), click "Tutorial" and select "Full application (With windows)".
172 Part 4: Full application with data Part 4: Full application with data 173
5. The data will be sorted by date. 10. The graphic query representation is displayed:
• In the list of query elements, select the "Orders.Date" item, then click the "Sort" button and
select "Sort on the selected item".
• In the window that appears, indicate an ascending sort on the item.
Query test
Like all elements found in a WINDEV project, you have the ability to run the test of query that was
• Validate. just created:
6. A blue arrow with the number 01 appears on the right of "Orders.Date" item. This arrow 1. Click .
indicates that an ascending order has been applied on this item. The number "01" indicates 2. The result is displayed in a window:
that this sort will be applied first.
7. Give a name to the query: type "QRY_FindOrders" instead of "QRY_NoName1" in the "Query
name" area:
174 Part 4: Full application with data Part 4: Full application with data 175
A popup menu is displayed when a right click is performed on the query result. We advise you to keep "Param" as the prefix of the query parameters.
Remark
Remark You have the ability to export the result to: This allows you to easily find them in the code editor.
• an XLSX file (Excel). To find a query parameter, simply type ’Param’ and the completion
• a Word or OpenOffice file. feature of the code editor will propose all the parameters.
• an XML file (eXtensible Markup Language).
• a HFSQL file. 4. Validate the condition description window. The number "1" appears on the right of "Orders.
Status" item, indicating that a selection condition was defined.
3. Close the window.
176 Part 4: Full application with data Part 4: Full application with data 177
▶ The last selection condition to define affects the order date. This date must be included Test of query with parameters
between two dates typed by the user.
▶ To run the test of query with parameters:
1. In the list of query elements, select the "Orders.Date" item.
1. Click .
2. Click the "Between two dates ..." button. This button allows you to define a selection
condition. 2. A window is displayed, allowing you to type the different query parameters.
3. In the window that is displayed: 3. Type the following data:
• The selection condition is "Is included between". • Uncheck the ParamStatus parameter.
• Click "the parameter". • Select the ParamPaymentModeID parameter. In the lower section of the screen, type "1".
• Specify the parameter name: "ParamStartOfPeriod". • Select the ParamStartOfPeriod parameter. In the lower section of the screen, type
"01/01/2016".
• Click the second "to parameter".
• Select the ParamEndOfPeriod parameter. In the lower section of the screen, type
• Specify the parameter name: "ParamEndOfPeriod".
"03/31/2016".
4. Validate the definition of selection condition.
5. Validate the description window of query. The query graph is modified to take into account
the selection conditions that have been defined.
4. Validate the window. The query result corresponding to the specified parameters is displayed.
5. Close the window.
We are now going to create the interface used to specify the parameters of this query, to run it and
to display the result.
6. Save the query by clicking among the quick access buttons.
178 Part 4: Full application with data Part 4: Full application with data 179
Creating the interface used to perform a multicriteria search 8. In the search area, specify "Search". Click the magnifier to start the search.
9. Among the proposed images, select the icon representing the binoculars ( ) and validate.
Modifying the Tab control 10. Keep the options found in the setting screen of generated image and validate.
11. Validate the description window of Tab control.
We are going to add a tab pane into the "WIN_Menu" window to display the result of multi-criteria
search.
▶ To add a tab pane:
1. Display (if necessary) the "WIN_Menu" window in the editor.
2. Select the Tab control.
3. Display the description window of control ("Description" from the popup menu). Creating the controls used to configure the criteria and to display the result
4. In the "General" tab of description window, click the "New" button. A third tab pane appears.
We now want to display the result of our multicriteria search.
5. Click "Pane 3".
We are going to create a Table control based on the query then to create the different controls
6. In the "Description of static pane" section, type the pane caption: "Finding orders".
allowing the user to select the search criteria.
Creating the Table control
▶ To create the Table control used to display the search result:
1. In the "WIN_Menu" window, click the "Finding orders" pane. The empty tab pane appears.
2. Create a Table control: on the "Creation" pane, in the "Data" group, expand "Table and list
box" and select "Table (Vertical)".
3. Click the Tab control pane previously selected: the Table control creation wizard starts.
4. The Table control will be based on the "QRY_FindOrders" query (that was created
beforehand). Select "Display the data found in a file or in an existing query". Go to the next step
of the wizard.
5. Select the query that will be used as data source for the Table control:
• Expand the "Queries" group if necessary.
• Select the "QRY_FindOrders" query.
7. We are going to associate an image to the tab pane via the WINDEV image catalog. Click
the button on the right of "Image" control. Select "Catalog" from the popup menu that is
displayed. The window of image catalog is displayed.
180 Part 4: Full application with data Part 4: Full application with data 181
6. Select all suggested items if necessary. 2. Click the "COL_OrdersID" column. The column title is displayed in the lower section of the
screen. Replace the "Identifier of Orders" caption by "ID".
7. Go to the next step of the wizard. 3. Click the "COL_FullName" column. Replace the "Full name" caption by "Customer".
8. Keep the default options in the different wizard steps and validate the creation of Table
control.
9. The Table control is automatically created in the "Finding orders" pane of the Tab control.
10. Modify (if necessary) the position of Table control so that it is entirely displayed in the tab
pane.
4. Click the "COL_Caption" column. Replace the "Caption" caption by "Payment mode".
▶ For better legibility, we are going to rename the captions of columns in the Table control.
1. Open the Table control description (double-click the control).
182 Part 4: Full application with data Part 4: Full application with data 183
We are now going to create in our window the different controls allowing the user to select the
Live Data and controls based on queries query parameters. These controls will be positioned above the Table control.
Remark The Live Data is not displayed in the controls that use a query as data source
for the following reason: the data displayed in the control depends on the query ▶ Move (if necessary) the Table control in the window and reduce its height in order to get
result therefore it is known at run time only. available space for creating the different controls.
First parameter: Order status
▶ We are going to run a first test of this window: Three states can be assigned to an order:
1. Click among the quick access buttons. • pending,
2. Click the "Finding orders" tab pane. Only some orders are displayed, like during the last query • paid,
test run in the editor, when parameters were specified in the test window of query. • canceled.
In our analysis, the order status is saved in the "Status" item found in the "Orders" file. This item
is a radio button.
To allow the user to select one of these three states, we are going to use the Radio Button control
associated with the "Status" item of "Orders" data file.
The radio buttons are also called "option box". They are used to select a single
option among the proposed ones.
Remark
How to differentiate between a radio button and a check box?
We will only refer to option boxes as "Radio buttons". An easy way to remember:
think of old radios: a single frequency could be selected via the button!
The radio button is used to select a single option.
The test parameters have been retrieved as default parameters for the execution. We are now
going to modify the window in order for the parameters to be typed by the user, via controls.
4. Close the code editor (click the cross in the top right corner of editor).
184 Part 4: Full application with data Part 4: Full application with data 185
▶ We are now going to pass the value selected in the Radio Button control in parameter to the ▶ We are now going to check how the first parameter is passed:
query: 1. Save the window by clicking among the quick access buttons.
1. Display the WLanguage events associated with the Table control: 2. Click among the quick access buttons.
• Select the Table control. 3. Select the "Finding orders" tab pane if necessary.
• Display the popup menu (right mouse click) and select "Code". 4. Change the status of orders with the radio button and click "Find". The content of Table
2. In the "Initializing" event of the Table control, replace the line: control is modified.
//MySource.ParamStatus = <Value of ParamStatus>
In this code, RADIO_Status is the name of the Radio Button control that was just created. The
value of this control is associated with the ParamStatus parameter expected by the query.
3. Close the code editor.
▶ Before running the test, we are going to create a Button control to re-display the content of
Table control according to the value selected in the Radio Button control:
1. Create a Button control:
• on the "Creation" pane, in the "Usual controls" group, click .
• then click on the "Finding orders" pane of the Tab control, at the top right.
2. Select the control and press Enter. The control caption becomes editable. Type "Find" and
press Enter on the keyboard.
3. Modify the control style:
• Display the popup menu of control (right mouse click) and select "Choose a style". 5. Close the test window.
• In the window that is displayed, press Ctrl + F. In the search control, type "BTN_Search". Second parameter: Payment mode
• The style is automatically selected. Validate.
Several payment modes can be used for an order: cash, checks, ... The available payment modes
4. Resize the control if necessary.
are stored in the "PaymentMode" data file.
5. Display the WLanguage events associated with this control: press F2.
We will be using a Combo Box control based on this data file to allow the user to select the
6. Write the following WLanguage code in the "Click..." event: requested payment mode.
// Refreshes the display of Table control
TableDisplay(TABLE_QRY_FindOrders, taInit) The "Combo Box" control is used to display a list of elements and to select an
element from this list.
In this code, the taInit constant is used to re-run the "Initializing" event of the Table control (the
event in which the parameters are passed to the query). Unlike a List Box control , a Combo Box control is not expanded: the Combo Box
control expands on request or when the cursor is positioned on the control input
Remark
7. Close the code editor.
area.
The elements displayed in a Combo Box control can be defined when creating
the control in the editor. These elements:
• are defined by programming.
• come from a data file or from a query.
186 Part 4: Full application with data Part 4: Full application with data 187
▶ To create a Combo Box control: In this code, COMBO_PaymentMode is the name of the Combo Box control that was just created.
1. On the "Creation" pane, in the "Usual controls" group, click "Combo Box". The value of this control is associated with the ParamPaymentModeID parameter expected by
2. Click the location where the control must be created in the window (beside the Radio Button the query.
control that was just created for example). 3. Close the code editor.
3. The wizard for creating the Combo Box control starts. 4. Save the window by clicking among the quick access buttons.
4. Select "Display the data found in a file or in an existing query" and go to the next step. ▶ We are now going to check how the first two parameters are passed:
5. Select the "PaymentMode" data file and go to the next step. 1. Click among the quick access buttons.
6. The item that will be displayed in the Combo Box control is "Caption". Uncheck 2. Select the "Finding orders" tab pane if necessary.
"PaymentModeID" and check "Caption". Go to the next step.
3. Change the order status with the Radio Button control and modify the payment mode with
7. Select the sort item: "Caption". Go to the next step. the Combo Box control, then click "Find". The content of Table control is modified.
8. Select the return value: "PaymentModeID". This return value is very important because it will
be passed in parameter to the query. Go to the next step.
9. Keep the default options in the different wizard steps and validate the creation of Combo Box
control.
10. The Combo Box control is automatically created in the window.
▶ We are going to modify some characteristics of Combo Box control:
1. Select the Combo Box control and display the description window of control ("Description"
from the popup menu).
2. In the "General" tab, modify the control caption: replace "PaymentMode combobox" by
"Payment mode".
3. In the "Content" tab, specify the initial value displayed by the Combo Box control ("Initial
value" at the bottom of description window). In our case, type "1". This value corresponds to a
payment in cash.
4. Close the test window.
4. Validate the control description window.
Last parameter: Order date
▶ Change the control style: to occupy less space, we are going to select a style that displays the
caption above the control. The last query parameter corresponds to the date of orders taken into account. The user must be
1. Select the Combo Box control. able to type a date interval. To do so, we are going to use a control template.
2. In the popup menu (right mouse click), select "Choose a style".
3. In the window that is displayed, select the "COMBO_Internal" style and validate. A control template is a specific window containing different controls. All types
of controls can be included in this window. A control template is a file whose
4. Reduce the control size. extension is "WDT".
Remark
▶ We are now going to use the value selected in the Combo Box control to pass it to the query as The main benefit of a control template is the re-usability. A control template
parameter: found in a project can be re-used in any project window.
1. Display the WLanguage events associated with the Table control: Furthermore, the control templates can be overloaded: code can be added, the
• Select the Table control. controls can be moved in the window that is using the control template. The
controls can also be modified.
• Display the popup menu (right mouse click) and select "Code".
2. In the "Initializing" event of the Table control, replace the line:
MySource.ParamPaymentModeID = "1"
by the code:
MySource.ParamPaymentModeID = COMBO_PaymentMode
188 Part 4: Full application with data Part 4: Full application with data 189
▶ To manage the order date: ▶ We are now going to check how the parameters are passed:
1. In the "Project explorer" pane, expand the "Control templates" folder. 1. Click among the quick access buttons.
2. Drag the control template named "TPLC_ChoosePeriod" from the "Project explorer" pane and 2. Select the "Finding orders" tab if necessary.
drop it in the "WIN_Menu" window (beside the "Payment mode" control). 3. Define the different search parameters:
• Status of orders,
• Payment mode,
• Range of dates to take into account.
4. Click on the "Find" control. The content of Table control is modified.
3. Select the created control template and display its description ("Description" from the popup
menu).
4. In the description window, rename the control template. The new name is "CTPL_
ChoosePeriod".
5. Validate the description window.
6. Reposition and align the controls if necessary.
▶ We are now going to use the selected dates to pass them to the query as parameter:
1. Display the WLanguage events associated with the Table control:
• Select the Table control.
• Display the popup menu (right mouse click) and select "Code".
2. In the "Initializing" event of the Table control, replace the lines:
MySource.ParamStartOfPeriod = "20160101" 5. Close the test window.
MySource.ParamEndOfPeriod = "20160331"
by:
MySource.ParamStartOfPeriod = EDT_StartDate
MySource.ParamEndOfPeriod = EDT_EndDate
In this WLanguage code, EDT_StartDate and EDT_EndDate are the names of two edit
controls found in the control template. Their values are associated with the parameters
ParamStartOfPeriod and ParamEndOfPeriod expected by the query.
3. Close the code editor.
4. Save the window by clicking among the quick access buttons.
190 Part 4: Full application with data Part 4: Full application with data 191
Lesson 4.5. Printing the content of a Overview
Table control
WINDEV allows you to print your data:
• by programming.
• via the reports. A report is the name given to the graphic representation of a print. A report is
created via the report editor.
WINDEV proposes several types of reports:
This lesson will teach you the following concepts
Estimated time: 20 mn
• Blank,
• Form,
• Table,
• Crosstab,
• TreeView table,
• Gantt chart.
• Organizer or scheduler,
• Spreadsheet,
• Mailing,
• Label,
• Report on form,
• Multicolumn report,
• Composite.
We are now going to explain how to create the different types of reports in the "WD Full Application"
application.
192 Part 4: Full application with data Part 4: Full application with data 193
If you did not create the windows in the previous lessons, you can follow this
lesson by opening a corrected project: in WINDEV’s home page (Ctrl + <), click
"Tutorial" and select "Full application (With windows)".
Answer
A full corrected application project is also available: in WINDEV’s home page (Ctrl
+ <), click "Tutorial" and select "Full application (Answer)". In this case, to follow
the rest of the lesson, select the "Windows 32-bit executable" configuration in
the "Project explorer" pane.
WINDEV AAF 25.PDF file. This file is automatically included in your application if corresponding to the control is displayed in the report viewer.
you choose the "Help for AAF" option when creating the automatic menu.
194 Part 4: Full application with data Part 4: Full application with data 195
8. The report editor appears with the report that was automatically created.
In test mode, the content of the Table control is printed directly.
Remark
At run time, the end user will be able to print directly or to start "Reports and
Queries" in order to create the corresponding report. See "Distributing "Reports
& Queries" with your applications" for more details about Reports and Queries.
196 Part 4: Full application with data Part 4: Full application with data 197
Lesson 4.6. Printing an order Overview
We want to give the user the ability to print the details of requested order. The report can be
directly printed via the popup menu of Table control.
This lesson will teach you the following concepts If you did not create the windows in the previous lessons, you can follow this
lesson by opening a corrected project: in WINDEV’s home page (Ctrl + <), click
"Tutorial" and select "Full application (With windows)".
Answer
• Creating a report based on a query. A full corrected application project is also available: in WINDEV’s home page (Ctrl
• Printing a report based on a query with parameters. + <), click "Tutorial" and select "Full application (Answer)". In this case, to follow
the rest of the lesson, select the "Windows 32-bit executable" configuration in
the "Project explorer" pane.
WINDEV proposes to create reports from several data sources: data files,
queries, controls, text files, ...
In most cases, we advise you to group the data to print via a query and to create
Remark
a report based on this query. To add an information into the report, all you have
to do is add the corresponding item into the query.
The reports based on data files must be simple reports, which means reports
used to display data coming from a single data file.
198 Part 4: Full application with data Part 4: Full application with data 199
Creating the query The description window of query is as follows:
▶ The query editor will be used to create the base query of report.
1. Click among the quick access buttons. The window for creating a new element is
displayed: click "Query". The query creation wizard starts.
2. Select the "Select" option.
Indeed, this query will be used to select the records that will be printed in the report. Go to the
next step.
3. The query description window is displayed. To build the query, we are going to select the
elements that will be displayed in the result.
4. Double-click the items found in the analysis on the left of description window. The items
taken into account are displayed in the middle of the screen.
We want to print in the report:
• information regarding the customer. In the "Customer" data file, double-click the FullName,
Address, ZipCode, City, and Country items.
• information regarding the order. In the "Orders" data file, double-click the OrderID and Date
items.
• information regarding the product. In the "Product" data file, double-click the Reference,
Caption, and PriceBT items.
• information regarding the order line. In the "OrderLine" data file, double-click the Quantity
and TotalBT items.
• information regarding the grand total of order. In the "Orders" data file, double-click the
TotalBT and TotalIOT items. At this time, this query is used to select all orders and the corresponding order lines.
We want to select the data corresponding to a single order whose identifier is known. Therefore,
The order in which the items are inserted into the query is important. we are going to define the order number in parameter.
Remark
Indeed, this order corresponds to the order used to display the data in
the report. The creation of the corresponding report will be simplified if ▶ To manage the "Order identifier" parameter:
this order is properly defined. 1. Select the Orders.OrdersID item (in the middle of the screen).
2. Expand "Selection condition" and select "New condition".
3. In the window that is displayed, we are going to specify that the selection condition
corresponds to a parameter:
200 Part 4: Full application with data Part 4: Full application with data 201
Perform the following operations: Creating the report based on a query
• Select "Is equal to".
▶ To create a report:
• Check "the parameter".
1. Click among the quick access buttons.
• The name of the parameter is automatically proposed: "ParamOrdersID".
2. The window for creating a new element is displayed: click "Report" then "Report". The report
4. Validate the condition description window. The number "1" is displayed on the right of Orders. creation wizard starts.
OrdersID item, indicating that a selection condition was defined.
3. The report creation wizard proposes several types of reports:
5. Give a name to the query: type "QRY_OrderForm" instead of "QRY_NoName1" in the "Query
name" area:
202 Part 4: Full application with data Part 4: Full application with data 203
7. The wizard asks you to specify whether a break is required. No break will be used in this • The items regarding the order totals will be displayed in the page footer. Indeed, this
report. This concept will be presented later in this tutorial. Answer "No". Go to the next step. information must not be repeated on each order line. For the TotalBT_Or and TotalIOT
8. You are going to specify the order in which the items will be printed and how they will be items, click the line corresponding to the item. In the "Block" column, expand the combo
distributed in the different blocks. In the wizard, the items are listed according to the order box and select "Page footer".
defined in the query:
• The items regarding the customer will be displayed in the "Page header" block. Indeed, this
information must not be repeated on each order line.
For the FullName, Address, ZipCode, City and Country items, click the line corresponding to
the item. In the "Block" column, expand the combo box and select "Page header".
The following table presents the different assignments of items in the order presented in
the wizard:
Item Block
FullName Page header
Address Page header
• The items regarding the order will also be displayed in the "Page header" block. Indeed,
this information must not be repeated on each order line. For the OrdersID and Date items, ZipCode Page header
click the line corresponding to the item. In the "Block" column, expand the combo box and City Page header
select "Page header".
• Furthermore, we are going to modify the caption of "OrdersID" item. Country Page header
• Select the line containing the OrdersID item. OrdersID Page header
• Click the Caption column and type "Order #". Date Page header
Reference Body
Caption Body
PriceBT Body
• The items regarding the order lines will be displayed in the report body. These items will
be displayed for all the order lines. Quantity Body
TotalBT Body
TotalBT_Or Page footer
TotalIOT Page footer
9. Go to the next step.
204 Part 4: Full application with data Part 4: Full application with data 205
10. The wizard proposes to create a counter, a sum or an average on the numeric items 14. All we have to do now is give a name and a title to the report.
found in the report. In this report, the calculations are performed by the query. Click the "No • Type the title : "Order form".
calculation" button. Go to the next step. • The "RPT_Order_form" name is automatically proposed.
11. This step is used to define the report layout.
We will keep the default values with the "Portrait" orientation. 15. Validate ("Finish").
16. The report being too large to be printed in Portrait mode, the report editor proposes to use
Print margins the landscape mode, to reduce the table or to print the table on several pages. In our case,
Remark
When choosing the print margins, don’t forget to take into account the physical accept the landscape mode.
margins of printers. The physical margins of printers are margins where no 17. Accept to reduce the table if necessary.
print is allowed. Furthermore, the physical margins differ according to the type 18. The window for saving the report is displayed. Validate the save information.
of printer.
19. The report is displayed in edit in the report editor:
206 Part 4: Full application with data Part 4: Full application with data 207
▶ Run this report by clicking among the quick access buttons. 3. The report is displayed as requested in the report viewer.
1. The report editor asks for the print destination. The print destination can be:
You can:
• Print the current page or the entire document by clicking the printer.
• Create a duplicate copy.
• Select a different zoom value.
• Save the report as a Word document (in RTF format).
• Save the report in HTML format.
• Save the report in PDF format.
• Save the report in XML format.
• Create an email with the report in HTML format in message body.
• Create an email with the report in PDF format in attachment.
• Annotate in the document.
• Perform a search in a document.
Validate. • Add watermarks.
▶ Close the report viewer.
208 Part 4: Full application with data Part 4: Full application with data 209
Modifying the "Order form" report
We are going to perform modifications regarding the layout in the report that was just created.
▶ Delete the number of pages displayed in the report:
1. Select the [PAGENUM]/[NBPAGES] control.
2. Press the Del key on the keyboard.
▶ We want to position the information regarding the customer and the order in the page header:
1. Delete the "Order form" caption found in page header.
2. Delete the captions found in front of the customer information (Full name, ...).
3. Position the item containing the city beside the zip code.
4. Select the customer details and move them (with the mouse) to the right of report.
5. Move the order number and the order date up (to the top of "Page header" block).
▶ We are going to position the totals properly in the page footer:
1. Select the controls (captions and items) corresponding to the totals found in the page footer. 3. Validate the description window.
2. Position these controls with the mouse in the bottom right corner of table. 4. The report is displayed in the report editor:
210 Part 4: Full application with data Part 4: Full application with data 211
Displaying the printed report from a menu option ▶ We are now going to define the option caption and write its WLanguage code.
1. Select "Menu option".
In our application, the "RPT_Order_form" report will be printed from an option found in the popup 2. Press the Space key on the keyboard: the caption becomes editable. Type the new caption
menu of the Table control used to list the requested orders. ("Print the order form") and validate.
As already seen, the Table control proposes an automatic menu. We want to keep the options of 3. Display the WLanguage events associated with the option:
this automatic menu and add an option that will be used to print the selected order form.
• Select the option.
The principle is as follows:
• Display the popup menu (right mouse click) and select "Code".
1. We are going to create a new popup menu. This menu will contain the WLanguage code used
4. Write the following WLanguage code:
to print the report.
2. We are going to link this popup menu to the Table control and specify that the default popup // Report viewer
iDestination(iViewer)
menu will be displayed just after the popup menu defined for the Table control. // Initializes the report query
iInitReportQuery(RPT_Order_form, ...
Creating the popup menu TABLE_QRY_FindOrders.COL_OrdersID)
▶ To create a popup menu in the "WIN_Menu" window: // Starts printing the report
iPrintReport(RPT_Order_form)
1. Open the "WIN_Menu" window in the editor if necessary (double-click its name in the "Project
explorer" pane for example). In this code:
2. On the "Window" pane, in the "Bars and menus" group, expand "Popup menus" and select • iDestination is used to specify that the report will be printed in the report viewer.
"New popup menu". • iInitReportQuery is used to specify the parameters expected by the query associated
3. A new popup menu appears in the editor. This menu option includes a single option named with the report. In our case, the query expects the order number in parameter. This order
"Menu option". number is found in the COL_OrdersID column of the TABLE_QRY_FindOrders Table control
for the current row.
• iPrintReport is used to print the specified report (the RPT_Order_form report in our case).
5. Close the code window and the window containing the popup menu.
6. Save the "WIN_Menu" window.
Associating the popup menu with the Table control
▶ Last step: we are going to link the popup menu to the Table control.
1. In the "WIN_Menu" window, display the "Finding orders" tab.
2. Select the Table control and display its description ("Table description" from the popup menu
4. Display the description of popup menu: of control).
• Select "Menu option". 3. In the "UI" tab, expand the "Popup menu" combo box.
• Display the popup menu (right mouse click). 4. Check "Add a popup menu", select the "MENU_Order" menu and select "At the beginning" to
• Select "Description of popup menu". specify that the menu is placed before the system menu.
5. Give a name to the popup menu ("MENU_Order") and validate.
212 Part 4: Full application with data Part 4: Full application with data 213
Print test
▶ Now, all we have to do is run a real test:
Lesson 4.7. Printing a list of
1. Run the test of "WIN_Menu" window. customers
2. Select the "Finding orders" tab pane.
3. Specify the criteria and start a search.
4. Select one of the orders displayed in the Table control.
5. Print the order via the popup menu. This lesson will teach you the following concepts
Estimated time: 20 mn
214 Part 4: Full application with data Part 4: Full application with data 215
Overview 4. Select the data source of report. The report will be based on the Customer data file. Select
"From a data file or from an existing query".
This lesson is used to print a list of customers, grouped by country and by state or province.
To do so, we are going to use a table report in order to clearly represent a list of data.
If you did not create the windows in the previous lessons, you can follow this
lesson by opening a corrected project: in WINDEV’s home page (Ctrl + <), click
Answer
216 Part 4: Full application with data Part 4: Full application with data 217
8. To add a sort on the country:
• Click on "+" to add a sort item. What is a break?
• In the window that is displayed, select the Customer.Country item. A Break is an operation used to group the records (or rows) according to one or
more criteria. Caution, the records (or rows) will be printed.
A break is NECESSARILY linked to a sort.
Remark
You will notice the presence of a break header and footer.
The information common to the different rows is found in the break header.
The totals, counters, ... are found in the break footer.
This break is used to group a set of records according to the same criterion. In
our example, the break is performed on the country and it is used to group all
the customers living in the same country.
• Validate.
9. To add a sort on the state:
• Click on "+" to add a sort item.
• In the window that is displayed, select the Customer.StateProvinceRegion item.
• Validate.
10. Modify the order of sort items. The customers must be sorted by country, by region, then in
alphabetical order.
• The "Customer.Country" item appears in second sort item. Select this item and move it in
first sort item via the arrow buttons.
• The "Customer.StateProvinceRegion" item appears in third sort item. Select this item and
move it in second sort item via the arrow buttons.
218 Part 4: Full application with data Part 4: Full application with data 219
Uncheck the "Customer.FullName" item. 16. This step is used to define the report layout.
14. Go to the next step. We will keep the default values with the "Portrait" orientation.
15. You are going to specify the order in which the items will be printed and how they will be
distributed in the different blocks. In our example: Print margins
Remark
• only the country will be found in the "Start of break 1" block. The "Country" item is When choosing the print margins, don’t forget to take into account the physical
automatically associated with the "Start of break 1". margins of printers. The physical margins of printers are margins where no
• only the state will be found in the "Start of break 2" block. The "StateProvinceRegion" item print is allowed. Furthermore, the physical margins differ according to the type
is automatically associated with the "Start of break 2". of printer.
• only the FullName, Address, ZipCode, City, StateProvinceRegion and Country items will be
displayed in the report. 17. Go to the next step.
Uncheck the CustomerID, Complement, Phone, Cell and Email items. 18. This step allows you to select the skin template used for the report. We recommend that you
use the same skin template as the one used for the windows. In our case, select the "Phoenix"
skin template for example and go to the next step.
19. All we have to do now is give a name and caption to the report and save it.
• Type the title: "List of customers".
• Keep the name proposed by default: "RPT_List_of_customers".
20. Validate.
21. Validate in order to switch to landscape mode.
220 Part 4: Full application with data Part 4: Full application with data 221
22. Accept to reduce the report by validating. ▶ Choose "Report viewer" and validate. The report is run and displayed in the report viewer.
The report is completed. Let’s now run the report test to see the result.
▶ Run this report by clicking among the quick access buttons. The print destination can be:
You have the ability to print the current page or the entire document by clicking the printer ("Print"
pane).
222 Part 4: Full application with data Part 4: Full application with data 223
5. In the input area, type "Reports". ▶ Test the window and its menu options by clicking among the quick access buttons.
▶ We are now going to modify this menu by adding an option used to exit from the application.
1. In the editor, select the "Menu" option.
2. In the popup menu (right mouse click), select "Transform to expand a sub-menu".
3. In the input area that is displayed, type "Exit".
4. We are going to associate this menu option with the "Alt + F4" shortcut:
• Select the "Exit" option.
• In the popup menu (right mouse click), select "Option description".
6. Select the "Reports" option: • In the "General" tab, in the "Keyboard shortcut" area, select "F4" and check "Alt".
• Display the popup menu (right mouse click).
• Select "Transform to expand a sub-menu".
7. In the input area that is displayed, type "List of customers". Press Enter to validate.
• Validate.
5. Display the WLanguage code of the option and write the following WLanguage code in the
event "Selecting the menu":
// Asks the user whether he wants to exit from the application
IF YesNo(No, "Exit from the application?") = Yes THEN
// End of application
▶ To type the WLanguage code of the option "List of customers": EndProgram()
END
1. Select the "List of customers" option in the editor.
2. Display the popup menu (right mouse click). Let’s take a look at this WLanguage code:
3. Select "Code". The code editor appears. • YesNo is used to establish a dialog with the user by asking him a question. The user can
4. Write the following code in the event "Selecting the menu": give an answer to the question via 2 buttons: yes or no.
• EndProgram (called if the user clicks "Yes") is used to end the application.
// The report is printed in the report viewer
iDestination(iViewer) ▶ Run the window test by clicking among the quick access buttons.
// Prints the report
iPrintReport(RPT_List_of_customers)
224 Part 4: Full application with data Part 4: Full application with data 225
Lesson 4.8. Statistics: Chart and Pivot Overview
Table controls
The presentation of statistics or summary tables is often required in a management application.
This type of presentation can be used for example to follow:
• the evolution of orders in time,
• the evolution of turnover,
• the evolution of stocks,
This lesson will teach you the following concepts • ...
Any executive manager wants to get this information.
• Displaying data in a chart. WINDEV proposes several controls allowing you to easily include this information in your
applications. Two specific controls will be used in this lesson:
• Creating summary tables via the Pivot Table control.
• the Chart control.
• the Pivot Table control.
If you did not create the windows in the previous lessons, you can follow this
lesson by opening a corrected project: in WINDEV’s home page (Ctrl + <), click
Answer
Estimated time: 30 mn "Tutorial" and select "Full application (with windows)".
A full corrected application project is also available: in WINDEV’s home page
(Ctrl + <), click "Tutorial" and select "Full application (Answer)".
226 Part 4: Full application with data Part 4: Full application with data 227
▶ To calculate the sum of values of "Orders.TotalIOT": 2. In the "Actions", on the right, click "Year, month" and select "Year". A window appears allowing
1. Select the "Orders.TotalIOT" item in the middle. you to create the Year item:
2. In the "Actions", on the right, select "Sum". The sum description window appears.
▶ We are now going to group the data by year and to sort it:
1. Select the "Orders.Date" item in the middle.
228 Part 4: Full application with data Part 4: Full application with data 229
Creating the Chart control 5. Type the chart parameters:
• the title: "Sales evolution".
We are going to include the Chart control in a new tab pane of WIN_Menu. • the legend: the chart has no legend.
▶ To create a new tab pane in "WIN_Menu": • the labels must be displayed.
1. Display "WIN_Menu" in the window editor (if necessary).
2. Double-click the Tab control: the control description window appears.
3. In the "General" tab, select the "Finding orders" tab pane and click the "New" button. A new
tab pane appears.
4. Select the new tab pane (named "Pane 4").
5. In the right section of the screen, type the caption of tab pane: "Chart".
6. In the right section of the screen, select an image in the image catalog:
• Click the button on the right of "Image" control. Select "Catalog" from the popup menu
that is displayed.
• The window of image catalog is displayed.
• Type "Chart" in the search control.
• Start the search by clicking the button with the magnifier.
• Select for example, and validate the different screens that appear.
7. Validate the description window of Tab control.
8. A new tab pane appears in the window.
▶ To create the Chart control:
1. In the "WIN_Menu" window, select the "Chart" tab pane if necessary.
2. On the "Creation" pane, in the "Graphic controls" group, click "Chart". The control appears
under the mouse cursor.
3. Click the "Chart" tab pane. The Chart control creation wizard starts.
6. Go to the next step.
4. In the wizard, select a "Column" chart.
7. Type the parameters of axes:
• X-axis title: Year
• Y-axis title: TO
Keep the default options and go to the next step.
230 Part 4: Full application with data Part 4: Full application with data 231
8. We are now going to define the data source. 13. Click the "Chart" tab pane to see the chart.
• For the labels (values displayed at the bottom of chart, the years in our example):
• the source corresponds to: "Browsing a file or a query",
• the data corresponds to the Year item in the QRY_SalesEvolutions query.
• For the series (values displayed in the Chart control): the Chart control will display a single
series corresponding to the total IOT calculated by the QRY_SalesEvolutions query.
• Double-click the "Sources of series" table.
• Type the caption: "Series 1".
• The source corresponds to: "Browsing a file or a query",
• The data corresponds to the "sum_TotalIOT" item in the QRY_SalesEvolutions query. Automatic features of Chart control (AAF)
Like the Table control, the Chart control proposes several automatic features
accessible via its popup menu.
Remark
Go to the next step.
You can for example:
9. No background image will be associated with the Chart control. Go to the next step.
• change the type of chart,
10. Give a name to the Chart control: "CHART_SalesEvolutions" and validate the wizard.
• save the chart,
11. The Chart control is automatically created in the editor.
• print the chart, ...
12. Click to run the window test.
232 Part 4: Full application with data Part 4: Full application with data 233
▶ To create a new tab pane in "WIN_Menu":
To master the use of a Chart control, don’t forget to take a look at the examples 1. Display "WIN_Menu" in the window editor (if necessary).
Example supplied with WINDEV:
2. Double-click the Tab control: the control description window appears.
• Unit example: The Chart control
3. In the "General" tab, select the "Chart" tab pane and click the "New" button. A new tab pane
• Training example: WD Chart appears.
These examples are available from the WINDEV home page (Ctrl + <). 4. Select the new tab pane (named "Pane 5").
5. In the right section of the screen, type the caption of tab pane: "Pivot Table".
6. In the right section of the screen, select an image in the image catalog:
Creating summary tables with the Pivot Table control • Click the button on the right of "Image" control. Select "Catalog" from the popup menu
that is displayed.
To handle the Pivot Table control in real conditions, we are going to create a Pivot Table control • The window of image catalog is displayed.
used to see the sales of products per country and per year in quantity and in turnover. • In the search control, enter "Array".
• Start the search by clicking the button with the magnifier.
• Select for example, and validate the different screens that appear.
7. Validate the description window of Tab control.
8. The new tab pane appears in the window.
234 Part 4: Full application with data Part 4: Full application with data 235
9. The products grouped by country must be displayed in the row headers. In the left section:
• expand the Customer data file and double-click the Country item.
• expand the Product data file and double-click Caption.
CAUTION: The calculation time depends on the size of the database and on
Remark
the number of row and column headers. The result of the pivot table can be
saved to avoid re-calculating at each interrogation.
236 Part 4: Full application with data Part 4: Full application with data 237
2. Click the "+" signs to expand the different columns and rows.
Lesson 4.9. Sending an email
Estimated time: 20 mn
▶ Stop the test. We will make a small improvement in this Pivot Table control. Indeed, nothing
indicates that one of the numbers in the cells corresponds to a quantity. We are going to use a
specific display mask for this value.
▶ To use a display mask in a cell:
1. Display the description of Pivot Table control (double-click the control).
2. In the "Content" tab, click "VAL_NoName2". The description of values displayed in the cells
appears.
3. In the "Mask" area, add the prefix "Qt: ".
238 Part 4: Full application with data Part 4: Full application with data 239
Overview We are going to use the SMTP protocol. Indeed, this mode is commonly used all over the world.
See the online help for more details about the other methods.
Several WLanguage functions allow you to manage the incoming and outgoing emails. You also
have the ability to access the email characteristics: To follow this lesson, you must have followed the lessons of this part until
Answer
• sender, recipients, "Printing a list of customers", page 215.
• outgoing date, subject, message, A full corrected application project is also available: in WINDEV’s home page
• attachments... (Ctrl + <), click "Tutorial" and select "Full application (Answer)".
Example
• Management via Lotus Notes, Outloook or MS Exchange: See the "WD Mail" example (full example supplied with WINDEV) for more
• The Lotus Notes or Outlook messaging software: these programs allow you to send and details. This example is accessible from the WINDEV home page (Ctrl + <).
receive emails.
• The "Simple Mail API" (also called SMAPI or Simple MAPI): this management mode of emails
is used by most of the Microsoft applications, especially by Microsoft Exchange.
• Management via the POP3, IMAP and SMTP protocols: A window for sending emails
• The POP3 protocol: this protocol for receiving emails is recognized by all service providers. It
is used to communicate with the server directly, available at your ISP. This protocol is used to This window will contain all controls allowing the user to type the different email elements. A
list the incoming messages and to read them. "Send" Button control will group all processes used to send the email.
• The IMAP protocol: this protocol for receiving emails is used to leave the emails the server so
that they can be consulted from different messaging clients or webmails. Creating the window
• The SMTP protocol: this protocol for sending emails is recognized by all service providers. ▶ Create a new window:
1. Open the "WD Full Application" project if necessary.
In this lesson, we are going to create a window allowing the user to send an email from the "WD
Full Application" application. This window is as follows: 2. Create a new blank window.
• Click among the quick access buttons.
• The window for creating a new element is displayed: click "Window" then "Window".
• The window creation wizard starts.
• In the "Based on a template" tab pane, select "Use: WINTPL_Template" and validate the
wizard.
3. The window for saving an element is displayed. The title of this window being "Sending an
email", its name is automatically proposed: "WIN_Sending_an_email". Validate the proposed
information.
Creating the controls used to configure the sending
In a first time, we are going to create all controls for configuring the SMTP server used to send
messages. Four edit controls are required:
• SMTP server,
• Port of SMTP server,
• User name,
• User password.
240 Part 4: Full application with data Part 4: Full application with data 241
▶ To create the edit control corresponding to the name of SMTP server: ▶ Align the created controls:
1. On the "Creation" pane, in the "Usual controls" group, click . 1. Select the four controls.
2. The control shape appears under the mouse cursor. 2. On the "Alignment" pane, in the "Inside and outside" group, click "Justify (Ins. and Out.)".
3. Click the top left corner of window: the edit control is automatically created.
4. Select the control and press Enter. The caption becomes editable. Type "SMTP server" and
validate. The control name automatically corresponds to EDT_SMTP_Server.
▶ To create the edit control corresponding to the port:
1. On the "Creation" pane, in the "Usual controls" group, expand "Edit".
2. Select a preset Integer edit control.
3. The control shape appears under the mouse cursor.
4. Click below the "SMTP server" control: the edit control is automatically created.
5. Select the control and press Enter. The caption becomes editable. Type "Port" and validate.
The control name automatically corresponds to EDT_Port.
▶ To create the edit control corresponding to the user name:
1. On the "Creation" pane, in the "Usual controls" group, click .
2. The control shape appears under the mouse cursor.
3. Click below the "Port" control: the edit control is automatically created. 3. Save the window ( or Ctrl + S).
4. Select the control and press Enter. The caption becomes editable. Type "User" and validate.
The control name automatically corresponds to EDT_User. Creating the controls used to type the email characteristics
To write an email, the user must have:
▶ To create the edit control corresponding to the user password:
• A control used to type the sender address.
1. On the "Creation" pane, in the "Usual controls" group, expand "Edit".
• A control used to type or select the recipient address.
2. Select a preset "Password" edit control.
• A control used to type the email subject.
3. The control shape appears under the mouse cursor.
• A control used to type the email text. The user must have the ability to format the email text.
4. Click below the "User" control: the edit control is automatically created.
• A control used to add attachments.
The "Password" edit control appears in the editor with a bullet and an eye. We are now going to create these controls in our window.
At run time, when the user types his password, the characters will be replaced ▶ To create the edit control corresponding to the sender address:
by bullets. A click on the eye will allow the user to see his password in clear:
Tip
this allows the user to check his password. 1. On the "Creation" pane, in the "Usual controls" group, expand "Edit".
This feature can be disabled by programming if necessary. See the online help 2. Enter "Email" in the search box at the top of the list of preset controls. Select "eMail Edit".
for more details. 3. The control shape appears under the mouse cursor.
4. Click below the "Password" control: the edit control is automatically created.
5. Select the control and press Enter. The caption becomes editable. Type "Sender" and
validate.
▶ The control used to type the recipient address must list the addresses of the customers found
in the database but it must also allow the user to type another address. To do so, we will be
using an "Editable combo box" control linked to the Customer data file.
1. On the "Creation" pane, in the "Usual controls" group, click "Combo Box".
2. The control shape appears under the mouse cursor.
3. Click below the "Sender" control: the wizard for creating the Combo Box control is
automatically started.
4. Select "Display the data found in a file or in an existing query". Go to the next step.
242 Part 4: Full application with data Part 4: Full application with data 243
5. Select the Customer data file. Go to the next step. ▶ Align the different controls found in the window.
6. The email addresses of customers must be displayed in the control:
• Uncheck the "CustomerID" item.
• Check the "Email" item.
Go to the next step.
7. The sort item is the "Email" item. Go to the next step.
8. The return value is the "Email" item. Go to the next step.
9. Keep the default options. Go to the next step.
10. In the "Additional parameters" screen, check "Allow the input". Indeed, the user must have
the ability to type a new email address. Go to the next step.
11. Modify the name and caption of Combo Box control:
• The control name is "COMBO_Recipient".
• The control caption becomes "Recipient".
12. Validate the wizard. The control is automatically created in the window.
▶ To create the edit control corresponding to the email subject:
1. On the "Creation" pane, in the "Usual controls" group, click .
2. The control shape appears under the mouse cursor.
3. Click below the "Recipient" control: the edit control is automatically created.
4. Select the control and press Enter. The caption becomes editable. Type "Subject" and
validate.
We will now create the Button control to send emails.
▶ For the message body, we will be using an HTML edit control: the user will have the ability to
format the email text via a specific toolbar. Sending the email
1. On the "Creation" pane, in the "Usual controls" group, expand "Edit". ▶ To create the Button control to send emails:
2. Enter "HTML" in the search box at the top of the list of preset controls. Select "HTML Edit". 1. On the "Creation" pane, in the "Usual controls" group, click .
3. The control shape appears under the mouse cursor. 2. Click the location where the control will be created (at the bottom of the window for example).
4. Click below the "Subject" control: the edit control is automatically created. 3. Select the control and modify its caption (press Enter for example). The new caption is
5. Enlarge the control in order for several lines to be visible. "Send".
6. Open the control description window (double-click the control). 4. Edit the WLanguage code associated with this Button control: select "Code" in the popup
• On the "General" tab, modify the mode for displaying the formatting toolbar. This toolbar menu (right click).
must always be visible. 5. Write the following lines of code in the "Click" event:
• Validate the control description window. • WLanguage code for opening the connection and starting the SMTP session:
7. Reposition the control if necessary in order for the toolbar to be displayed properly. MySession is EmailSMTPSession
MySession..Name = EDT_User
▶ We are going to create a file picker allowing the user to add an attachment. Instead of creating MySession..Password = EDT_Password
it from scratch, we will be using a preset edit control of file type. Via the popup menu of control MySession..ServerAddress = EDT_SMTP_Server
("Browse" option), the user will be able to select the file to attach. MySession..Port = EDT_Port
// Starts the SMTP session
1. On the "Creation" pane, in the "Usual controls" group, expand "Edit". The list of preset controls IF NOT EmailStartSession(MySession) THEN
proposed by default is displayed. Error("Unable to connect to the SMTP server.", ...
2. Select the "File" control and perform a Drag and Drop toward the "WIN_Sending_an_email" ErrorInfo())
window: drop the control below the "HTML text" control. The file picker is immediately created. RETURN
END
244 Part 4: Full application with data Part 4: Full application with data 245
This code is using an advanced emailSMTPSession variable. The different properties of this Improving the window
variable are used to define the characteristics of SMTP session. Then, EmailStartSession
associated with this variable is used to start the session. We are going to improve our window:
• WLanguage code for preparing the email: • Add a Button control to close the window.
MyMessage is Email • Format the window via the management of anchors and the tab order.
• Start the window from the "WIN_Menu" window.
MyMessage..Sender = EDT_Sender
MyMessage..Subject = EDT_Subject Closing the window
MyMessage..HTML = EDT_HTML_Text
MyMessage..Message = HTMLToText(EDT_HTML_Text) ▶ To add a Button control to close the window:
// Adds a recipient
1. On the "Creation" pane, in the "Usual controls" group, expand "Button": the list of preset
Add(MyMessage..Recipient,... buttons is displayed.
COMBO_Recipient..DisplayedValue) 2. Click the "Close" button.
3. Click the position in the window where the control must be created (for example at the
// Adds the attachment if necessary
IF EDT_File <> "" THEN bottom, to the right of the "Send" Button control).
EmailLoadAttachment(MyMessage, EDT_File)
END Formatting
This code is using an Email variable. The different properties of this variable are used to ▶ To define the anchors:
define the characteristics of email to send. This code associates the content of different • Select the "Sender", "Recipient" and "Subject" controls: these controls must be anchored in
window controls to the properties of Email variable. width.
• WLanguage code for sending the email: • Select the "HTML text" control: this control must be anchored in width and in height.
// Send the email
• Select the Button controls: these controls must be anchored to the right and at the bottom.
IF EmailSendMessage(MySession, MyMessage) = False THEN • Select the control for file selection: this control must be anchored in width and at the bottom.
Error("Message not sent.", ErrorInfo())
ELSE ▶ To define the tab order:
// Message sent
ToastDisplay("Message sent", toastShort, ... The tab order of controls is the order in which the user can type the values
vaMiddle, haCenter) in the different window controls. Going from a control to another one is
END
performed when pressing the Tab key at run time.
The email is sent by EmailSendMessage. All you have to do is pass in parameter the The default tab order corresponds to the creation order of controls. It can be
Remark
variable containing the characteristics of SMTP session and the variable containing the modified:
characteristics of email to send. • by specifying an automatic tab order: the first control in edit will be the
If the email is sent, a Toast message is displayed, indicating that the email was sent. A control found in the top left corner of window, the second one will be the
Toast message corresponds to a furtive message. one found immediately to its right or below...
• WLanguage code for closing the SMTP session: • by specifying a tab order by selection.
// Closes the SMTP session
EmailCloseSession(MySession) 1. Display the tab order via the F5 key.
This code closes the session with EmailCloseSession. 2. Define the automatic tab order: on the "Window" pane, in the "Order" group, expand
"Navigation" and select "Define automatically".
▶ Save the window and its code ( or Ctrl + S).
246 Part 4: Full application with data Part 4: Full application with data 247
3. The numbers are modified and they now appear in order. ▶ Save the window and its code ( or Ctrl + S).
▶ Run the project test ( among the quick access buttons) and open the window for sending
emails via "Menu .. Send an email".
In this WLanguage code, OpenChild is used to open the window in "non-modal" mode: the user
will be able to write an email and to see the information displayed in the main window at the
same time.
248 Part 4: Full application with data Part 4: Full application with data 249
Lesson 4.10. Identifying the user: the Overview
An application can be used by several contributors with different profiles. It is often necessary to
user groupware define several access levels according to the user.
Let’s take a simple example: an application for sales management proposes the following features:
• Viewing the price list.
• Modifying the price list.
This lesson will teach you the following concepts • Entering orders.
• Entering customers.
• What is the user groupware? The accesses differ according to the user. Some examples:
• Integrating the user groupware. • the administrative assistants can see the price list and create orders.
• Configuring the user groupware. • the sales people can see the price list, place orders and create new customers.
• Checking the user groupware. • the sales directors have access to all options.
WINDEV allows you to easily manage these access levels in your applications via the user
groupware.
We are going to include the user groupware in our "WD Full Application" application and to
configure it.
Estimated time: 20 mn
If you did not create the windows in the previous lessons, you can follow this
Answer
lesson by opening a corrected project: in WINDEV’s home page (Ctrl + <), click
"Tutorial" and select "Full application (Answer)".
250 Part 4: Full application with data Part 4: Full application with data 251
Integrating the user groupware 7. In the "Files" tab, select "Enable history of connections". This option allows the supervisor to
get information about the connected users.
▶ To include the user groupware in the "WD Full Application" project:
1. On the "Project" pane, in the "Project" group, click "User groupware". The window for
configuring the user groupware is displayed.
If you (or the end user) is using Windows Vista (or a more recent operating
system), we advise you to use the "Data directory" option.
252 Part 4: Full application with data Part 4: Full application with data 253
9. Select the "Registration" tab. 4. A new menu is displayed, allowing you to run the application test or to configure the
application.
Remark
A single user exists by default, the supervisor. During the first application start, • when developing the application. The necessary data files (regarding the
connect yourself by using the name: "supervisor". You will have the ability to users and their rights) can be installed along with the application.
define the password used by the supervisor. • when the application is installed, by the administrator of the application.
▶ To configure the user groupware, we are going to create a "Test_1" user and associate this user
with the "Tests" group. Then, we are going to configure the management of rights for the group.
254 Part 4: Full application with data Part 4: Full application with data 255
▶ To create a user: ▶ To associate the user with the group:
1. Click the "New" button found below the "Users" area. The screen for entering a new user is 1. Select the "Test_1" user in the window.
displayed. 2. Drag and Drop the "Test_1" user to the "Tests" group.
2. Type the following information:
• Login: Test_1
• Last name: Test_1
• Password: Test_1
password, click on the eye icon: the password appears in clear as long as
the mouse button is pressed.
256 Part 4: Full application with data Part 4: Full application with data 257
2. Click the "Forbid the access" button. 5. Switch the "Send an email" option to invisible:
258 Part 4: Full application with data Part 4: Full application with data 259
3. The application starts. If necessary, select the tab "List of products". You will notice that the
"New" and "Modify" buttons are grayed and that the "Send an email" option is invisible. Lesson 4.11. Re-use code via the
external components
Estimated time: 40 mn
The user groupware will no longer be used in the rest of this tutorial. Therefore, it can be disabled.
1. On the "Project" pane, in the "Project" group, click "User groupware".
2. In the window that is displayed, in the "Integration" tab, select "No user groupware".
3. Validate.
If automatic tests are performed in your application, the user groupware must
Remark
be configured in order not to use the login window. To do so, fill the "Automatic
login in test mode" option in the "Runtime" tab of the window for configuring the
groupware.
260 Part 4: Full application with data Part 4: Full application with data 261
Overview Teamwork
An external component is a building block that can be re-used in an unlimited number of projects A developer creates and maintains an external component that is made available to other
(and therefore executables). developers. No risk of modifications "made by mistake"!
The huge projects
The external components allow you to have several small projects as well as a central project in
which the elements found in the other projects are visible. The external components are a lot
more convenient to use than the libraries (WDL files).
The databases accessed by several projects
When the same database is accessed by several projects, you often find inconsistencies in the
database caused by modified or old source code. By grouping the operations used to access the
database (at least in write mode) in an external component, a single source code must be checked
and maintained ; therefore, the risks of database inconsistency are reduced.
Furthermore, using a component avoids recompiling the application when the analysis is modified.
The processes used in several projects
Complex processes are often used in several projects. These processes can be re-used via "sets
of procedures" or "classes". In this case, the modifications may not be applied to the different
projects, making these elements no longer compatible between themselves.
Using external components prevents such out-of-sync modifications, preserves the compatibility
between projects and simplifies the common modifications.
Furthermore, the PRIVATE keyword allows you to ensure the confidentiality of your code at all
levels of external component. When re-using your external component in another WINDEV project,
An external component allows you to have an identical process with a single source code to the call to a PRIVATE procedure will not be allowed but the documentation regarding the use of
perform a given operation even if this process must be performed by several projects. procedure will be displayed!
The projects that use an external component have access in the WINDEV editor to the name of The ability to distribute a feature or set of features
objects, procedures or methods made visible by the component creator. The projects cannot see
or modify the source code. This ensures confidentiality and stability of source code. The external components allow you to develop a feature or a set of features. Other WINDEV
Creating an external component is child’s play. developers will be able to include these features in their own projects. The developers who are
How to proceed? Don’t change anything, create your windows, procedures, classes. Then, when using an external component can see the component elements that are made visible. However,
you’re done, create a Component configuration with all the elements needed for your component, the source code cannot be viewed or modified.
and generate. It’s that simple! Your external components can be distributed (free of charge or not)!
A component can contain code, windows, an analysis, data files, etc!
Multi-product external component
Five methods can be used to share "code" in WINDEV: An external component can be intended to operate in:
1. The sets of procedures. • a WINDEV application,
Remark
262 Part 4: Full application with data Part 4: Full application with data 263
Step by step ▶ To create a project configuration whose type is "Component":
1. On the "Project" pane, in the "Project configuration" group, expand "New configuration" and
select "External component (WDK)".
Step 1 : Creating an external component
2. The wizard for creating a project configuration starts. WINDEV proposes to create a project
We are going to create an external component from the "WD Full Application" project. This project configuration whose type is "Component". Go to the next step.
is used to manage orders, products and customers. This external component will be used to 3. Give a name to your project configuration: "CompoOrdersByCity" for example. Go to the next
immediately find out in another application the customers corresponding to a given city. step.
During the call to the external component, you will have the ability to: 4. Keep the default options. Go to the next step.
• Pass a city in parameter. 5. Select the elements that will be included in the project configuration. In this example, these
• Retrieve a string containing the customer name and the total amount of his orders. elements will also be found in the component.
• Click the "None" button.
To avoid having to develop the code required for the component to operate, the "WD Full
Application" project contains all necessary elements. • Select the "QRY_OrdersByCity" and "SET_Component" elements.
If you did not create the windows in the previous lessons, you can follow this
lesson by opening a corrected project: in WINDEV’s home page (Ctrl + <), click
Answer
Remark
The project configurations are used to create several "targets" from the same
project:
• A 32-bit application,
Remark
264 Part 4: Full application with data Part 4: Full application with data 265
▶ We are now going to generate our component. 8. The wizard proposes to manage the different component versions. In our example, the
1. On the "Project" pane, in the "Generation" group, click "Generate". component was just created.
2. The wizard for generating the component starts. Go to the next step of the wizard. Keep the default options. Go to the next step.
WINDEV lists the elements that will be included in the component (elements specified in the 9. Type the information regarding the component:
configuration and analysis). • Owner,
• Caption, Copyright, ...
10. Go to the next step.
11. You have the ability to associate an image with your component. Go to the next step.
12. Specify the main component overview. This overview will allow the user to find out the
component purpose. Type for example:
13. Go to the next step. The wizard will automatically generate the documentation about the
component. This documentation can be based on the comments inserted into your source
code.
14. Go to the next step. You have the ability to modify the generated documentation. Don’t do
anything. Go to the next step.
15. You have the ability to create a help file associated with your component (CHM format).
5. Go to the next step. This help file will be supplied along with the component. The users will be able to access it by
6. WINDEV proposes to allow the translation of component. This feature is interesting if your pressing F1 from the component code.
component must be used by multilingual applications. We will generate no help file. Go to the next step.
16. The component will not be saved in the SCM. Go to the next step.
17. All we have to do now is give a physical name to our component.
If the option "Allow component translation" is checked, the specified component elements can
be translated from the application that is using the component.
This translation will be performed via WDMSG, independent module used to check out and
check in the project messages to translate.
In this example, don’t check this option. Go to the next step.
7. Choose the component languages. Our example will contain the English language only. Go to
the next step.
▶ Validate ("Finish"). A message indicates that the component was generated. Click "End" to
validate the message.
▶ Well done, you’ve just created your first ready-to-use component!
266 Part 4: Full application with data Part 4: Full application with data 267
Step 2 : Using the external component • On the "Details" tab, the component description as well as the help that was automatically
generated. This allows you to identify the re-usable component elements.
Once created, your component can be used in any other WINDEV project. Let’s now see how this
component can be re-used. The component description can be accessed at any time. Simply select
Remark
▶ To do so, we are going to create a new project and import our component into this project. the component in the "Project explorer" pane and select the "Description"
option from the popup menu. In this case, you also have the ability to
1. Close the current project: on the "Home" pane, in the "General" group, expand "Close" and
define the load mode of component.
select "Close the project".
2. Validate the closing of project and save the modifications if necessary.
3. The WINDEV home page is displayed. 8. Validate ("Close" button). The component is included in your project.
4. Create a new project: click "Create a project" in the home page. ▶ We are now going to create a blank window to use the component.
• This project is a Windows application. 1. Create a blank window.
• This project is named "CompUse" and it has no analysis. • The window title is "Customers by city".
5. On the "Project" pane, in the "Project" group, expand "Import" and select "An external • The window name is "WIN_Customers_by_city".
component .. From a file". • Save.
6. In the directory of "WD Full Application" project, select the "EXE\CompoOrdersByCity" sub- 2. Display the WLanguage events associated with the window ( "Code" from the popup menu).
directory, then the "CompoOrdersByCity.wdi" file.
3. We are going to call the DataLocation function of component in the "End of initialization"
event. This function expects in parameter the path used to access the data files handled by the
If the component was created from:
component. Type the access path to the data found in the "WD Full Application" example. For
• the "WD Full Application (Exercise)" example, select the "My Projects\ example:
My Examples\WD Full Application (Exercise)\EXE\CompoOrdersByCity"
Remark
sub-directory, then the "CompoOrdersByCity.wdi" file. DataLocation(...// Specify the path of YOUR data
"C:\WINDEV\Tutorial\Exercises\" + ...
• the "WD Full Application (with windows)" example, select the "My "WD Full Application\Exe")
Projects\My Examples\WD Full Application (With windows) (Exercise)\
EXE\CompoOrdersByCity" sub-directory, then the "CompoOrdersByCity.
wdi" file. If your project is using another procedure named "DataLocation", the name of
component procedure must be prefixed by the name of the set of procedures
Remark
used. The code becomes:
7. Click "Open", the description of our component is displayed. This description contains:
• On the "General" tab, the elements typed when creating the external component as well as SET_Component.DataLocation(...
its location.
268 Part 4: Full application with data Part 4: Full application with data 269
▶ You can now edit the WLanguage events associated with "BTN_Search". When this control is ▶ Run the window test: click among the quick access buttons. In the edit control, type "Paris"
clicked on, we will run the search procedure found in the component. This procedure: (while respecting the case) and click the "Search" button. The list of customers is displayed.
• expects the city name in parameter
• returns a string in the following format:
Name of customer 1 + TAB + Total sales 1 + CR +
Name of customer 2 + TAB + Total sales 2 + ...
Standard distribution
In this case, you must supply all the files required for your component to operate. These files are
created when generating the component (WDI, WDK and WDO files, images, other documents, ...).
These files will be manually copied from their source directory to the destination directory. The
WINDEV projects that use this component will find the dependent files in this destination directory.
List of files that must be supplied for a standard distribution:
• the files automatically generated by WINDEV (WDK, WDI, ...).
• the dependency files.
• the WDO file must be supplied if the component is using dependency files. This file contains
the references to the external files used in the component.
270 Part 4: Full application with data Part 4: Full application with data 271
Professional distribution
The distribution of components via a setup procedure consists in providing a setup program to the
Lesson 4.12. Consuming a Webservice
users of WINDEV component. This program installs all the files required for using the component
in the directory specified by the user.
This setup mode is used to automatically manage: This lesson will teach you the following concepts
• the WDO file and the setup of additional files used by the component.
• the automatic setup of necessary tools (MDAC, ODBC driver for HFSQL, ...).
• the automatic update of data files used by the component (if necessary). • Overview.
• the uninstall program of component. • Importing and consuming a Webservice.
▶ Close the "CompoUse" project: on the "Home" pane, in the "General" group, expand "Close" and
select "Close the project".
▶ Open the "WD Full Application" project that was used beforehand (for example, display the
home page and select the "WD Full Application" project found in the recent projects). If
Estimated time: 10 mn
necessary, select the project configuration corresponding to the component in the "Project
explorer" pane.
▶ To create the setup, go to the "Project" pane, "Generation" group, and click on "Setup
procedure".
The wizard for creating the component setup starts.
We won’t go into details about the different setup modes of a component. Follow the instructions
given by the wizard.
See the online help for more details (keyword: "External component, Distributing a component").
272 Part 4: Full application with data Part 4: Full application with data 273
Overview ▶ Position (if necessary) on the "32-bit Windows executable" configuration: in the "Project
explorer" pane, in the "Configurations" folder, double-click "Windows 32-bit executable".
In most cases, an XML Web service is defined as an application accessible via the standard
Internet protocols. More specifically, Web services allow several computers connected via Internet ▶ To import a Webservice into the project:
to interact. 1. On the "Project" pane, in the "Project" group, expand "Import" and select "A Webservice".
Web services allow you to run procedures and processes on a remote Web server (.NET, SOAP or 2. The import wizard starts. Go to the next step.
J2EE) from a client computer. 3. Specify the address into which the WSDL description of Webservice must be imported:
https://examples.webdev.info/WSTUTORIALV2_WEB/awws/WSTutorialV2.
With WINDEV, these Web services can be used as client, via the SOAP protocol on HTTP (the awws?wsdl
standard Internet protocol for transferring HTML pages), with the SOAPxx, DotNetxx and J2EExx
functions. Reminder: This Webservice is used to interrogate a supplier database to check the availability
(stock) of a product from its reference.
Regardless of the platform of the Web server (.NET, J2EE, ...), a Web service is accessible via the
SOAP protocol.
Remark
With WINDEV, you don’t even have to be an expert in this field. A wizard takes
care of ("almost") everything!
Practical example
A Webservice specific to the Tutorial allows you to check the different operations that can be
performed on a Webservice.
Integrated to the "WD Full Application" project, this Webservice is used to interrogate a supplier
database to check whether a product is available (stock) from its reference.
In a first time, the Webservice will be imported into the "WD Full Application" project then it will be
used in the application to check the product availability from a Product form.
4. Go to the next step. The Webservice is imported.
Importing a Webservice
▶ Close the current project if necessary. The WINDEV home page is displayed.
▶ In the home page, click "Tutorial" and select "Full application (Exercise)". The project is loaded.
If you did not create the windows in the previous lessons, you can follow this
lesson by opening a corrected project: in WINDEV’s home page (Ctrl + <), click
Answers
5. Validate the information window. The imported Webservice is in the "Imported Webservices"
"Tutorial" and select "Full application (With windows)". folder of the "Project explorer" tab pane.
A full corrected application project is also available: in WINDEV’s home page 6. In the "Project explorer" pane, expand the "Imported Webservices" folder.
(Ctrl + <), click "Tutorial" and select "Full application (Answer)"
274 Part 4: Full application with data Part 4: Full application with data 275
Let’s take a closer look at the information displayed in the "Project Explorer" pane: Consuming a Webservice
In our "WD Full Application" example, the call to the Webservice will be included in the tab used
to see the list of products. A button "In stock?" is used to check whether the product displayed via
the Webservice is available.
▶ To use the Webservice:
1. Open the "WIN_Menu" window in the editor (double-click its name in the "Project explorer"
pane, for example).
2. Add a Button control in the "List of products" tab pane:
• On the "Creation" pane, in the "Usual controls" group, click .
• Click below the "Modify " Button control in the window.
• The control is automatically created.
3. Modify the characteristics of the control ("Description" from the popup menu). This control is
named "BTN_InStock" and its caption is "In stock?".
276 Part 4: Full application with data Part 4: Full application with data 277
3. Select any product in the Table control and click "In stock?".
Lesson 4.13. Monitor the evolution of
your applications
Estimated time: 20 mn
278 Part 4: Full application with data Part 4: Full application with data 279
Overview Automatic tests
The project dashboard is an essential element for managing the WINDEV projects. The project One of the most interesting features of the dashboard is to give information about the tests that
dashboard gives an overall view of the progress of a project. have been run on the application.
The dashboard includes several elements (widgets) that give an overall view of the project status. Several tests have already been run while developing our application.
In this section, we will present the operations that can be performed on the dashboard elements The automatic tests are a category of specific tests. The automatic tests are used to automatically
as well as the management of automatic tests and the optimization of queries. perform some operations on your windows. These tests are recorded as WLanguage scenarios
and they can be easily modified in the code editor. Once recorded, the automatic test can be
If you did not create the windows in the previous lessons, you can follow this re-run as many times as necessary, to test for example the impact of a modification made to a
lesson by opening a corrected project: in WINDEV’s home page (Ctrl + <), click window, a procedure, ...
Answer
"Tutorial" and select "Full application (with windows)". Let’s give it a try! We are going to create an automatic test on the edit window that was created at
A full corrected application project is also available: in WINDEV’s home page the beginning of this lesson.
(Ctrl + <), click "Tutorial" and select "Full application (Answer)"
Remark
▶ To display the project dashboard (if not already done), on the "Project" pane, in the "Project" The automatic tests can be run on the windows, procedures, classes.
group, click .
The dashboard ▶ To create an automatic test on a window, all you have to do is run the test of the window:
1. Open the "WIN_Menu" window in the editor.
2. On the "Automatic tests" pane, in the "Tests" group, expand "New" and select "Record a new
scenario".
3. In the window that is displayed, click "Start recording".
4. The test of the window is run.
5. Click the "Finding orders" tab pane.
6. Choose the "Credit card" payment mode.
7. Click "Find".
8. Close the window via "Menu .. Exit" and confirm the end of application.
Remark
This option may not be available if you did not follow the entire tutorial. In this
case, click the "x" to close the window.
The project dashboard includes several Widgets. Each Widget displays various information about
the project.
For example, the "Performances" Widget is used to start the performance profiler or to open the
last performance report.
The "Static audit and Compilation" Widget is used to quickly see whether the project contains
compilation errors.
You have the ability to enable (or not) a Widget, to add one or to delete one at any time.
280 Part 4: Full application with data Part 4: Full application with data 281
11. The test editor displays the WLanguage code of the test that was just saved: 9. The test appears again in the test editor. The "Compilation errors" tab pane reports several
test errors.
10. Redisplay the "WIN_Menu" window in the editor.
11. Display the description of the "Find" Button control ("Description" from the popup menu).
12. In the "UI" tab, select "Enabled".
13. Validate the control description window.
14. Go back to the test editor (click the corresponding button in the open documents bar).
15. Run the test again. The test is now successfully run.
▶ Another feature of the test editor is the ability to modify or add WLanguage code in the test
scenarios. We are going to add code lines to check whether the Table control contains at least
one record.
1. Display the test editor if necessary (for example, double-click "TEST_Menu" in the "Tests"
folder of the "Project explorer" pane).
2. Add the following code before the line "EmulateMenu("_Menu","OPT_Exit")":
// If the Table control contains no record
IF WIN_Menu.TABLE_QRY_FindOrders..Count = 0 THEN
// An error must be signaled
TestWriteResult(twrError, ...
"The Table control is empty after search")
The test is available and it is not passed ( icon in front of the test name in the editor). END
12. The test can be run at any time:
• Select the test name in the test editor.
• In the popup menu (right mouse click), select "Run".
13. The test is automatically run and the test editor displays the result in the "Test result" pane
(the test was successfully run in our case).
14. Save the test if necessary.
Remark
The WLanguage functions used to run automatic tests are the EmulateXXX
functions.
▶ We are now going to perform a modification in our window and to run the test again. The
modification affects the "Find" Button control. We are going to gray it.
1. Display the "WIN_Menu" window if necessary.
3. Save the test.
2. In the editor, click the "Finding orders" tab pane and select the "Find" Button control.
4. Click the icon. The test is successfully run. Indeed, the Table control contains at least one
3. Display the control description ("Description" from the popup menu). record.
4. In the "UI" tab, select "Grayed".
5. Validate the control description window.
6. Save the window.
7. Go back to the test editor (click the corresponding button in the open documents bar).
8. Run the test again.
282 Part 4: Full application with data Part 4: Full application with data 283
The test editor proposes several features that will not be presented in this tutorial:
• the ability to use a set of test values. Lesson 4.14. Deploying the application
• the definition of input and output parameters for the test.
• the ability to create a test library to run the test of an executable on a computer other than the
development computer for example.
This lesson will teach you the following concepts
See the online help for more details (keyword: "Automatic test").
▶ Close the editor of automatic tests.
• Creating the executable.
• Help about the new features.
• Creating the setup.
Estimated time: 30 mn
284 Part 4: Full application with data Part 4: Full application with data 285
Overview 3. Describe the general options of executable:
• the executable name: we will keep the default name.
A full application was created, allowing you to discover several WINDEV features. We must now • the name of icon associated with the executable: you have the ability to select an icon in
generate the executable and install the application on the user computers. That’s what we are the image catalog.
going to do now. So, you will be familiar with the main topics for developing a WINDEV application.
• the splash screen. Several types of splash screens are available. A splash screen with
animated text is selected by default. The "Options" button is used to configure it.
If you did not perform the operations in the previous lessons, you can follow this
Answer
lesson by opening a corrected project: in WINDEV’s home page (Ctrl + <), click
"Tutorial" and select "Full application (Answer)"
WINDEV also allows you to create 64-bit executables, Linux executables, 5. You have the ability to customize the error message of application. We will keep the message
services, Java applications, ... proposed by default. Go to the next step.
6. The wizard proposes to enable the telemetry in the application. We won’t be using this
feature. Go to the next step.
2. The wizard for creating an executable starts.
Telemetry allows you to get detailed statistics about the use of your application
by the end users. Telemetry returns various information about your deployed
Remark
applications, giving you the ability to improve them.
See the online help for more details about implementing and configuring the
telemetry.
286 Part 4: Full application with data Part 4: Full application with data 287
7. This step is used to specify whether the executable will take the patches into account. 12. We are now going to type the information about the executable. This information is
displayed in the Windows explorer by selecting the file properties.
When a modification is performed in the application, to avoid having to provide Type the following information:
the entire executable, the additional resources (windows, reports, ...) can be
supplied as patches. These patches are additional libraries.
Remark
If the option "Yes: the executable will take these updates by patch into
account" was checked when the executable was created, the elements found
in the patch will replace the elements found in the application library when the
application starts.
See the online help for more details.
Select "Automatic (recommended)" if necessary. This option is used to install the data files:
• in the data directory of application (if the executable is installed in "Program files").
• in the executable directory.
11. Go to the next step.
288 Part 4: Full application with data Part 4: Full application with data 289
15. We are now going to define the options for integrating the WINDEV framework. Creating the setup
Remark The setup is created via a wizard. This wizard allows you to define the main choices. You also have
The framework corresponds to the different libraries required for the the ability to use the setup editor if the options proposed by the wizard are not suitable. We will not
executable to operate. see its use in detail in this lesson. See the online help for more details.
We will now present the different steps for creating the setup program. You can click the "Finish"
button to validate all the steps of the wizard at any time.
The option "Framework DLL beside the executable" allows you to use the necessary libraries
only. These DLLs are copied into the executable directory. ▶ To create the setup program:
The option "Framework included in the executable" allows you to distribute the executable only 1. On the "Project" pane, in the "Generation" group, expand "Setup procedure" and select
(the DLLs being found in the executable). "Create the setup procedure". The wizard for creating the executable and the setup starts.
The option "Common framework" allows you to use the framework common to all the WINDEV 2. The executable was already created: the selected options are stored.
applications installed on the computer. With this option, the framework is installed once only on 3. In the wizard, click on "Additional information" in the "Executable" section.
the computer (it can also be downloaded by Internet) and it is used by all WINDEV applications.
4. The wizard proposes to perform a project backup. Select "No: Don’t make a backup copy of
16. Select "Common framework" and choose "Common WINDEV framework". the project" and go to the next step.
Go to the next step.
5. The wizard proposes to create the page of new features.
17. This step concerns Windows Vista (and later). You have the ability to include a manifest for a
use in Windows Vista (and later).
For our example, check "Don’t include a manifest for Windows Vista and later".
Go to the next step.
18. WINDEV proposes to perform a project backup. This backup is used to keep a project
version whenever the executable is created. In our case, select "No: Don’t make a backup copy
of the project" and validate the wizard.
19. The executable is created. It can be run immediately to check its operating mode. To do so,
click the "Run the executable" button.
That’s it, the executable creation is ended. A lot of options to fill but after a first configuration of
your choices, you will be able to validate all wizard steps from the beginning.
You also have the ability to click the steps specified in the wizard in order to
Remark
reach a wizard screen directly. The default options of other screens will be
automatically validated.
This option is used to create a help file in order to present the new features to the end users.
During a first setup, this file can correspond to the software help.
Select "Create a documentation for the new features" and go to the next step.
290 Part 4: Full application with data Part 4: Full application with data 291
6. You have the ability to define the elements that will be automatically included in the help file. • Validate. The files are automatically positioned in the data directory of application.
Keep the default options and go to the next step.
Remark
If the application already contains a help system, it can be used in order to
include a page for the new features.
7. Validate the message. The executable is automatically created (with the options defined when
creating the executable) as well as the help system. You now have the ability to type specific
information in the help system. In the example, leave the information created by default.
To resume the creation of the setup program, click , which corresponds to "Continue the
creation of the setup procedure".
We will choose the optional tools to install and we will include the uninstaller. The uninstaller will
allow the users to uninstall the application from the Windows program manager. Go to the next
step.
292 Part 4: Full application with data Part 4: Full application with data 293
15. We will select WDOptimizer. This tool is used to optimize the data files of application on a 4. Choose "Custom setup". The wizard asks for the setup directory of application.
regular basis.
16. Click "Medium" on the left of wizard. The setup will be generated in a single directory. By
default, the setup program is created in the "Install" subdirectory of project. You can:
• Specify a password for the setup. In this case, only the user who knows the password will
be able to install the application.
• Sign the setup with a certificate. This option is used to ensure the integrity of setup pack.
17. Validate. The setup program is automatically created.
18. A screen is displayed, allowing you to check the setup or to open the generation directory.
Installing an application
In the window for the end of setup creation, click the "Test" button. If this window was closed, run
the "Install.exe" program found in the directory of setup program. The application setup starts.
▶ We are going to follow the different steps of setup program for the "WD Full Application"
application.
1. If you are using an operating system corresponding to Windows Vista (or later), a window 5. Validate the setup directory of application.
requests the authorization to run the program. Validate this window. 6. Go to the next step and end the application setup.
2. Choose the language of setup program and click "OK". 7. The application setup starts. Validate the different setup steps.
294 Part 4: Full application with data Part 4: Full application with data 295
The different types of deployment
We have performed a simple application deployment. In the wizard for setup creation, WINDEV
also proposes setups with automatic update.
HFSQL Classic
application
computers
(Optional)
Database
WINDEV
Overview
USERS
User
Several setup modes are available for a WINDEV application:
• Stand-alone setup:
This type of setup is used to create a unique setup program. This setup program will be run by
the end user on his computer.
To update the application, you will have to re-create a setup for the application. Then, the end
user will have to install this new program.
This is the type of setup that was just performed.
• Setup with automatic update:
This type of setup is used to automatically detect the updates when starting the application. If
user setup
an update is available, the user can perform this update immediately.
of setup
Request
Run the
This type of setup is available via the network or via the Web. You also have the ability to
The setup request is performed by the User Control Center or the setup path supplied by the network administrator.
During the setup, the network administrator chooses to install (or not) the Control Center of network applications.
perform a multi-site setup. LOCAL NETWORK
We are now going to present the operating mode of a setup with update.
Setup with network update
multi-user (optional)
The creation of the setup program is performed via the wizard for creating the setup program
Control Center
Executable of
("Setup procedure" option in the "Project" pane).
applications
user setup
Reference
The setup program obtained at the end of the wizard includes two setups:
version
reference
SERVER(S)
Server of
The diagram below presents the setup mode of an application that is using a local HFSQL Classic
network administrator
database, with a network update.
ADMINISTRATOR
Computer of
The version of reference application is automatically checked whenever the application is started
by the end user. If this version was modified (if the reference version was updated for example), an
Run the
update is automatically proposed for the final application.
setup
(CD,DVD,USB...)
support
Setup
296 Part 4: Full application with data Part 4: Full application with data 297
Setup with Internet update
The same principle is used by the setup with Internet update.
The creation of the setup program is performed via the wizard for creating the setup program
("Setup procedure" option in the "Project" pane).
WINDEV
USERS
the download
page
database, with an update by Internet.
Remark: This type of setup can also be performed via PCSCloud (if you have an account).
install application
Download and
Download
Multisite setup
page
INTERNET
The multi-site setup combines:
for setup
Request
• a reference network setup deployed on a local network.
• an HTTP setup used to update the reference setup on the local network.
Client/Server server
Manta Manager
Server database
Control Center
HFSQL Client/
Manta server
Executable
Download
Reference
(Optional)
(Optional)
version
of user
HFSQL
SERVER(S)
setup
page
HFSQL
server
HTTP
ADMINISTRATOR
administrator
Computer of
the network
Run the
setup
(CD,DVD,USB...)
Setup media
298 Part 4: Full application with data Part 4: Full application with data 299
Lesson 4.15. Distributing "Reports and Overview of "Reports and Queries"
"Reports & Queries" allows the users to modify and create the reports and queries found in your
Queries" with your applications applications.
The user thinks that some information is missing in the standard report? "Reports and Queries"
allows the user to add this information from the report viewer. This modification may be useful for
the other users? The report can be made available to all users who are using the application in
This lesson will teach you the following concepts network. Same for the queries.
"Reports and Queries" is free and it can be distributed with your applications
Remark
• What is "Reports & Queries" used for? developed with WINDEV. See the license for more details about the distribution
• How to distribute "Reports and Queries". and use conditions.
• How to use "Reports and Queries".
We are going to present these different steps in details by using the "WD Full Application" project.
If you did not perform the operations in the previous lessons, you can follow this
Answer lesson by opening a corrected project: in WINDEV’s home page (Ctrl + <), click
"Tutorial" and select "Full application (Answer)".
300 Part 4: Full application with data Part 4: Full application with data 301
Configuring project ▶ To define an invisible data file in "Reports and Queries":
1. In the data model editor, select the requested data file.
▶ To use "Reports and Queries" from your application, you must configure the project associated
with your application. 2. Display the description window of the data file ("Description of data file" in the popup menu)
1. Open (if necessary) the "WD Full Application" example: in WINDEV’s home page (Ctrl + <), 3. In the "Reports and Queries" tab, uncheck "Visible by the end user in "Reports and Queries"".
click "Tutorial" and select "Full Application (Answer)". The project is loaded. 4. Validate.
▶ To define in invisible item in "Reports and Queries":
If no report was created in the "WD Full Application" project, open the corrected
Remark
application project: in WINDEV’s home page (Ctrl + <), click "Tutorial" and 1. In the data model editor, select the requested data file.
select "Full application (Answer)". 2. Display the file description window ("Description of items" in the popup menu).
3. Select the requested item in the table.
2. Display the project description. 4. In the "Reports and Queries" tab, uncheck "Visible by the end user in "Reports and Queries"".
Reminder: To display the project description, go to the "Project" pane, "Project" group, and click 5. Validate.
on "Description".
▶ To take into account the modifications performed in the analysis, you must regenerate the
3. In the "Advanced" tab, check "Allow to start "Reports and Queries"". analysis (on the "Analysis" pane, in the "Analysis" group, click on "Generation"). An automatic
modification of data files is proposed to take the modifications into account.
Configuring reports
When creating a report, you have the ability to specify whether this report can be modified in
"Reports and Queries".
▶ To allow the "RPT_QRY_FindOrders_table" report (found in the "WD Full Application" project) to
be modified in "Reports & Queries":
1. Open the "RPT_QRY_FindOrders_table" report in the report editor.
2. Display the report description ("Report description" from the popup menu).
3. In the "Options" tab, check "Report modifiable in Reports and Queries".
4. Next, check one of the following options:
• "Modifiable interface" for the report interface to be modifiable in Reports and Queries.
• "All modifiable (interface and code)" for the entire report to be modifiable in Reports and
Queries.
4. Validate.
Configuring analysis
We are going to open the analysis in order to configure the files and items that can be used in
"Reports and Queries".
▶ Open the analysis of your project: click among the quick access buttons of WINDEV menu.
By default, all data files and all items are visible and usable in "Reports & Queries". If your
application contains sensitive information (passwords, ...), these data files or these items can be
made invisible in "Reports and Queries".
"Reports & Queries" does not allow the user to add, modify or delete records
Remark
(HAdd, HModify and HDelete are not allowed). It is also not possible to create or
re-create data files (HCreation and HCreationIfNotFound are not allowed).
302 Part 4: Full application with data Part 4: Full application with data 303
3. The wizard for setup creation starts.
4. Choose an "Individual setup". Go to the next step.
5. Choose a "Standard setup". Go to the next step.
6. Validate the proposed setup directory and go to the next step.
7. In the screen named "Files installed", select (if necessary) the data files (.fic, .mmo and .ndx)
found in the executable directory. To do so, click "Add" and select these files.
If the wizard proposes to create the help file, validate the different messages.
304 Part 4: Full application with data Part 4: Full application with data 305
3. The setup wizard starts. Two setup modes are available:
• Quick setup: The setup is performed with the parameters specified by the application
provider.
• Custom setup: The wizard asks the user to define the parameters of application setup.
4. Choose "Custom setup". The wizard asks for the setup directory of application.
5. Validate the setup directory of application.
6. The screen named "Reports and Queries" is used to install "Reports and Queries" (only if this
program is not already installed on the current computer).
• Specify (if necessary) the directories corresponding to the reports and queries modified or
created by the end user:
• The directory of custom reports and queries corresponds to the directory of reports and
queries visible by the user who created them.
• The directory of shared reports and queries corresponds to the directory of reports and
queries visible by all application users.
These directories can be modified when installing the application: all you have to do is
check "Allow these directories to be modified during the setup".
12. Click "Medium" on the left of wizard. This step allows you to select the setup media, the
directory for creating the setup program if necessary, and also to protect the setup with a
password. Remark: If an earlier version of "Reports and Queries" is installed on the computer, it is possible
to make a backup copy of that version.
13. Keep the default options and validate the wizard. The setup program is generated. Don’t
close the window indicating the end of setup creation. 7. Go to the next step.
8. The next screen allows you to define the directories that will be used to save the reports and
queries (if the option "Allow these directories to be modified during the setup" was checked in
Installing and using "Reports and Queries" the wizard for creating the setup program).
306 Part 4: Full application with data Part 4: Full application with data 307
Application test
We are now going to take the place of the application user (not easy, but worth a try).
▶ To run the application test:
1. Start the "WD Full Application" application.
2. Select "Reports .. List of customers". The report is displayed in the report viewer. Click the
"Preview" pane.
308 Part 4: Full application with data Part 4: Full application with data 309
Conclusion
Lesson 4.16. Managing multiple
The development step of our application is ended. The following lessons will allow you to discover:
• how to transform your application into a multilingual application, languages
• how to include your application in the Source Code Manager (SCM).
Estimated time: 20 mn
310 Part 4: Full application with data Part 4: Full application with data 311
What is a multilingual application?
A multilingual application is an application that can be run in different languages (English, French,
German or any other language).
Therefore, the same application can be used in several languages. But how is it possible? That’s
what we will see in this lesson.
We are going to handle a project that can be run in English or in French, according to the user’s
choice.
If you did not perform the operations in the previous lessons, you can follow this
Answer
lesson by opening a corrected project: in WINDEV’s home page (Ctrl + <), click
"Tutorial" and select "Full application (Answer)".
4. Click "French". A checkmark is displayed on the right of language.
5. Validate. The "French" language appears in the list of project languages.
Choosing the project languages ▶ The "Languages" tab can also be used to configure the linguistic options regarding the
numbers, the currencies, the dates, ... for the selected language. Let’s see an example:
▶ The first operation consists in choosing the project languages.
1. Click the "French" language.
1. Display the project description: on the "Project" pane, in the "Project" group, click
"Description". 2. Select the "Date" tab.
2. Click the "Languages" tab. Our application will support English and French. 3. The linguistic options of Windows are used by default. Select "Use the following parameters":
you now have the ability to define the date format as well as the translation used for the days
3. Click the "Add" button. The window for selecting languages is displayed. and months.
4. Keep the option "Use the parameters defined in the linguistic options of the operating
system".
312 Part 4: Full application with data Part 4: Full application with data 313
In the linguistic options, you have the ability to choose the text direction for
Remark
Remark
To take into account all languages of the project linked to the current analysis,
the language ("Various" tab, "Text direction" option). This allows you to create
you also have the ability to click the "Synchronize with the project" button.
interfaces with a language written from right to left.
▶ Validate. A message proposes to synchronize the different project elements. Answer "Yes". ▶ To type shared information in several languages, let’s take a simple case: entering the caption
All project elements opened in the editor (windows, reports, ...) are closed and the additional of the control linked to the "Address" item of "Customer" data file:
languages are added to these elements. 1. Select the Customer data file.
Remark: The captions that exist in the base project language are automatically copied into the 2. Display the description of items of a data file ("Description of items" in the data file popup
added languages. menu).
3. Select the "Address" item and display the parameters of control linked to the selected item
Localizing the analysis (shared information). To do so, click the link at the bottom of the screen. The shared information
is displayed in a new window.
By default, an analysis is created in a specific language and it cannot be translated. 4. In the "Caption" area, type the caption for the French language: "Adresse".
However, some information can be typed in several languages (notes in the documentation,
shared information, ...).
If your application uses Reports and Queries, the names of the data files and items can also be
translated. This translation can be done in the "Reports and Queries" tab (this tab is both in the
data file and the item description window).
By default, the controls created from the analysis items have the item caption specified in the
analysis. If a caption was specified in the shared information of item, this caption will be used
when creating the control.
When changing the language of project linked to the analysis, this change is not automatically
applied to the analysis. Indeed, an analysis can be shared between several projects.
▶ To support several languages in an analysis:
1. Display the data model editor: click among the quick access buttons of WINDEV menu.
2. In the analysis description ("Analysis description" from the popup menu), select the
"International" tab.
3. The list of languages supported by the analysis is displayed. The French language not being
supported:
• Click the "Add" button.
• Select "French".
5. Validate the window for typing shared information.
• Validate the window for adding languages.
6. Validate the description window of items.
Remark
• at any time via the editor.
• at any time via WDMSG and WDTRAD, tools used to extract, translate
and reintegrate the different elements.
▶ To take into account the modifications performed in the analysis, you must generate the
analysis: on the "Analysis" pane of the ribbon, in the "Analysis" group, click "Generation".
4. Validate the description window of analysis.
314 Part 4: Full application with data Part 4: Full application with data 315
Localizing the project elements Localizing an image
All project elements can become multilingual elements: windows, reports, help, ... ▶ To change the image of the bar used in the WIN_Menu window according to the runtime
language:
We are going to modify some elements of WIN_Menu window to present the different methods
that can be used. 1. Open the "WIN_Menu.WDW" window.
We are going to modify: 2. The bar image is found in the template associated with the window. Therefore, the associated
window template must be opened:
• the image of the bar used in the WIN_Menu window.
• Click the "WD FullApplication" control and display the popup menu.
• the captions of controls found in the WIN_Menu window.
• Select "Open the template".
• the menu options.
• the message displayed by the WLanguage code when closing the application.
▶ Open the "WIN_Menu" window in the editor (double-click its name in the "Project explorer" pane
for example).
▶ First of all, check whether the WIN_Menu window is associated with the different languages
defined in the project:
1. Display the window description ("Description" from the popup menu of window).
2. Select the "Language" tab: the two languages selected in the project are displayed. • The window template appears, enclosed in an orange border.
3. Display the description window of the bar:
• Select the "WD FullApplication" control and display the popup menu.
• Select "Description".
4. In the "Image" area, click the button.
316 Part 4: Full application with data Part 4: Full application with data 317
Localizing controls 3. The following window is displayed:
A control can display various information to the user:
• a caption,
• a help message,
• an image, ...
This information must be translated. This information is accessible in the different tabs of the
description window of control.
▶ For our example, we are going to translate the first pane of Tab control.
1. Double-click the Tab control to display its description window. 4. This window allows you to translate all messages of your program into all project languages.
2. In the "General" tab of description window, select the first tab "List of products". 5. In the "French" area, type "Quitter l’application?" and validate.
3. In the "Description of static pane" section, you can: 6. The icon as well as a digit appear in the code editor.
• type the translation for the pane caption: "Liste des produits".
• define a specific image for the tab pane according to the language (as already done
before).
• define a tooltip for each language.
4. Close the description window of control.
Localizing a programming message These icons indicate that the multilingual message exists in 2 languages.
All messages found in your program can be translated into several languages. In our example, 7. Close the code editor.
selecting the "Exit" menu displays the message "Exit from the application". We are going to Localizing menus
translate this message.
The menu options can be translated like the other controls via the description window of the
▶ To translate the message of menu option: option, or from the window editor directly.
1. Display the code of menu option:
• Expand the menu in the editor. ▶ To translate the menu of "WIN_Menu" window:
• Select the "Exit" option. 1. On the "Display" pane, in the "Options" group, expand "Language displayed" and select the
language that will be viewed in the editor (French in our case).
• Select "Code" from the popup menu (right mouse click).
2. The menu options are displayed in the selected language. If no translation corresponds to the
selected language, the menu options are displayed in English.
3. Expand the "Menu" option.
4. Select "Send an email".
5. Press the Space key on the keyboard: the caption becomes editable.
6. Type the caption in French: "Envoyer un email" and validate.
2. To translate this type of message, position the cursor in the "Exit from application?" string 7. Switch the displayed language back to English: on the "Display" pane, in the "Options" group,
and press Ctrl + T. On the "Code" pane, in the "Languages" group, you can also expand expand "Language displayed" and select "English".
"Translate strings" and select "Translate messages".
318 Part 4: Full application with data Part 4: Full application with data 319
The translation tools Translation with WDMSG and WDTRAD
Some application elements have been translated manually. A tool named WDMSG (not supplied with WINDEV) can be used to:
Several methods can be used to translate this information: • check out all project messages (caption of controls, code message, title of windows, ...) in order
to translate them,
• a direct translation of messages performed in the different editors. This translation can be
performed via a translation tool, Google Translate (providing that you own a license), ... • check the translated messages back in.
• a translation performed via an external tool (WDMSG and WDTRAD). The messages to translate are checked out:
• in a text format that can be configured to be used by most translation tools
Direct input of translations • in HFSQL format.
The translations are typed in the product interface directly. For example, the caption of "New" WDMSG is also supplied with WDTRAD, a computer-assisted translation tool. WDTRAD is used to
button becomes "Nouveau" in French. All you have to do is open the description window of control easily type all translations for the multilingual information of a project.
and type the corresponding translation in the requested language.
If you want to use a translation software or a translation site, WINDEV can be configured to use Contact PC SOFT Sales Department for more details about WDMSG and WDTRAD.
this software:
Other elements to translate: the framework messages
1. On the "Home" pane, in the "Environment" group, expand "Options" and select "General
options of WINDEV". Various information and messages are found in the WINDEV framework. For example, the
2. Display the "Translation" tab. names of days and months used by the functions for date management come from the WINDEV
framework. To translate one or more libraries of this framework, you must use WDINT (not supplied
with WINDEV).
This program is used to get a file whose extension is WDM. To use this file in your application:
• you have the ability to use LoadError.
• you have the ability to include the file to the project description in the "Languages" tab. All you
have to do is select the requested language and select the "Various" tab.
3. Specify:
• Whether the regional settings must be automatically enabled according to the language used
for the input. In this case, if the language requires a specific character set, this character set
will be automatically selected.
• The software or the site that will be used for translation. You have the ability to use WDDixio,
translation dictionary supplied with WDMSG (see next paragraph), a specific translation
software or site, or Google Translate.
See the online help for more details.
• The supported languages.
4. When the translation parameters are defined, you have the ability to click the button
found in the different description windows of project elements: this button allows you to use the
software defined for translation.
320 Part 4: Full application with data Part 4: Full application with data 321
Programming the change of language Project test
By default, the project is run in the runtime language defined for the project, in the "Languages" Some application elements being translated, we are now going to check the change of language.
tab of project description ("Description" in the "Project" pane). ▶ To run the application test:
In an application, the language can be chosen via a menu option. You can change the language of 1. Run the project test ( among the quick access buttons). The window is displayed in test
the application being run using Nation in the event associated with the menu option. mode in English.
Adding a menu option 2. Select "Menu .. Languages .. French".
3. The elements that have been translated are displayed in French:
▶ To add a menu option:
1. Open the "WIN_Menu" window in the editor if necessary (double-click its name in the "Project
explorer" pane).
2. Click the "Menu" option of window. The menu is expanded.
3. Select "Send an email".
4. Display the popup menu (right click). Select "Add after". Type the caption ("Languages") and
validate.
5. Select the "Languages"’ option you have just created.
6. Display the popup menu (right mouse click) and select "Transform to expand a sub-menu".
7. Type the caption of first sub-option: "English".
8. Press the Enter key twice and type the caption of second option ("French").
We are now going to type the WLanguage code required to change language.
Programming
To type the code for managing languages:
1. Select "Menu .. Languages .. French" in the editor.
2. Display the popup menu (right click). Select "Code".
3. Write the following code:
Nation(nationFrench)
4. Select "Menu .. Languages .. English" in the editor. 4. End the test and go back to the editor.
5. Display the popup menu (right click). Select "Code".
6. Write the following code:
Nation(nationEnglish)
Nation is used to change the runtime language of application. The constants passed in parameter
allow you to specify the language to use.
The change of language performed by Nation is immediately effective.
322 Part 4: Full application with data Part 4: Full application with data 323
Lesson 4.17. SCM Introduction
The development of a large IS system requires the participation of several developers. These
developers must work on a single WINDEV project while sharing the different resources (windows,
classes...).
This lesson will teach you the following concepts WINDEV is supplied with a Source Code Manager named "SCM" used to share the source codes of
different projects between developers and to find out the full history of modifications performed
(in the code, in the interface, ...).
• Overview.
• The Source Code Manager. SCM (Source Code Manager)
• Using the Source Code Manager.
Principle of SCM
The Source Code Manager is used to store and share the projects and their elements.
The principle is as follows:
Estimated time: 30 mn • A reference version of each one of your projects is found on a server. This set of versions is
called "Repository".
• Each developer has a local copy of different projects on his computer.
• Whenever a developer wants to modify a project element (window, report, query, ...), he informs
the SCM that he is becoming the temporary owner of this element. To do so, the developer will
check out the element from the repository.
• This developer gets exclusive rights on this element: all requested modifications can be
performed on this element.
• The other developers are still working on the copy of the reference version of this element
(found in the repository).
• Once the developer has finished, the checked-out element is checked back into the repository.
324 Part 4: Full application with data Part 4: Full application with data 325
• The other developers are automatically notified of this check-in operation. They can now update ▶ Our repository will be created when a project is imported into the SCM (next step).
their local copy.
We advise you to make backup copies of the repository on a regular basis. To do
Remark
so, you must:
• connect as administrator to the management tool of SCM.
• on the "Management" pane, in the "Backups" group, select "Full backup".
If you did not perform the operations in the previous lessons, you can follow this
Answer
lesson by opening a corrected project: in WINDEV’s home page (Ctrl + <), click
"Tutorial" and select "Full application (Answer)"
▶ We are now going to include the "WD Full Application.WDP" project in the repository:
1. On the "SCM" pane, in the "Add project" group, click "Add project to SCM". The wizard for
adding projects into the SCM starts:
The SCM supports teamwork and it allows you to find out the history of all modifications. The SCM
can also be used to manage and control the elements shared between several projects.
Creating the repository
To share a project via the Source Code Manager, a repository must be created. This repository
must be created once only on a server.
326 Part 4: Full application with data Part 4: Full application with data 327
2. Click"Create a repository...". 9. The wizard asks you to select the project elements that will be added into the repository.
3. The repository creation window appears.
If the repository is in HFSQL Client/Server format, it can be used remotely. 11. Validate the project integration in the SCM. The project and its elements have now been
added into our repository.
A help window about the SCM toolbar is displayed. Read and validate this window.
4. Select "Create a repository in network share mode " and specify the directory of this Sharing project elements
repository ("C:\My Projects\Local repository" for example).
When the projects that share the same resources (same analysis, same
Remark
5. Validate the creation of the repository ("Create repository"). windows, etc.) are included in the SCM, the relevant elements can be shared
6. The repository has now been created. We are going to include our project in this repository. between the different projects. Therefore, the same element is checked in
7. Go to the next step. once only into the SCM and the modifications are automatically applied to the
8. The wizard proposes to locate the project in the "WINDEV projects" subdirectory of the other projects.
repository.
In a real case, in order for other developers to work on a project found in the Source Code
Manager, they must get a copy of this project locally.
To do so, the following operations must be performed:
1. Open the project from the Source Code Manager: on the "Home" pane, in the "General" group,
expand "Open" and select "Open a project from the SCM".
Accept this location. Go to the next step.
328 Part 4: Full application with data Part 4: Full application with data 329
2. Specify the location parameters of the repository and validate (this step is required only if the Configuring SCM
current project in the editor does not belong to the SCM):
Before you start working on the elements of project found in the SCM, you must configure the
mode for checking out the project elements.
When working on the elements of a project in the SCM, the element must be checked out from the
repository before it can be modified, then it must be checked back in once the changes have been
made. Therefore, the modified element becomes available to all SCM users.
WINDEV proposes two modes for checking out the project elements:
• the standard mode: if you display a SCM element that is not checked out, a panel indicates
that the element must be checked out before it can be modified. The element can be checked
out immediately (check-out button found in the dialog box).
• the automatic mode: if you try to modify a SCM element that is not checked out, the SCM
3. In the screen that is displayed, specify (if necessary) the connection and the local directory: automatically proposes to check out this element. Once the check-out is validated, the element
can be modified.
Remark: this mode is not recommended when using SCM with a slow Internet connection.
of a project not managed by SCM: all you have to do is open the project (".WDP"
file) corresponding to the local copy.
330 Part 4: Full application with data Part 4: Full application with data 331
▶ Several SCM windows appear: ▶ To modify the "WIN_Product_form" window:
1. First of all, the window for automatic project check-out is displayed. Indeed, we want to 1. Select the "WIN_Product_form" window in the project explorer and double-click the element
modify a project characteristic therefore the project must be checked out. to open it in the window editor.
2. "Check in the project automatically at the end of the operation" allows you to automatically 2. The automatic check-out is enabled during the first modification: all you have to do is move a
check in the project once all the changes have been made. Keep this option. control to check the element out. You also have the ability to click the "Check out" icon found in
3. Validate this window. the ribbon ( ).
4. Different check-in and check-out windows open allowing you to add the internal component 3. The check-out window is displayed:
"WDFAA.wci" and its elements to the project in the repository and extract them to the local
project. This component contains the different system windows to customize. Validate these
different windows.
5. The project description window is closed and the project is automatically checked back into
the repository.
Modifying a project window
We are now going to modify the "WIN_Product_form" window: a click on the image must allow to
modify the image (like the "Modify" button).
The method for modifying a checked-out element (UI, code, ...) is the same as the method for
modifying an element in a project not managed by SCM.
However, the modifications performed on a checked-out element are not visible to the other
developers.
If another developer runs the checked-out element, the element that is currently found in the
repository will be used.
This allows you to make an application evolve while keeping a stable version in the repository.
332 Part 4: Full application with data Part 4: Full application with data 333
4. The SCM proposes three check-out modes: Checking the checked-out element back in
• Exclusive (recommended mode): nobody can check out this element until it is checked
Now that the modifications have been made and tested, we are going to check the window back
back in. The element can be checked out for test only.
into the repository. Then, your modifications will be made accessible to the other developers.
• For test: the element can be modified but the modifications will not be checked back in.
• Multiple: the element can also be checked out by other users. In this case, the differences ▶ On the "SCM" pane, in the "Current element" group, click the "Check in" button. The following
between the different element versions can be viewed when the element is checked back window is displayed:
in. This mode is reserved to specific cases and to experienced developers.
5. The window will be checked out in exclusive mode. Keep the "Exclusive" option checked.
6. Type a comment ("Image modification" for example). This comment will be useful for the other
developers.
7. Validate the check-out. The window is checked out.
8. Display the description window of Image control ("Description" from the popup menu).
9. In the "UI" tab, modify the cursor used: select the "System hand" cursor.
10. Validate the control description window.
11. Display the code of Image control: select the Image control and press F2 for example.
12. Write the following code in the event "Click...":
// Runs the click code of button that modifies the image
ExecuteProcess(BTN_Modify, trtClick)
Remark
3. In the form that is displayed, click the product image: the file picker is opened to modify the You have the ability to compare an element to one of its earlier versions.
product image. This is the expected operating mode. This allows you to compare the code in order to retrieve a code section that
4. Close the test window. was "lost" or accidentally deleted by another developer.
If you are using the Control Centers, the current task can be ended when
Remark
the element is checked back into the Source Code Manager. This feature is
useful to follow the monitoring of tasks, the corrections of bugs, ...
334 Part 4: Full application with data Part 4: Full application with data 335
Synchronizing the project In offline mode, there are two solutions to check out elements:
• No element is checked out from the SCM. The other developers will be able to work on the
Several options can be used to configure a project handled by SCM. These options are grouped in
same elements as you while you are working in offline mode. When you reconnect to the
the "SCM" tab of project description (to display it, click "Description" on the "Project" pane).
SCM, the modifications made by yourself to the element will have to be merged with the
modifications made by the other developers.
• The elements that you want to modify are checked out in exclusive mode. No one else can use
the element while you are working in offline mode.
SCM administrator
The SCM administrator is used to directly handle the different projects included in the source code
manager.
It allows you to:
• manage the repositories (creation, connection to a repository).
• manage the files and directories found in a project of repository (add, delete, rename, ... files
and directories).
These options are as follows: • manage the different files of the repository (check-in, check-out, share, etc).
• Propose to get the latest version of the elements when the project is opened. • start some tools (options, maintenance, etc).
When opening a project found in the SCM, this option proposes to get the latest version of the • show the history of an element.
project elements. • show the status of elements.
• Propose to check in the elements when the project is closed. • perform backups.
When the project is closed, this option is used to display the list of elements that are currently
checked out in order for some of them (or all of them) to be checked back in. • grant rights to the different SCM users.
By default, the checked-out elements are not checked back in when the project is closed. • list the projects in which you are taking part in order to dissociate from them (if necessary).
• Check out/Check in the project automatically. ▶ Start the SCM administrator: on the "SCM" pane, in the "Repository" group, click "Manage". All
This option allows you to automatically check out or check in the project when using an project elements are listed in the administrator.
element.
This option is selected by default.
Offline mode
The SCM allows you to work in offline mode. This mode allows a developer (who is using a laptop,
for example) to continue working on a project found in the repository while being disconnected.
336 Part 4: Full application with data Part 4: Full application with data 337
Disconnecting from SCM
PART 5
In the rest of this tutorial, we will be using the "WD Full Application" application. To simplify the
operations, we advise you to disconnect from SCM:
1. Display the description window of project: On the "Project" pane, in the "Project" group, click
"Description".
2. In the "SCM" tab, select "No developer groupware and no SCM".
3. Validate the description window of project.
Conclusion
We have presented the main steps for developing an application.
WINDEV proposes several tools to optimize your applications. See "Project audits" for more details.
Managing a
HFSQL Client/
Server database
• Principle of Client/Server.
• Why switch an application to HFSQL Client/Server?
Estimated time: 5 mn
340 Part 5: Managing a HFSQL Client/Server database Part 5: Managing a HFSQL Client/Server database 341
Overview Why switch an application to HFSQL Client/Server mode?
WINDEV allows you to create applications accessing HFSQL Client/Server databases. The main benefits of an application in HFSQL Client/Server mode compared to an application in
A database in Client/Server mode allows you to host the databases on a server. HFSQL Classic mode are as follows:
This operating mode: • The use of HFSQL Client/Server is more secure (use of a login and password and definition of
• increases the security of data, rights granted to the users).
• allows you to easily manage the multi-user mode, • No management of directories: all the database files are grouped at the same location.
• simplifies the maintenance, • The end users do not see the data files in the explorer and they cannot access them directly.
• ... • The databases in Client/Server mode can be used via an Internet connection.
• Management of native multi-user mode: the performances are optimized in multi-user mode.
Client computer 1
WinDev application
Manta server
WinDev application
HFSQL
Client computer n Client/Server
databases
WinDev application
342 Part 5: Managing a HFSQL Client/Server database Part 5: Managing a HFSQL Client/Server database 343
Lesson 5.2. Implementing a Client/ Overview
Server database
In this lesson, we are going to perform all operations required to develop and to deploy an
application that is using a HFSQL Client/Server database.
Remark
Don’t forget to open this port on the firewall in order to connect to the HFSQL
server from another computer.
8. Specify the name and password of the user with management that will be created by default
on the HFSQL server. By default, this user is "Admin" and has no password.
Remark
For security reasons, don’t forget to change the administrator password.
9. Install the HFSQL Control Center if it is not already present or accessible from your computer.
Caution!
The HFSQL Control Center is required to manage the HFSQL Client/Server
database.
10. The wizard proposes to configure the sending of notifications in order to identify the server
dysfunctions in real time. In our example, go to the next step and indicate that the setting will be
performed "Later".
344 Part 5: Managing a HFSQL Client/Server database Part 5: Managing a HFSQL Client/Server database 345
11. The wizard proposes to enable the authentication via Active Directory. Enable this option if Adapting the example
necessary.
12. Validate (or not) the participation in product improvement by allowing us to collect
information regarding the use of product. This optional and anonymous collect allows PC SOFT to If you did not perform the operations in the previous lessons, you can follow this
Answer
improve the product features. lesson by opening a corrected project: in WINDEV’s home page (Ctrl + <), click
13. The setup is performed. By default (if you have not changed the administrator settings), to "Tutorial" and select "Full application (Answer)".
connect to the server in administrator mode, you must use the "Admin" user without a password.
▶ To adapt the project:
Creating an application that is using a HFSQL Client/Server 1. Open the "WD Full Application" project if necessary.
database 2. If necessary, go to the "Project explorer" pane and select the "Windows 32-bit executable"
project configuration.
Creating a WINDEV application that is using a HFSQL Client/Server database is child’s play. You 3. Load the analysis of your project in the data model editor: click among the quick access
must: buttons. The data model editor is displayed.
1. Create the project by asking to create a new database. 4. On the "Analysis" pane of the ribbon, in the "Connection" group, click "New connection". A
2. Create the analysis by specifying that the databases used by the project will be "HFSQL Client/ wizard is opened, allowing you to create a connection.
Server" databases. 5. Select the type of connection to create: "HFSQL Client/Server".
3. Specify the characteristics of the connection to the HFSQL Client/Server server that will be
used.
4. When creating a data file in the analysis, indicate that this data file is in Client/Server mode
and specify the connection used.
Remark
You can also describe the connection to the HFSQL server by programming. See
the online help for more details: HDescribeConnection.
Overview
Switching a database from HFSQL Classic mode to Client/Server mode is the most common
operation.
WINDEV proposes several methods to perform this switch:
• perform this adaptation in the data model editor.
• perform this adaptation from the HFSQL Control Center.
To better understand the different steps, we are going to switch the application that was created
in Part 3 to Client/Server mode by using the first method, the data model editor. • the server name (name of your computer for example) and the port number. Go to the next
step.
• the user name and password (leave this information empty to use the administrator). Go to
the next step.
• the database name ("WD Full Application" in our example). Go to the next step.
8. Type the connection name (keep the proposed name).
346 Part 5: Managing a HFSQL Client/Server database Part 5: Managing a HFSQL Client/Server database 347
9. Go to the next step and validate. The connection to the database is automatically created. 15. The data files in the analysis are automatically changed into HFSQL Client/Server data files
The wizard proposes to associate the different data files found in the analysis with the and associated with the selected connection.
connection that was just created.
10. Click "Yes".
11. In the next step, select all the data files proposed:
16. Generate the analysis: on the "Analysis" pane of the ribbon, in the "Analysis" group, click
Go to the next step. "Generation". An automatic modification of data files is automatically proposed. If all the data
12. Then, the wizard proposes to copy the data files onto the server. Validate ("Copy now"). files are up to date, the automatic modification of data files can be canceled.
Remark
• Depending on the parameters specified when creating the
connection, the connection defined in the analysis can be modified by
HOpenConnection and HChangeConnection.
• HOpenConnection is used to go back to HFSQL Classic mode: all you
have to do is specify the path of directory containing the HFSQL Classic
13. Select the analysis files that will be copied onto the server: in our case, all data files found
data files.
in the EXE directory.
17. The development project was successfully adapted. You may also have to adapt the
deployed application (if the deployed application is using HFSQL Classic data files for example).
This operation is configured when creating the setup program of the application.
348 Part 5: Managing a HFSQL Client/Server database Part 5: Managing a HFSQL Client/Server database 349
Features available in HFSQL Client/Server mode
Lesson 5.3. Managing a Client/Server
HFSQL Client/Server proposes several features:
• Transactions, database
• Logs,
• Stored procedures,
• Triggers,
• Hot automatic data modification,
This lesson will teach you the following concepts
• Hot reindexing,
• Scheduled backups, • The HFSQL Control Center.
• Incremential backups, • Creating a user in the HFSQL Control Center.
• Universal replication. • Saving the database.
These features will not be described here (some of them have been presented in this tutorial in
HFSQL Classic mode).
See the online help for more details.
Estimated time: 20 mn
350 Part 5: Managing a HFSQL Client/Server database Part 5: Managing a HFSQL Client/Server database 351
Overview 4. Click the vertical tab named "HFSQL C/S" if necessary. The list of data files in HFSQL Client/
Server format is displayed.
Now that we know how to create and/or adapt an application so that it operates in HFSQL Client/
Server, let’s see how to manage the associated database.
Indeed, a Client/Server database requires:
• a specific configuration of computers (setup of a HFSQL server, ...).
• a management performed via the HFSQL Control Center.
• The "Description" tab gives information about the data files (data file items, etc.).
3. Validate the screen. The HFSQL Control Center is displayed. This mode allows you to see the • The "Content" tab displays the records found in the data files.
different files linked to the analysis of the current project. The entire HFSQL Client/Server database can be managed from the HFSQL Control Center.
352 Part 5: Managing a HFSQL Client/Server database Part 5: Managing a HFSQL Client/Server database 353
Creating a user account in the HFSQL Control Center
A single user account is created when installing a HFSQL server and when creating a database:
the administrator account ("Admin" login without password).
Using a user account allows you to secure the access to data. Indeed, all application users are not
administrators. Specific rights can be granted to each user (or group of users).
The user rights specified in the HFSQL Control Center are granted for the
Caution!
Some users may not have the rights to write into some data files for example.
To run a simple test, we are going to create a user and allow this user to see the records in the
Customer data file.
▶ To directly connect to the database found on the server: 5. In the right section of the screen, select the "Users" tab. This tab is used to manage the
1. Expand the menu found at the top left of HFSQL Control Center and select "Connect to server users.
a HFSQL server". 6. Only the "Admin" user exists at this time.
2. The home window of HFSQL Control Center is displayed.
3. The option "Connect to a HFSQL server" is selected by default. Specify the characteristics of 7. To create a new user, in the ribbon, in the "Users" group, click the "New" button. The window
the server that was installed in the previous lesson and validate. used to define the user characteristics is displayed.
4. The characteristics of HFSQL server are displayed:
• the name of HFSQL server as well as the list of databases found on this server are
displayed in the left panel.
• in the right section of the screen, a new tab allows you to see the characteristics of HFSQL
server.
354 Part 5: Managing a HFSQL Client/Server database Part 5: Managing a HFSQL Client/Server database 355
8. Type the following information: ▶ To grant rights to connect to the database:
1. In the HFSQL Control Center, double-click the "WD Full Application" database.
2. On the "WD Full Application" pane, in the "Rights" group, click "Management of rights".
3. Select the "Test" user in the list of users.
4. In the list of rights, for the action named "Rights to connect to the server (encrypted and
unencrypted connection)", click in the "Defined rights" column and select the green checkmark.
files.
• Account enabled: If this option is not checked, the user exists but he is
not enabled (users on holiday for example).
• Password expiration: You can specify a password valid for a limited
number of days. (configurable).
9. Validate the user creation. By default, no rights are granted to this user.
We are now going to grant rights to the user: the "Test" user can connect to the database and read
the Customer data file.
356 Part 5: Managing a HFSQL Client/Server database Part 5: Managing a HFSQL Client/Server database 357
▶ To grant rights to read the Customer data file: Saving the database
1. In the HFSQL Control Center, expand the "WD Full Application" database and double-click the
Customer data file (on the left of the screen). To make a backup copy of the database:
2. On the "Customer" pane, in the "Rights" group, click "Management of rights". 1. Go to the tab corresponding to the "WD Full Application" database.
3. Select the "Test" user in the list of users. 2. Select the vertical tab named "Backups".
4. In the list of rights, for the action named "Rights to read the records of a file", click the 3. In the menu, in the "Backups" group, expand "New backup" and select "New hot backup".
"Defined rights" column and select the green checkmark. Remark: This button is accessible in the "Backups" group:
• on the tab corresponding to the HFSQL server,
• on the tab corresponding to the database.
Note: The wizard can also be used to save a selection of data files.
4. Validate the backup.
Conclusion
The HFSQL Control Center is a tool for managing databases, allowing you to:
5. Click "Apply" at the bottom of window. The rights become effective. • stop or restart a server if a problem occurs,
6. Close the window for managing rights. • manage the users and their rights,
• reindex the data files if necessary,
Similarly, rights can be defined: • perform database backups.
• on the HFSQL server
• on the database The HFSQL Control Center is a redistributable tool that can be installed on the computers of
users who are working with HFSQL Client/Server databases. The HFSQL Control Center must be
• on the database files. used by the database administrator.
In our example, the "Test" user can only browse the records in the Customer data file. If this user
tries to perform another action, a message will be displayed: "The Test user has no sufficient
rights to XXXX" (where XXXX corresponds to the action performed).
Once the account is created, it can be used when the application connects to the server (when
HOpenConnection is used).
The users and their rights can also be managed by programming with the
Remark
WLanguage functions.
See the online help for more details.
358 Part 5: Managing a HFSQL Client/Server database Part 5: Managing a HFSQL Client/Server database 359
Lesson 5.4. Setup on end-user Overview
Installing a Client/Server application requires several specific options. These options are taken
computers into account by the wizard for setup creation of WINDEV.
We are going to create the setup procedure of our "WD Full Application" application.
If these options are checked, the next steps are used to configure the elements that will be taken
into account for the setup on end-user computers.
See the online help for more details.
360 Part 5: Managing a HFSQL Client/Server database Part 5: Managing a HFSQL Client/Server database 361
PART 6
Optimizing and
debuging a
project
Estimated time: 5 mn
364 Part 6: Optimizing and debuging a project Part 6: Optimizing and debuging a project 365
Overview
Lesson 6.2. Project audits
Your application is created. It operates properly, several automatic tests have been created to
avoid the regressions. You want to deploy it on the end-user computers.
Why not use the WINDEV tools to optimize your application? WINDEV proposes several tools and
features allowing you to optimize your application and to avoid predictable bugs. This lesson will teach you the following concepts
This part presents these tools and their use.
• What is an audit and what is its purpose?
A project to optimize was prepared, allowing you to handle these features!
• Starting and studying the static audit.
Opening project • Starting and studying the dynamic audit.
▶ Start WINDEV 25 (if not already done).
▶ Display the WINDEV home page if necessary (Ctrl + <).
▶ Open the "WD Optimization" project.
To do so, in the home page, click "Tutorial" and select "Optimize a project". Estimated time: 15 mn
366 Part 6: Optimizing and debuging a project Part 6: Optimizing and debuging a project 367
What is an audit? 2. The wizard starts. We are going to define the target of static audit.
We are going to check these audits on the "WD Optimization" project. 3. Select "Run the static audit on the entire project".
4. Validate the wizard.
Static audit 5. The audit report is displayed:
The static audit is an environment feature used to study the source codes of a project in order to
detect different problems and to propose improvements.
▶ To start the static audit on the "WD Optimization" project:
1. On the "Project" pane, in the "Audit and performance" group, expand "Edition audit" and
select "Trigger the edition audit".
The static audit of project can also be started from the project dashboard, via
the "Static audit and Compilation" widget.
To do so:
• enable the Widget if necessary (click the link "Click here to re-enable").
• click the arrow.
Remark
368 Part 6: Optimizing and debuging a project Part 6: Optimizing and debuging a project 369
Procedure not run Orphan element
In our project, the audit indicates that a procedure is never run. The audit indicates that our project contains an orphan element.
In huge projects, you may want to create one or more procedures to perform a process then, As for the procedures run, you may create windows or reports in order to run a quick test, save
further to a code reorganization, the procedure is no longer used but it remains in the project. them and forget everything about them. The presence of orphan elements in the executable
The presence of unused procedures unnecessarily consumes the resources distributed to the end unnecessarily consumes the resources distributed to the end users.
users.
▶ To fix this problem:
▶ To fix this problem: 1. Click the [...] button to get more details. The window that lists the orphan elements is
1. Click the [...] button to get more details. The window that lists the dead codes is displayed. displayed.
2. The "ObsoleteProcedure" procedure is never called. This window is used to: 2. The "WIN_UnusedWindow" window is never called. The window that lists the orphan elements
• specify that the procedure is still used ("Flag as useful"). In this case, the procedure will is used to:
not be taken into account anymore during the audit. • specify that the element is still used ("Flag as useful"). In this case, the window will not be
• delete the procedure if it is actually unused ("Delete"). taken into account anymore during the audit. This option can be interesting when using a
• see the procedure ("View"). test window specific to the development for example.
• find the use cases in the strings for example ("Search"). • delete the element if it is actually unused ("Delete").
3. In our case, this procedure is actually unused, click "Delete". • see the element ("View").
4. A window is displayed, asking you to confirm the deletion. Click the "Delete" button to confirm • find the use cases in the strings for example ("Search").
the deletion. 3. In our case, this "WIN_UnusedWindow" window is actually unused, click "Delete".
5. Close the window of dead code (click the cross in the top right corner). 4. Close the window of orphan elements (click the cross in the top right corner).
▶ In the window of static audit, click the "Refresh" button to update the audit report. ▶ In the window of static audit, click the "Refresh" button to update the audit report.
370 Part 6: Optimizing and debuging a project Part 6: Optimizing and debuging a project 371
Cleaning the project
The dynamic audit of the project can also be started from the project
Our project contains several unused files. You have the ability to clean the project in order to keep dashboard, via the "Execution" widget. To do so:
the necessary elements only. The executable and the client setup is not weighted with images, • enable the Widget if necessary (click the link "Click here to re-enable").
external files, ... not used.
• expand the arrow and select "Detailed Go of project".
▶ To fix this problem:
1. Click the [...] button to get more details.
2. The wizard for cleaning a project starts. This wizard indicates the unused files that can be
deleted.
3. Go to the next step.
4. Select the type of cleaning to perform. You can:
• create a zip file with the useless files.
• move the useless files into a specific directory.
Remark
5. Validate the option proposed by default and go to the next step. Remark: The dynamic audit is automatically run whenever the application
6. End the wizard. is started by a project GO. A report is automatically displayed in the project
Our project was optimized according to the tips given by the static audit. dashboard:
The static audit is used to get an overall status on the source code of your project. Our advice: run
it on a regular basis!
Let’s see what happens at run time by starting the dynamic audit.
Dynamic audit
The dynamic audit is used to study the application execution. The audit is used to detect problems
such as:
• Excessive memory consumption,
• Slowness of algorithms used,
• Errors "hidden" at run time, 2. Click the "Test window of dynamic audit" button.
• ... 3. Click the different buttons found in the window. At the end of each process, a toast message
A dynamic audit can be performed in a test environment or on a live application. is displayed to specify that the process is over. For the "Assertion and Exception" option, an
The "WD Optimization" project contains a specific window triggering errors that can be detected by assertion is displayed: click "Continue" in order for the message to appear in toast format.
the dynamic audit. 4. Stop the application test.
The dynamic audit and the project test will be started at the same time.
▶ To start the dynamic audit on the "WD Optimization" project:
1. On the "Project" pane, in the "Test mode" group, expand "Test mode" and select "Debug the
project while the audit is enabled". The project test is run.
372 Part 6: Optimizing and debuging a project Part 6: Optimizing and debuging a project 373
5. The report window of the dynamic audit appears.
The dynamic audit of a project can also be performed when an application is
deployed on the user computers.
You can:
• modify the application and use dbgEnableAudit to start the audit.
Remark
• use a text file in the application directory. This solution allows you not to
modify the executable. All you have to do is create, in the directory of the
executable, a file named like the executable and whose extension is ".WX".
The audit generates a ".wdaudit" file, this file must be loaded in the development
environment in order to study the result.
See the online help for more details (keyword: "Dynamic audit").
374 Part 6: Optimizing and debuging a project Part 6: Optimizing and debuging a project 375
Lesson 6.3. Performance profiler Overview
The performance profiler (also called Profiler) is a tool used to check and optimize the execution
time of the processes found in your application.
This lesson will teach you the following concepts The principle is straightforward:
• You run the test of your application.
• Overview. • During this test, the performance profiler keeps track of all actions performed and saves the
execution times of each one of the processes run.
• Starting the performance profiler.
• Studying the result.
At the end of test, the performance profiler displays:
• the 10 most time consuming operations,
• the duration and the number of calls for all processes run.
The "WD Optimization" project contains a specific window used to see the interesting results with
the performance profiler.
Estimated time: 15 mn
Starting the performance profiler
The performance profiler can be started:
• from the WINDEV editor:
In this case, the project is automatically run in test mode. You can use your application and
start the processes of your choice.
To go back to the WINDEV editor, all you have to do is exit from your application.
Then, the performance profiler displays the monitoring result. This result is saved in a WPF file.
• from one of your WLanguage processes, with the following functions:
ProfilerStart Starts "collecting data" for the performance profiler.
ProfilerEnd Stops "collecting data" for the performance profiler.
In this case, only the code found between ProfilerStart and ProfilerEnd is studied. The result is
saved in a WPF file.
376 Part 6: Optimizing and debuging a project Part 6: Optimizing and debuging a project 377
▶ The first method will be used in our example. To start the performance profiler on the "WD
Optimization" project:
1. On the "Project" pane, in the "Audit and performance" group, expand "Analyze the
performance" and select "Analyze the performance".
The performance profiler can also be started from the project dashboard, via
the "Performance" widget. Simply:
• enable the Widget if necessary (click the link "Click here to re-enable").
• expand the button with arrow and select "Analyze the performance".
Remark
• The "Mapping" tab is used to visually identify what took the longest time. In our case, it’s a
2. The project test is run. call to Ping:
3. Click the "Test window of performance profiler" button.
4. Click the "Process to analyze" button.
5. Validate the information window and stop the project test. The report window of performance
profiler is displayed.
378 Part 6: Optimizing and debuging a project Part 6: Optimizing and debuging a project 379
• The "Details" tab presents all processes or events run, from the slowest one to the fastest 2. Click the "Calls" button to display the details of calls to the UpdateProductStock procedure.
one. Select the "Ping" line and click the "Code" button: the corresponding code line is displayed in the
code editor.
380 Part 6: Optimizing and debuging a project Part 6: Optimizing and debuging a project 381
▶ We are now going to restart the performance profiler:
1. On the "Project" pane, in the "Audit and performance" group, expand "Analyze the Lesson 6.4. Debugging a project
performance" and select "Analyze the performance".
2. The project test is run.
3. Click the "Test window of performance profiler" button.
This lesson will teach you the following concepts
4. Click the "Process to analyze" button.
5. Validate the information window and stop the project test. The report window of performance
profiler is displayed. • Overview.
6. In the "Mapping" tab, Ping does not appear with the same importance. • Using the debugger.
Estimated time: 15 mn
382 Part 6: Optimizing and debuging a project Part 6: Optimizing and debuging a project 383
Overview
Let’s take a look at the debugger supplied with WINDEV.
What is the debugger?
The debugger is a powerful tool used to follow the code or application progress, step by step.
Enhancing a process or even an application becomes child’s play.
We are going to use the debugger on the long process found in the WIN_PerformanceProfiler
window.
We are going to perform some operations in the debugger to discover its capabilities.
▶ First of all, we are going to run the different statements step by step and see the content of
variables:
1. Press the F8 key (or click the "Step by step" button found in the ribbon). The line following
the current line is automatically run. The values of variables are modified (if necessary) in the
"Debugger" pane (displayed at the bottom of the screen).
384 Part 6: Optimizing and debuging a project Part 6: Optimizing and debuging a project 385
2. When the cursor shaped like an arrow reaches the "PROGBAR_Progress..MaxValue = ..." line, 4. The expression is automatically added into the debugger pane at the bottom of the screen.
hover "PROGBAR_Progress" with the mouse. A tooltip is displayed with the expression value:
3. Press the F6 key (or click the "Run until cursor" button found in the ribbon).
4. The arrow indicating the line currently run moves until it reaches the code line where the
▶ Let’s continue our operations in the debugger. We are now going to run the cursor is positioned. The code lines found before the cursor are automatically run.
UpdateProductStock procedure step by step in the debugger.
1. To run this procedure step by step, press the F7 key (or click the "Detailed step by step" ▶ We are now going to add a breakpoint and to run the code until it reaches the breakpoint:
button in the ribbon). 1. Click in the hatched area with the mouse, in front of HModify. A breakpoint (red bullet)
2. The procedure code is displayed in the debugger. appears.
▶ We are now going to add an expression to monitor the evolution of its value in the "Debugger"
pane. This expression can have any type: variable, function, operation on variables, ... The
expression result is calculated and displayed.
This expression is used to perform a custom debugging. For example, you can find out the
content of a variable while it is being used in the application.
1. Press F7 to run the different lines of UpdateProductStock procedure until you reach the line:
PROGBAR_Progress++
2. Press the F5 key (or click the "Continue" button found in the ribbon). The code is run until it
reaches the breakpoint. The arrow used to identify the current line moves until it reaches the
breakpoint.
3. Click the breakpoint to remove it.
386 Part 6: Optimizing and debuging a project Part 6: Optimizing and debuging a project 387
▶ To end this test, we will be using an "Auto-stop" expression. An "Auto-stop" expression is used
to start the debugger as soon as a condition is checked or when the value of a variable is
PART 7
modified. In our example, the debugger will be started as soon as the value of progress bar is
set to 50%:
1. In the "Debugger" pane, select the "PROGBAR_Progress" expression that was added
beforehand.
2. Click the green circle.
3. Press F5 to continue the test.
4. A message is displayed, indicating that the value of "PROGBAR_Progress" expression
changed.
Advanced
programming
5. Validate.
6. In the "Debugger" pane, select the "PROGBAR_Progress" expression. Click the expression
again: the "Expression" column becomes editable. In the "Expression" area, add "=50". You will
get "PROGBAR_Progress = 50".
7. Press F5. The program continues to run. The debugger is started again when the value of the
progress bar is set to 50.
▶ That’s it, the main features of debugger have been presented here. To stop the test in the
debugger, click "End the test" found in the ribbon.
• Overview.
• How to open a training example?
• How to open a unit example?
Estimated time: 5 mn
The errors can be automatically managed by WINDEV. This feature helps you reduce the number Two types of errors can occur in WLanguage:
of code lines while centralizing the management of errors. • the "non-fatal" errors (also called runtime errors): in most cases, these errors are managed
The use of this feature also makes the code easier to read. in the code and they do not stop the application. For example, opening a file that cannot be
accessed or an archive that does not exist.
Operating mode • the "fatal" errors (also called programming errors): in most cases, these errors are linked to a
development problem (access to a non-declared file, use of non-existing controls ...). A "fatal"
Two operations are performed when an error is detected by a WLanguage function: error can also occur after a "non-fatal" error that was not processed properly. In this case, the
• an error value is returned by the function (for example, fOpen returns "-1" if the specified file application will be stopped.
was not opened).
• the error is detected by WLanguage (the ErrorOccurred variable is set to True) and the error The mechanism for managing errors is used to manage these two types of errors according to
details are returned by ErrorInfo. different methods in order to specify behaviors adapted to the errors that occur.
This second operation can be automatically managed by the error management of WINDEV. Automatic management of errors: a training example
Implementation
▶ To understand the different error cases, we will be using a training example supplied with
The automatic management of errors can be configured: WINDEV.
• in the code editor: all you have to do is click the link "If error: By program" in the code editor: 1. Display the WINDEV home page if necessary (Ctrl + <).
2. On the home page, click "Open an example". The list of complete examples, training examples
and unit examples supplied with WINDEV is displayed.
3. Type "Error" in the search area. Only the examples containing this word are listed.
4. Select the "WD Auto Error Management" project. The project is loaded.
• by programming with ErrorChangeParameter.
▶ This project presents the management:
• of a non-fatal error (opening an archive that does not exist).
• of a fatal error (division by 0).
• of an error on several levels.
3. Click the "Test this error management" button. 2. Click the "Test this error management" button.
4. When running the code line that triggers the error, an error message is displayed, allowing 3. When running the code line that triggers the error, a procedure is automatically called. This
the user to retry the operation, cancel the operation or stop the application. The "Debug" option procedure is used to display the error message and to stop the current process.
should be used: 4. Click "OK" and close the window.
• in test mode, to directly debug the application.
• in executable mode, to debug an executable directly from WINDEV.
5. Click "Cancel the operation" and close the window.
Estimated time: 20 mn
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 files in XML format via a native access supplied with WINDEV.
See the online help for more details.
• the exports to XML (TableToXML, TextToXML, HExportXML).
• import of XML data (HImportXML).
• the use of an XML document via the advanced XMLDocument type and via the WLanguage
functions starting with XML.
The XML file can also be handled in the code editor directly. Simply:
1. Drag the XML file from the file explorer and drop it in the "Project explorer" pane tab, "External
descriptions" folder.
2. Drag the XML file from the "Project explorer" pane and drop it in the code editor. The
xmlDocument variable is automatically created as follows: • read an XML file.
<Variable name> is xmlDocument, description = <Document name> ▶ Study the code associated with each button.
3. You now have the ability to access the variable nodes by their names. These names are
Remark
automatically proposed by the mechanism for automatic completion of the code editor. We won’t go into details about all the features proposed by the XML functions.
See the online help for more details.
Estimated time: 20 mn
▶ Go back to the editor and study the code of different Button controls in the window.
We won’t go into details about all the features proposed by the XLS functions
Remark
3. Press Ctrl + F2. The "Click" event of the "Run" Button control re-appears in the code editor.
In the rest of this code, you can see that the function that is dynamically compiled is run by
Execute.
When these events occur, they can be intercepted in order to prepare or to run a specific process.
WINDEV proposes an automatic management of most common events. For example, the following
Estimated time: 10 mn events are automatically proposed for an edit control:
• Initializing the control,
• Entry in the control,
• Modifying the control,
• Exit from the control.
Practical example
The management of events will be presented via the unit example named "The Event function".
▶ Open the unit example named "The Event function".
To use Event, you must be familiar with the Windows programming, especially included in the application code.
the Windows events.
• Then, all supported events are declared:
// Events on LIST_Month control
See the WINDEV online help to find out the non-exhaustive list of Windows events (keyword: // Keyboard key down
"Windows API, Value of constants of Windows API"). Event("MouseOrKeyboard", LIST_Month..FullName, ...
WM_KEYDOWN)
// Left mouse click
Event("MouseOrKeyboard", LIST_Month..FullName, ...
WM_LBUTTONDOWN)
The procedure MouseOrKeyboard is called whenever the keyboard is used on the List Box
control (corresponding Windows event: WM_KEYDOWN) or whenever the left mouse click is
used (corresponding Windows event: WM_LBUTTONDOWN).
In most cases, a secondary thread is used to detect an event such as a user action, an incoming
email, a phone call, ... • Overview.
• Server application.
Examples for using threads: • Client application.
• Retrieving emails in background task while typing a new email.
• Communication application: managing the phone calls, communication by socket, ...
Example
WINDEV is supplied with several unit examples allowing you to understand the
Example
Client application
Example
WINDEV is supplied with a training example allowing you to understand the use
of sockets: "WD Using sockets". This example is accessible from the WINDEV
A client application of a socket server connects to a standard server in order to exchange
home page (Ctrl + <).
information via socket.
Example: A client WINDEV application can connect to a standard news server on Internet.
The steps for creating a client application are as follows:
Server application: for a simplified server 1. Connecting to the server.
2. Exchanging data.
WINDEV gives you the ability to create a simplified socket server. This server allows you to
communicate with a single client computer at a time. This type of application is very useful when 3. Ending the communication.
two remote applications must communicate. Connecting to the server
The steps for creating a simplified server are as follows:
1. Creating the socket. To connect to a server socket, all you have to do is use SocketConnect. This function is used to
perform a request for connecting to the server.
2. Exchanging data.
The socket is identified by its port and by its address.
3. Closing the socket.
Exchanging data
Creating the socket
When two computers are using the same socket, a communication stream is established between
To create the socket, the server is using SocketCreate. A socket is associated with a specific port.
these two computers. These two computers can read and write character strings on the socket.
For a simplified use of socket by programming on the server, specify the socket name.
Remark: To avoid locking the applications, the management of incoming messages is often
The client computer will connect to this socket in order to exchange data. The connection between
performed by a specific thread.
the two computers will be actually established during the first exchange of data between the two
computers (which means when the server reads information for the first time). To read and write on the socket, the WINDEV client application must use SocketRead and
SocketWrite.
The connection is established during the first successful attempt of SocketRead on the server.
Ending the communication
Exchanging data
To end the communication, all you have to do is close the socket from the client computer with
When two computers are using the same socket, a communication stream is established between
SocketClose.
these two computers. These two computers can read and write character strings on the socket.
Remark: you also have the ability to end the communication from the server.
Remark: To avoid locking the applications, the management of incoming messages is often
performed by a specific thread.
You will notice the presence of SocketRead that is used to read the socket that
was created beforehand. The message read is immediately displayed in the "EDT_
SentenceReceivedFromComputerB" control. Close the code editor.
To send a file to an FTP server, all you have to do is use FTPSend. 3. In the example, the procedure called is used to display the files found in a trace window.
Let’s see a code sample that can be used: PROCEDURE CallBackFTPListFile(sFileName, nFileSize <useful>, ...
sAttribute, sModifDate <useful>, sModifTime <useful>)
// When connecting to the server with FTPConnect, we have
// retrieved the connection number in the gnConnectionID variable // Is it a file or a directory
// Transfer the "C:\MyDocuments\File.DOC" file to IF sAttribute = "D" THEN
// the "Temp" directory found on the server. // Directory or sub-directory
bResult is boolean = FTPSend(gnConnectionID, ... Trace("Directory: " + sFileName)
"C:\MyDocuments\File.DOC", "/Temp") ELSE
// File
Trace("File: " + sFileName)
Pay great attention to the case (uppercase/lowercase characters) for the name END
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 // Continue to browse the files
Caution!
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 the online help for more details (keyword: "FTP, Functions").
The Object-Oriented Programming (OOP) is designed for better code reusability. The programs The notions of Constructor and Destructor are important because they allow for an automatic call
developed in OOP are structured: they include modules, each one managing a software feature. to initialization methods when creating an object and when destroying it.
These modules can easily be re-used in other software. They group a set of procedures (called The Constructor method associated with a class is automatically called when declaring a class
methods) and they encapsulate the data structure on which the methods will act. object.
To use the object-oriented programming, you must declare the classes, the members and the The Destructor method associated with a class is automatically called when deleting the object
associated methods. (exit from the procedure where the object was declared).
A class contains the description of a data structure (the members) and the procedures (methods) The data encapsulation is used to ensure that the data belonging to the object is not accidentally
that handle the members. modified by functions (methods) external to the object.
Therefore, a class defines a type of data and its behavior. This allows you to prevent the user of an object from accessing some or all of its members. The
members whose access is forbidden are called private members.
The objects These private members can only be accessed from the methods designed for this purpose in the
class.
A class is used to create objects. Each created object owns the members described in its class
and it can be handled via the methods of its class. An object is defined as a class instance. Example
When the class is declared, all you have to do is associate an object with a class in order for the
object to be handled by all methods of this class. Let’s take a simple example to apply these concepts:
• Let’s consider the PERSON class.
The members • Florence is an instance of PERSON class.
A member is a data (or parameter) of the object. • The last name, first name and date of birth can be members of PERSON class.
• The Age() method can be a method of PERSON class. It would calculate the age according to
The methods the "date of birth" member and according to todays’ date (returned by DateSys).
A method is used to act on the object, to modify its members for example. • Inheritance: A contact can be either a person, or a company.
A method is a procedure. Its operating mode is similar to the one of standard WLanguage • PERSON could be a class derived from CONTACT.
procedures. • COMPANY could be a class derived from CONTACT.
In this code:
• "cSavanna" is the class name.
• "m_sNameImageControlForDrawing" and "m_arrTheAnimals" are class members.
• The "PROTECTED" keyword is used to specify that these members can only be handled
from a code of the class or from a code of a derived class.
Describing the methods
▶ WINDEV allows you to easily declare the classes from the "Project explorer" pane. To create a
method:
1. Right-click your class in the "Project explorer" pane.
2. Select "New method" from the popup menu.
3. In the window that is displayed, specify the method name and validate.
4. Type the method code in the code editor.
3. Click the different buttons corresponding to the animals in order to add them.
4. Stop the example test to go back to the editor.Remark: We won’t go into details about the ▶ To display the AddAnimal method of cSavanna class:
syntax of OOP but we will present a simple example of an object-oriented program. 1. Click your class in the "Project explorer" pane.
See the online help for more details (keyword: "OOP, Class"). 2. Click the little arrow found in front of the class name: the different class methods are
displayed.
Declaring a class 3. Double-click the method name:
▶ WINDEV allows you to easily declare the classes from the "Project explorer" pane. To create a PROCEDURE AddAnimal(pclAnAnimal is cAnimal dynamic)
class:
1. In the "Project explorer" pane, select the "Classes" folder // No more than 5 animals
IF m_arrTheAnimals..Count = 5 THEN
2. Display the popup menu of this folder (right mouse click) and select "Create a class". Error("No more than 5 animals!")
3. In the window that is displayed, specify the class name ("TestTUT" for example) and validate. RESULT False
END
▶ Study the WLanguage code of cSavanna class used in the example.
// Adds the animal to the list
1. In the "Project explorer" pane, select the "Classes" folder Add(m_arrTheAnimals, pclAnAnimal)
2. Open the "Classes" folder (to do so, click the arrow found in front of the folder name).
3. Double-click the cSavanna class. // Draws the savanna
DrawSavanna()
RESULT True
// Adds the elephant into the savanna (this action refreshes the
drawing)
IF gclTheSavanna.AddAnimal(clElephant) THEN
// End message
ToastDisplay("Animal added", toastShort, vaMiddle, haCenter) 2. The UML diagram (class diagram) linked to the project is displayed.
END
3. The different classes used by the "WD Simple OOP" project are found in this diagram.
Appendices
We won’t go into details about the use of UML language with WINDEV.
See the online help for more details (keyword: "UML").
Estimated time: 30 mn
Anchoring Database
Mechanism that consists in defining positioning or resizing rules in order for the content of a Element containing the program data. The data is organized in data files (also called tables).
window or page to adapt when resizing a window or a browser.
Data binding
Application RAD Method used to associate a graphic interface element to a data (variable, item).
Fast development method of program from a program template.
Deployment
Array Consists in installing a program on the user computer.
Type of variable that contains several values. The values can be accessed via a subscript. The
[] characters are used to access the elements of an array.
Editor
Program that is used to create a project element (window editor, page editor, ...).
Assignment
Operation that consists in assigning a value to a variable or control. For example:
Event-driven
// Assign the value MOORE to CustomerName variable Type of programming. A user action on a window or on a page induces a code to run. The code
CustomerName = "MOORE" of the action to run is typed in the event representing the user action.
For example, the "Button click" event corresponds to the user clicking this button with a mouse.
The = sign is the assignment operator.
External component
Break (report)
Software brick that is used to export one or more business rules in order to re-use them.
Mechanism that consists in grouping and separating the data according to a value.
For example, create a break in a report that is used to list the customers by city. The customers
who live in the same city are grouped together. Visually, we separate the customers for each Data file (Table)
new city. Element that constitutes a database. A data file is used to store the data entered into a
program.
For example, a CUSTOMER file will contain the customer information that was entered into a
Class (OOP)
program.
Element defined in Object-Oriented Programming. A class gathers methods (actions) and
members (data).
Global (variable or procedure)
Corresponds to the scope in memory of a variable or procedure. A global element is accessible
Classic (data file)
from any other project element. The opposite is local.
Type of access to an HFSQL data file. An HFSQL data file is Classic when accessed directly in
its directory.
Procedure Structure
Project element containing the code of a process to run. Type of variable that includes several sub-variables.
Webservice
Report Program installed on a Web server whose processes are accessible via the Web.
Project element that defines a printout.
XML
Block (report) Language for organizing data in order to normalize and simplify the exchange of data (mainly
Element constituting a report. For example, a Header block, a Footer block, a Body block. used in the exchanges with the Webservices).
Report template
Container representing a standard report that can be applied to one or more project reports.
Main template characteristic: if the initial template is modified, the modifications are
automatically applied to the copies.
SCM
Source Code Manager. Tool for organizing, sharing project resources, managing rights, ...
Style
Element used to describe the graphic style of a control in a window or in a page. A style
includes, for example, a font, the character size, the character color, etc.
This lesson is intended to the users with a good knowledge of SQL databases.
Remark
This lesson will teach you the following concepts Some operations to perform on the SQL database will not be presented in
details
• Creating a project.
To create an application that is using an SQL database, you must:
• Creating an analysis.
• Create the project linked to the application. This project will group all application elements
(windows, codes, queries, reports, ...).
• Import the description of SQL data files.
Remark
tutorial examples) with the available import tools (MySql, Oracle, SQL Server,
...). The image directory is used to get the images of Product data file.
3. Run the SQL script files on the SQL server.
Remark: The provided SQL scripts operate on Oracle only.
Your SQL database is ready for this lesson.
Tip
1. Click among the quick access buttons.
2. The window for creating a new element is displayed: click "Project".
4. The first step of the wizard allows you to select the operating system for which the project is
intended. Select "Windows platform" and go to the next step of the wizard ("Next").
You can:
• access the data in its current format directly. Only the description of tables is imported into
the analysis. No conversion is required. Generating the analysis
• convert the data to HFSQL Classic format.
6. In our case, choose "Access the data in its current format directly". Go to the next step. Generating the analysis consists in validating the modifications performed in the analysis (creation
7. Select the tables (files) to import. of data files, addition or deletion of items, etc.) and to apply them to the entire project (pages,
linked controls, reports, etc).
The generation is automatically proposed when closing the data model editor while modifications
have been performed.
You also have the ability to generate the analysis manually. That’s what we are going to do.
▶ To generate the analysis:
1. In the data model editor, go to the "Analysis" pane, "Analysis" group, and click "Generation".
2. The analysis generation is automatically started.
When your analysis is generated, the data can be handled like the HFSQL data. There is no
difference. You can:
• Create a full application via RAD (Rapid Application Development). See "Lesson 3.4. The full
RAD" for more details.
• Create a full custom application. See "Part 4" for more details.
8. Validate and end the wizard. The tables are imported and viewed in the data model editor.
This course covered a range of topics, but not all of WINDEV features, far from it!
You are now familiar with the main concepts.
Also explore the examples supplied with WINDEV: some are simple and only address one topic,
while others are more complex. These examples will show you the different aspects of WINDEV.
Reading the source code is also a good way to learn.
It would take too much time to discuss all available topics (there are hundreds, even thousands!).
WINDEV proposes several other features not presented in this tutorial:
• HTTP and telephony functions
• creation of skin templates...
• nested reports, queries with parameters...
• dynamic compilation, calls to DLL, external languages...