strmid()

strmid()

Description

Extract a range of characters from a string.

Syntax

strmid(dest[], source[], start, end, maxlength);

Parameters

Variable

Input

Variable

Input

dest[]

The string to store the extracted characters in.

source[]

The string from which to extract characters.

start

The index of the first character to extract (starting at zero).

end

The index of the character after/ the last character to extract.

maxlength

The size of dest in cells. If the length of dest would exceed maxlength cells, the result is truncated.

Returns

The number of characters stored in dest[].

Function call example

Example of characters extraction
new data1[20]; new data2[10] = [15, 20, 4, 8, 15, 14, 23, 42, 35, 11]; new array1[10]=''newText''; new array2[20]=''oldTextold''; main(){ strmid(data1, data2, 2, 8, sizeof data1); // result of data1 will be (in HEX): 04 08 0F 0E 17 2A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 strmid(data1[5], array2, 3, 7, sizeof data1); // result of data1 will be (in ASCII): <0><0><0><0><0>Text<0><0><0><0><0><0><0><0><0><0><0> // 5 zeroes in front since 5 elements offset was made (strmid(data1[5]...)) while(1){ Delay(100); } }

Notes and Warnings

The parameter start must point at the first character to extract (starting at zero) and the parameter end must point behind the last character to extract. For example, when the source string contains “Jabberwocky”, start is 1 and end is 5, parameter dest will contain “abbe” upon return.