ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / String functions
  • Middle and UNICODE
  • Miscellaneous
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Extracts:
  • a substring from a string starting at a specified position.
  • part of a buffer starting at a specified position.
WEBDEV - Browser code In this version, it is not possible to extract part of a buffer.
Note: The same functionality can be obtained with operator [[]].
Example
// Extraction de caractères
Middle("Eponine", 2, 3)   // Renvoie "pon"
Middle("Eponine", 2)    // Renvoie "ponine"
Middle("Eponine", 50)    // Renvoie ""
Middle("Eponine", 2, 50)   // Renvoie "ponine"
// Equivalent à 
// MaChaîne est une chaîne = Eponine
// MaChaîne = MaChaîne[[2,50]]

MaChaîne is string = "Antananarivo - Madagascar"
Middle(MaChaîne, 10, 7)   // Renvoie "ivo - M"
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget iPhone/iPadApple WatchJavaUser code (UMC)PHPAjax
// Extraction d'octets
MonBuffer is Buffer = "Antananarivo - Madagascar"
Middle(MonBuffer, 10, 7) // Renvoie "ivo - M"
Syntax

Extracting a substring from a string Hide the details

<Result> = Middle(<Initial string> , <Start position> [, <Length>])
<Result>: Character string
  • Part of <Initial string>.
  • Empty string ("") if <Start position> is greater than the length of <Initial string>.
  • EOT if <Start position> and/or <Length> are negative. A WLanguage error occurs (non-fatal error). To get more details on the error, use ErrorInfo.
<Initial string>: Character string
Character string containing the substring to extract. This string is not modified.
<Start position>: Integer
Position of the first character to extract.
If <Start position> is null, the extraction starts at the beginning of the string.
<Length>: Optional integer
Number of characters to extract.
If this parameter is not specified or is greater than the number of characters after <Start position>, the string is returned from <Start position>.
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget iPhone/iPadApple WatchJavaUser code (UMC)PHPAjax

Extracting part of a buffer Hide the details

<Result> = Middle(<Initial buffer> , <Start position> [, <Size>])
<Result>: Character string
  • Part of <Initial buffer>.
  • Empty string ("") if <Start position> is greater than the length of <Initial buffer>.
  • EOT if <Start position> and/or <Size> are negative. A WLanguage error occurs (non-fatal error). To get more details on the error, use ErrorInfo.
  • Buffer invalid if <Buffer initial> contains a string in Unicode format.
<Initial buffer>: Buffer
Buffer containing the part to extract. This buffer is not modified.
<Start position>: Integer
Position of first byte to extract.
If <Start position> is null, the extraction starts at the beginning of the buffer.
<Size>: Optional integer
Number of bytes to extract.
If this parameter is not specified or is greater than the number of characters after <Start position>, the string is returned from <Start position>.
Remarks

Middle and UNICODE

If the string passed as a parameter is an ANSI string, the result will be an ANSI string.
If the string passed in parameter is in Unicode format, the result will be in Unicode format.
Reminder In Unicode, each character occupies two bytes of memory. The memory size of a Unicode string is therefore twice the number of characters actually contained in the string.
The fist character in the string is at index 1.
Note If the result on an ANSI string is assigned to a Unicode string (and vice versa), the conversion will be implicitly performed.
For more details, see Unicode management.

Miscellaneous

The same feature can be obtained with the [[]] operator.
Component: wd300vm.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/27/2025

Send a report | Local help