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.

System and Other Functions$ZPOSITION adds the widths of the characters in the expression one at a time until thecumulative width equals the value of field or until there are no more characters in expression.The result is thus the number of characters that will fit within the specified field valueincluding any fractional part of a character that would not completely fit.Note:$ZPOSITION can be abbreviated as $ZP in DSM-J mode. This abbreviation cannotbe used in <strong>Caché</strong> mode.ExamplesIn the following example, assume that the variable string contains two half-width charactersfollowed by a full-width character.WRITE $ZPOSITION(string,3,1.5)returns 2.6666666666666666667.In the above example, the first two characters in string fit in the specified field width withone left over. The third character in string, a full-width character with a width of 1.5 (determinedby the pitch argument), would not completely fit, although two thirds (1/1.5) of thecharacter would fit. The fractional part of the result indicates that fact.In the following example, string is now a string that contains a full-width character followedby two half-width characters. The result returned is 2.5:WRITE $ZPOSITION(string,3,1.5)The results are now different. This is because the first two characters, which have a combinedwidth of 2.5, would completely fit with .5 left over. Even so, only half of the third character(.5/1) would fit.Finally, if string is a string that contains three half-width characters then all three characterswould completely (and exactly) fit, and the result would be 3:WRITE $ZPOSITION(string,3,1.5)Note:Full-width characters are determined by examining the pattern-match table loadedfor your <strong>Caché</strong> process. Any character with the full-width attribute is considered tobe a full-width character. The special ZFWCHARZ patcode can be used to checkfor this attribute (for example, char?1ZFWCHARZ). See the description of the $X/$YTab in Customized National Language Translations for more information about thefull-width attribute.554 <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!