From Clomosy Docs

No edit summary
No edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 15: Line 15:


<b>Example</b><br>
<b>Example</b><br>
<b>TRObject Syntax</b><br>
 
<pre>
<pre>
var
var
Line 25: Line 25:
   ShowMessage('Target : '+Target);
   ShowMessage('Target : '+Target);
}
}
</pre>
<b>Base Syntax</b><br>
<pre>
var
  Source, Target : string;
begin
  Source := '12345678';
  Target := Copy(Source, 3, 4);
  ShowMessage('Target : '+Target);
end;
</pre>
</pre>


Line 42: Line 31:
Target : 3456
Target : 3456
</div>
</div>
<h2> See Also </h2>
* [[System_Library#String_Functions | String Functions]]
{{#seo:|title=Copy in Clomosy - Clomosy Docs}}
{{#seo:|description=Learn how to use the Copy function in Clomosy to extract a substring or segment of a dynamic array, starting at a specific index with a defined count.}}

Latest revision as of 15:01, 24 December 2024

Returns a substring of a string or a segment of a dynamic array.

S: An expression of a string or dynamic-array type.
Index and Count: Integer-type expressions.

Copy returns a substring or subarray containing Count characters or elements starting at S[Index]. The substring or subarray is a unique copy (that is, it does not share memory with S; if the elements of the array are pointers or objects, these are not copied). If Index is larger than the length of S, Copy returns an empty string or array.
If Count specifies more characters or array elements than are available, only the characters or elements from S[Index] to the end of S are returned.

Example

var
  Source, Target : string;

{
  Source = '12345678';
  Target = Copy(Source, 3, 4);
  ShowMessage('Target : '+Target);
}

Output:

See Also