PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Overview
  • How to proceed?
  • 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/iPadApple WatchUniversal Windows 10 AppWindows Mobile
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 have the ability to 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 in 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 a project to another one, from a computer to another one, etc.
Each code snippet is associated with a keyword that simplifies the search.
Versions 16 and later
The management of code snippets is common to the management of the glossary found in the earlier versions.
New in version 16
The management of code snippets is common to the management of the glossary found in the earlier versions.
The management of code snippets is common to the management of the glossary found in the earlier versions.
How to proceed?

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.
Versions 16 and later
  • Manage the glossary elements.
New in version 16
  • Manage the glossary elements.
  • Manage the glossary elements.
This manager is displayed like a pane:
  • via "Code .. Code snippets .. Code snippet manager" (available in the code editor)
  • via "Code .. Code snippets .. Display the code snippets" (available in the code editor)
  • via "Code snippets .. Code snippet manager" from the popup menu of the code editor.
  • via "Code snippets .. Display code snippets" from the popup menu of the code editor.
To display this manager:
  • In the code editor, select "Code snippets .. Display all the code snippets" from the popup menu.
  • On the "Home" pane, in the "Environment" group, expand "Panes" and select "Code Snippets".
Versions 16 and later
Note: 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.
New in version 16
Note: 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.
Note: 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 code line 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 by 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 by 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, the added code snippets are stored in "Personal\Code snippets", in the setup directory of the product used. This directory can be modified in the options of WINDEV, WEBDEV or WINDEV Mobile ("Tools .. Options of WINDEV/WEBDEV/WINDEV Mobile", "Directories" tab).By default, the added code snippets are stored in "Personal\Code snippets", in the setup directory of the product used. This directory can be modified in the options of WINDEV, WEBDEV or WINDEV Mobile:
  1. On the "Home" pane, 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.
Versions 16 and later
Note: 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 code lines. 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.
New in version 16
Note: 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 code lines. 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.
Note: 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 code lines. 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.
  • Use the F5 key on the keyword associated with the code snippet.
Notes:
  • Versions 16 and later
    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.
    New in version 16
    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.
    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 (popup 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 ("Tools .. Options .. General options of WINDEV/WEBDEV/WINDEV Mobile", "Directories" tab).All you have to do is configure the directory of code snippets in the options of the product used:
  1. On the "Home" pane, 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.
Versions 16 and later

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 located in the "Custom" subdirectory of the product used. The file is automatically imported.
New in version 16

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 located in the "Custom" subdirectory of the product used. The file is automatically imported.

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 located in the "Custom" subdirectory of the product used. The file is automatically imported.
Minimum version required
  • Version 10
This page is also available for…
Comments
Video Code Bricks
https://youtu.be/ID2Qv17mRRs

https://windevdesenvolvimento.blogspot.com/2019/01/dicas-2000-windev-dicas-86-code-bricks.html
amarildo
29 Jan. 2019