Set part of string


s.set(ss [from] [nc])



s.set(char [from] [nc])



s - str variable.

ss - source string.

char - source character. Integer character code.

from - where to copy (0-based character index in s). Default: 0.

nc - number of characters to copy.



Syntax1: Copies nc characters from ss (or whole ss, if nc omitted) to s, starting from from.


Syntax2: If from and nc are omitted, fills s with char. Otherwise, copies nc (default is 1) char characters to s, starting from from. In Unicode mode, don't use non ASCII characters.


Common: If from+nc>s.len, s is automatically expanded. If from>s.len, area from s.len to from is filled with spaces.



str s = "My dog"
s.set("cat" 3)
 now s is "My cat"

str s.all(6 2)
 now s has allocated 6 bytes. String content is undefined.
s.set(' ')
 now s is " " (6 spaces)

str s = "Number"
s.set('1' 7)
 now s is "Number 1"