ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Editors / Code editor
  • Overview
  • How to?
  • Code snippet manager
  • Creating a code snippet
  • Using code snippets
  • Sharing code snippets
  • Retrieving the data from a custom glossary
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Warning
From version 24, code bricks are now called "Code snippets".
Overview
The code editor allows you to enter "Code snippets". These "Code snippets" are sections of code that are frequently used. You can create all your code snippets: they will always be available to help you save time.
These code snippets can contain parameters: the name of the data file, the name of the search item or the name of the window can be passed as parameter to your code snippet. When it is used, the code editor will ask you to enter the necessary parameters: no risk of error!
Code snippets can be easily moved from one project to another, from one computer to another, etc.
Each code snippet is associated with a keyword that simplifies the search.
How to?

Code snippet manager

The code editor features a code snippet manager. This manager is used to:
  • Add a code snippet.
  • Modify a code snippet.
  • Use a code snippet.
  • Delete a code snippet.
To display this manager:
  • In the code editor, select "Code snippets .. Display all the code snippets" in the context menu.
  • On the "Home" tab, in the "Environment" group, expand "Panes", select "Panes", and then select "Code Snippets".
Remark: By default, the code snippet manager is empty. If custom code snippets were defined in the earlier versions, these code snippets are automatically imported. To display the standard elements (the shortcuts proposed by default on the WLanguage functions), select "Display the standard snippets" of the arrow button.

Creating a code snippet

A code snippet can be created:
  • from the code snippet manager. To do so, click the "+" button and enter the requested information.
  • from the code editor. To do so, select the code corresponding to the code snippet and perform a Drag and Drop toward the code snippet manager. The code snippet description window is displayed, with the requested information. If the first line of code corresponds to a comment, this comment automatically becomes the title of the code snippet.
The description window of a code snippet contains the following elements:
  1. Title of the code snippet. This title is displayed in the code snippet manager.
  2. Abbreviation associated with the code snippet. This abbreviation can be a word or a set of words. This abbreviation simplifies the use of the code snippet: all you have to do is enter the abbreviation in the code editor and press F5: the corresponding code snippet is automatically inserted.
  3. Code corresponding to the code snippet.
  4. Button used to insert the automatic controls. The following information can be inserted:
    • the date and time when the snippet was inserted into the code (to the format defined in the language parameters of Windows)
    • automatic insertion of the selected code: in this case, when the code snippet is "dropped" from the code manager to the code editor, the code currently selected in the code editor is inserted at the specified location. This option is useful for a code snippet that is used to perform an iterative process (loop, etc.).
    • login of the user who inserts the code snippet
    • parameter: this option is used to replace the code selected in the code snippet by §<Parameter name>§. <Parameter name> can be replaced with the requested name. If the code snippet contains this option, a window for entering the parameters will be automatically displayed when using the code snippet.
    • parameter with default value: this option is used to replace the code selected in the code snippet by §<Parameter name>=<Value>§. <Parameter name> can be replaced with the requested name and <Value> by the default value of the parameter. If the code snippet contains this option, a window for entering the parameters will be automatically displayed when using the code snippet.
    • cursor position: this option allows you to define the position of the cursor once the code snippet has been used. The cursor can be positioned in the code section to type for example.
Location of code snippets:
By default, new code snippets are stored in the "Personal\Code Bricks" subdirectory of the IDE installation directory. This directory can be modified in the options of WINDEV, WEBDEV or WINDEV Mobile:
  1. On the "Home" tab, in the "Environment" group, expand "Options" and select "General options of WINDEV/WEBDEV/WINDEV Mobile".
  2. Display the "Directories" tab and modify the directory of code snippets.
Remark: The code snippet manager is used to manage all the abbreviations of the code editor. Each abbreviation allows you to access a function, a procedure, a property or a set of lines of code. The code snippet manager includes the glossary found in the earlier versions. You can create a code snippet corresponding to a name of WLanguage function.

Using code snippets

Several methods allow you to use the code snippets:
  • Drag and Drop from the code snippet manager.
  • Pressing F5 on the keyword associated with the code snippet.
Remarks:
  • When typing the shortcut corresponding to a code snippet, the assisted input proposes the corresponding code snippet. All you have to do is select it and validate to include it in the current code.
  • The "Code snippet" option (context menu of the code editor) returns the list of the last ten code snippets, allowing you to use them directly.

Sharing code snippets

You want to share your code snippets between developers or between WINDEV, WEBDEV et WINDEV Mobile?
All you have to do is configure the directory of code snippets in the options of the product used:
  1. On the "Home" tab, in the "Environment" group, expand "Options" and select "General options of WINDEV/WEBDEV/WINDEV Mobile".
  2. Display the "Directories" tab and modify the directory of code snippets.

Retrieving the data from a custom glossary

If your glossary was customized in an earlier version, you can retrieve this data:
  1. Select "Import a glossary" of the arrow button.
  2. Select the "WX_Gloss.fic" file in the "Personal" subdirectory of the IDE used. The file is automatically imported.
Minimum version required
  • Version 10
This page is also available for…
Comments
Path para fazer o backup do dicionário de dados do Code Bricks
C:\PCSOFT\Windev Xx\Personal\Code Bricks

Ou

C:\PCSOFT\Windev Xx\Personal\Briques de Code
Boller
06 Mar. 2024

Last update: 09/12/2023

Send a report | Local help