PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Middle function and UNICODE
  • Various
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
Extracts:
  • a sub-string from a given position in a string.
  • a section from a given position in a buffer.
WEBDEV - Browser code In this version, no section can be extracted from a buffer.
Note: The same feature can be obtained with the [[]] operator.
Example
// Extract characters
Middle("Eponine", 2, 3)   // Returns "pon"
Middle("Eponine", 2)    // Returns "ponine"
Middle("Eponine", 50)    // Returns ""
Middle("Eponine", 2, 50)   // Returns "ponine"
// Equivalent to
// MyString is string = Eponine
// MyString = MyString[[2,50]]

MyString is string = "Antananarivo - Madagascar"
Middle(MyString, 10, 7)   // Returns "ivo - M"
WEBDEV - Server codePHPAjax
// Extract the bytes
MyBuffer is Buffer = "Antananarivo - Madagascar"
Middle(MyBuffer, 10, 7) // Returns "ivo - M"
Syntax

Extracting a sub-string from a string Hide the details

<Result> = Middle(<Source String> , <Start Position> [, <Length>])
<Result>: Character string
  • Part of <Source String>.
  • Empty string ("") if <Start Position> is greater than the length of <Source String>.
  • EOT if <Start Position> and/or <Length> are negative. A WLanguage error occurs (non-fatal error). To find out the error details, use ErrorInfo.
<Source String>: Character string
Character string containing the sub-string to extract. This string is not modified.
<Start Position>: Integer
Position of first character to extract.
If <Start Position> is null, the extraction starts from the beginning of string.
<Length>: Optional integer
Number of characters to extract.
If this parameter is not specified or if it is greater than the number of characters found after <Start Position>, the string is returned from <Start Position>.
WEBDEV - Server codePHPAjax

Extracting part of a buffer Hide the details

<Result> = Middle(<Source Buffer> , <Start Position> [, <Size>])
<Result>: Character string
  • Part of <Source Buffer>.
  • Empty string ("") if <Start Position> is greater than the size of <Source Buffer>.
  • EOT if <Start Position> and/or <Size> are negative. A WLanguage error occurs (non-fatal error). To find out the error details, use ErrorInfo.
  • Invalid buffer if <Source Buffer> contains a character string in UNICODE format.
<Source 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 from the beginning of buffer.
<Size>: Optional integer
Number of bytes to extract.
If this parameter is not specified or if it is greater than the number of characters found after <Start Position>, the string is returned from <Start Position>.
Remarks

Middle function and UNICODE

If the string passed in parameter is in ANSI format, the result will be in ANSI format.
If the string passed in parameter is in UNICODE format, the result will be in UNICODE format.
The subscript of the first character in the string is set to 1.
In UNICODE, each character occupies two memory bytes. Therefore, the memory footprint of a UNICODE string is twice the number of characters actually found in the string.
Note: If the result on an ANSI string is assigned to a UNICODE string (and conversely), the conversion will be implicitly performed.
See Managing the UNICODE format for more details.

Various

The same feature can be obtained with the [[]] operator.
Component : wd240vm.dll
Minimum required version
  • Version 9
This page is also available for…
Comments
Example MIDDLE
https://forum.pcsoft.fr/fr-FR/pcsoft.br.windev/778-valida-cnpj-3140/read.awp
BOLLER
Apr. 02 2019