11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Caché</strong> <strong>ObjectScript</strong> Functions“1234Alabama567”, the following $EXTRACT functions both return the string“Alabama”:SET var2="1234Alabama567"WRITE !,$EXTRACT(var2,5,11)WRITE !,$EXTRACT(var2,*-9,*-3)You can also use the $EXTRACT function with the SET command to change the values ofspecified characters within a string. For example:SET var1="ABCD"SET $EXTRACT(var1,2)="Z"WRITE var1returns “AZCD”.ParametersstringThe string value can be a variable name, a numeric value, a string literal, or any valid <strong>Caché</strong><strong>ObjectScript</strong> expression.fromThe from value must be a positive integer, an asterisk (*), or an asterisk and a negativenumber. A from value with a negative number may include or omit blank spaces; all of thefollowing are permissible: *-3, * -3, * - 3.If the from integer value is greater than the number of characters in the string, $EXTRACTreturns a null string. If the from asterisk negative value is equal to or greater than the numberof characters in the string, $EXTRACT returns a null string.If from is an asterisk, attempting to specify a to value causes <strong>Caché</strong> to generate an error.If from is used with the to parameter, from identifies the start of the range to be extracted andmust be less than the value of to. If from equals to, $EXTRACT returns the single characterat the specified position. If from is greater than to, $EXTRACT returns a null string. If usedwith the to parameter, a from value less than 1 (zero, or a negative number) is treated as if itwere the number 1.toThe to parameter must be used with the from parameter. It must be a positive integer, anasterisk (*), or an asterisk followed by a negative integer. If the to value is an integer greaterthan or equal to the from value, $EXTRACT returns the specified substring. If the to value204 <strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong>

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

Saved successfully!

Ooh no, something went wrong!