PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | French EN
  • Middle and UNICODE
  • Miscellaneous
  • Differences between GO mode and runtime
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 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.
Remark: The same feature can be obtained with the [[]] operator.
Versions 15 and later
Android This function is now available for Android applications.
New in version 15
Android This function is now available for Android applications.
Android This function is now available for Android applications.
Versions 17 and later
iPhone/iPad This function is now available for iPhone/iPad applications.
New in version 17
iPhone/iPad This function is now available for iPhone/iPad applications.
iPhone/iPad This function is now available for iPhone/iPad applications.
Versions 18 and later
Android Widget This function is now available in Android Widget mode.
New in version 18
Android Widget This function is now available in Android Widget mode.
Android Widget This function is now available in Android Widget mode.
Versions 21 and later
Apple Watch This function is now available in Apple Watch mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Apple Watch This function is now available in Apple Watch mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Apple Watch This function is now available in Apple Watch mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
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"
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppJavaPHPAjaxUser code (UMC)
// Extract bytes
MyBuffer is Buffer = "Antananarivo - Madagascar"
Middle(MyBuffer, 10, 7) // Returns "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 the details of 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 WatchUniversal Windows 10 AppWindows MobileJavaPHPAjaxUser code (UMC)

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 the details of the error, use ErrorInfo.
  • Invalid buffer if <Initial buffer> contains a UNICODE string.
  • Windows Mobile Invalid buffer if <Initial buffer> contains an ANSI string.
<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>.
Windows Mobile In UNICODE, each character occupies two bytes of memory. Therefore, the number of bytes is twice the number of characters.
Remarks

Middle and UNICODE

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

Miscellaneous

The same feature can be obtained with the [[]] operator.
Windows Mobile

Differences between GO mode and runtime

In GO mode (simulation on the development computer), when extracting part of a buffer (syntax 2), <Size> corresponds to the number of characters to extract and not to the number of bytes.
For example, when the following code is executed:
MyBuffer is Buffer = "WINDEV is astonishing"
Middle(MyBuffer, 16, 6)
  • in GO mode, this code returns "ishing".
  • at runtime, this code returns "is".
The differences between GO mode (simulator) and runtime are presented in Differences between GO mode and runtime.
Component : wd260vm.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment