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.

<strong>Caché</strong> <strong>ObjectScript</strong> FunctionsSET X="THIS IS A TEST"WRITE $EXTRACT(X,*-3,*)$EXTRACT with SETYou can use $EXTRACT with the SET command to replace a specified character or rangeof characters with another value. The simplest form of this is a one-for-one substitution:SET foo="ABZD"SET $EXTRACT(foo,3)="C"WRITE fooyields “ABCD”.You can also extract a string and replace it with a string of a different length. For example,the following command extracts the string “Rhode Island” from foo and replaces it with thestring “Texas”, with no padding.SET foo="Deep in the heart of Rhode Island"SET $EXTRACT(foo,22,33)="Texas"WRITE fooyields "Deep in the heart of Texas".You can extract a string and set it to the null string, removing the extracted characters fromthe string:SET foo="ABCzzzzzD"SET $EXTRACT(foo,4,8)=""WRITE fooyields “ABCD”.If you specify to larger than the string, $EXTRACT pads with blank spaces:SET foo="ABCD"SET $EXTRACT(foo,8)="X"WRITE fooyields “ABCD^^^X” (here a blank space is shown using “^”).If you specify from larger than to, no replacement occurs:SET foo="ABCD"SET $EXTRACT(foo,4,3)="X"WRITE fooyields “ABCD”.SET $EXTRACT ExamplesThe following example changes the value of x from “ABCD” to “ZBCD”:206 <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!