Difference between revisions of "Documentation/DevGuide/Basic/String Functions"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (Robot: Changing Category:Basic and Dialogs)
m
 
(3 intermediate revisions by 2 users not shown)
Line 6: Line 6:
 
|NextPage=Documentation/DevGuide/Basic/Specific UNO Functions
 
|NextPage=Documentation/DevGuide/Basic/Specific UNO Functions
 
}}
 
}}
{{DISPLAYTITLE:String Functions}}
+
{{Documentation/DevGuideLanguages|Documentation/DevGuide/Basic/{{SUBPAGENAME}}}}
{{PRODUCTNAME}} Basic supports several runtime functions for string manipulation. Some of the functions are explained briefly in the following:
+
{{DISPLAYTITLE:String Functions}}
 +
{{AOo}} Basic supports several runtime functions for string manipulation. Some of the functions are explained briefly in the following:
  
* <code>Asc</code> returns the the Unicode value.
+
* <code>Asc</code> returns the Unicode value of the first character of its string parameter.
* <code>Chr</code> returns a string containing the character that is specified by the ASCII or Unicode value passed to the function. This function is used to represent characters, such as '"' or the carriage return code (<code>chr(13)</code>) that can not be written in the "" notation.
+
* <code>Chr</code> returns a string containing the character that is specified by the ASCII or Unicode value passed to the function. This function is used to represent characters, such as the carriage return code (<code>Chr(13)</code>), that cannot be written in the "" notation. This is not necessary for the " character, which can be included in a string literal by simply doubling it, eg. <code>s = "This string has ""embedded"" quotes"</code>
* <code>Str</code> converts a numeric expression to a string.
+
* <code>Str</code> converts a numeric expression to a string in a locale-independent manner (contrary to the <code>CStr</code> function).
 
* <code>Val</code> converts a string to a numeric value.
 
* <code>Val</code> converts a string to a numeric value.
 
* <code>LCase</code> converts all letters in a string to lowercase. Only uppercase letters within the string are converted. All lowercase letters and nonletter characters remain unchanged.
 
* <code>LCase</code> converts all letters in a string to lowercase. Only uppercase letters within the string are converted. All lowercase letters and nonletter characters remain unchanged.
Line 19: Line 20:
 
* <code>Right</code> returns the rightmost "n" characters of a string expression.
 
* <code>Right</code> returns the rightmost "n" characters of a string expression.
 
* <code>Trim</code> removes all leading and trailing spaces of a string expression.
 
* <code>Trim</code> removes all leading and trailing spaces of a string expression.
 
+
All these functions are fully compatible with VBA and all functions returning a string can be specified with a trailing $ like <code>Mid$</code>.
 
{{PDL1}}
 
{{PDL1}}
  
[[Category:Documentation/Developers Guide/Basic and Dialogs]]
+
[[Category:Documentation/Developer's Guide/Basic and Dialogs]]

Latest revision as of 14:43, 10 December 2020



Apache OpenOffice Basic supports several runtime functions for string manipulation. Some of the functions are explained briefly in the following:

  • Asc returns the Unicode value of the first character of its string parameter.
  • Chr returns a string containing the character that is specified by the ASCII or Unicode value passed to the function. This function is used to represent characters, such as the carriage return code (Chr(13)), that cannot be written in the "" notation. This is not necessary for the " character, which can be included in a string literal by simply doubling it, eg. s = "This string has ""embedded"" quotes"
  • Str converts a numeric expression to a string in a locale-independent manner (contrary to the CStr function).
  • Val converts a string to a numeric value.
  • LCase converts all letters in a string to lowercase. Only uppercase letters within the string are converted. All lowercase letters and nonletter characters remain unchanged.
  • UCase converts characters in a string to uppercase. Only lowercase letters in a string are affected. Uppercase letters and all other characters remain unchanged.
  • Left returns the leftmost “n” characters of a string expression.
  • Mid returns the specified portion of a string expression.
  • Right returns the rightmost "n" characters of a string expression.
  • Trim removes all leading and trailing spaces of a string expression.

All these functions are fully compatible with VBA and all functions returning a string can be specified with a trailing $ like Mid$.

Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages