11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

$EXTRACT$EXTRACTExtracts specified characters from a character string.$EXTRACT(string,from,to)$E(string,from,to)ParametersstringfromtoAn expression that evaluates to the target string from which the substringis to be extracted.Optional — The starting position within the target string from which to extracta character or the beginning of a range of characters. Specify either apositive integer (counting from 1), an asterisk (which specifies the lastcharacter of the string), or an asterisk followed by a negative integer. If fromis an asterisk, you cannot specify a to parameter.Optional — The end position (inclusive) for a range of characters to beextracted. Specify either a positive integer (counting from 1) or an asterisk(which specifies the last character of the string), or an asterisk followed bya negative integer (which specifies an end position counting backwardsfrom the last character of the string).Description$EXTRACT returns a substring from a specified position in string. The nature of the substringreturned depends on the parameters used.• $EXTRACT(string) extracts the first character in the string.• $EXTRACT(string,from) extracts a single character in the position specified by from.The from value can be an integer count from the beginning of the string, an asteriskspecifying the last character of the string, or an asterisk with a negative integer specifyinga count backwards from the end of the string. For example, if variable var1 contains thestring “ABCD”, the following example extracts “B” (the second character), then “D”(the final character), then “A” (3 characters before the final character):SET var1="ABCD"WRITE !,$EXTRACT(var1,2) // "B"WRITE !,$EXTRACT(var1,*) // "D"WRITE !,$EXTRACT(var1,*-3) // "A"• $EXTRACT(string,from,to) extracts the range of characters starting with the fromposition and ending with the to position. For example, if variable var2 contains the string<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 203

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!