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.

contain only up to 9 characters and the state and ZIP fields were known to contain only 2 and5 characters, respectively, the SET commands could be coded with the $EXTRACT functionas follows:ADDRESSEXTRACTSET ^client(2,1,1)="Cambridge,MA,02142"SET city=$EXTRACT(^client(2,1,1),1,9)SET state=$EXTRACT(^client(2,1,1),11,12)SET zip=$EXTRACT(^client(2,1,1),14,18)WRITE "City is ",city,!,"State or Province is ",state,!,"Postal code is ",zipQUITNotice the gaps between 9 and 11 and 12 and 14 to accommodate the comma field separators.The following example replaces the first substring in A (originally set to 1) with the string"abc".StringPieceSET A="1^2^3^4^5^6^7^8^9"SET $PIECE(A,"^")="abc"WRITE !,"A=",AQUITA="abc^2^3^4^5^6^7^8^9"The following example uses $EXTRACT to replace the first character in A (again, a 1) withthe string "abc".StringExtractSET A="123456789"SET $EXTRACT(A)="abc"WRITE !,"A=",AQUITA="abc23456789"The following example replaces the third through sixth pieces of A with the string "abc" andreplaces the first character in the variable B with the string "abc".StringInsertSET A="1^2^3^4^5^6^7^8^9"SET B="123"SET ($PIECE(A,"^",3,6),$EXTRACT(B))="abc"WRITE !,"A=",A,!,"B=",BQUITA="1^2^abc^7^8^9"B="abc23"SET<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 133

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

Saved successfully!

Ooh no, something went wrong!