From Clomosy Docs

No edit summary
No edit summary
 
Line 36: Line 36:
<h2> See Also </h2>
<h2> See Also </h2>
* [[System_Library#String_Functions | String Functions]]
* [[System_Library#String_Functions | String Functions]]
{{#seo:|title=Insert Using in Clomosy - Clomosy Docs}}
{{#seo:|description=Use the Insert function in Clomosy to add a substring into a string or an element into a dynamic array at a specified position.}}
{{#seo:|description=Use the Insert function in Clomosy to add a substring into a string or an element into a dynamic array at a specified position.}}

Latest revision as of 14:08, 24 December 2024

Inserts a substring into a string (or inserts a dynamic array into a dynamic array), beginning at a specified position.

In Clomosy code, Insert merges Source into Dest at the position Dest[Index].

Parameters

Source : The string or array elements to insert in Dest. If Source is empty, Dest is not changed.
Dest : The destination string or array, which is changed if the operation succeeds.
Index : The insertion position:
  • For a string, if Index is less than 1, it is set to 1. If it is past the end of Dest, it is set to the length of Dest, turning the operation into an append.
  • For an array, Insert inserts a dynamic array at the beginning at the position index, and returns the modified array.
Note: Index is a character index (not a byte index). But it must be incremented by 2 to pass over a surrogate pair (see the Unicode specification). When iterating or counting the characters in a Unicode string, a surrogate pair is considered to be two characters.

Example

var
 insertValue : string;

{
 insertValue = 'ClomosyLanguage';
 Insert('--', insertValue, 8);

 ShowMessage('insertValue : '+insertValue);
}

Output:

See Also