strins()
Description
Insert a sub-string in a string.
Syntax
strins(string[], substr[], index);
Parameters
Variable | Input |
|---|---|
| The source and destination string. |
| The string to insert in parameter string. |
| The character position of string where substr is inserted. When 0, substr is prepended to string |
Returns
true on success and false on failure.
Function call example
String insertion example
new data1[13] = [4, 8, 15, 14, 23, 42];
new data2[6] = [4, 8, 15, 14, 23, 42];
new array1[10]=''newText'';
new array2[20]=''oldText'';
main(){
strins(data1, data2, 3); //result of data1 buffer will be 4, 8, 15, 4, 8, 15, 14, 23, 42, 14, 23, 42
strins(array2, array1, 3); //result
while(1){
Delay(100);
}
}Notes and Warnings
During insertion, the substr parameter may be converted from a packed string to an unpacked string, or vice versa, in order to match string.
If the total length of string would exceed maxlength cells after inserting substr, the function raises an error.
In case index is higher than size of the text or gets text out of bounds of destination string - this will cause your MCU to stop. Select index number carefully. Make sure that index number will not overflow destination string.