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.

System and Other Functionstypedef struct zarray {unsigned short len;unsigned char data[1]; /* 1 is a dummy value */} *ZARRAYP;This is also the structure used for the b (or B) argument type.The following $ZF sample function performs a round trip conversion:#include cdzf.hextern int trantest();ZFBEGINZFENTRY("TRANTEST","t/SJIS/ T/SJIS/",trantest)ZFENDint trantest(inbuf,outbuf);ZARRAYP inbuf;/* Buffer containing string that was converted frominternal <strong>Caché</strong> encoding to SJIS encoding before itwas passed to this function */ZARRAYP outbuf; /* Buffer containing string in SJIS encoding that willbe converted back to internal <strong>Caché</strong> encoding beforeit is passed back into the <strong>Caché</strong> environment */{int i;/* Copy data one byte at a time from the input argument bufferto the output argument buffer */for (i = 0; i < inbuf->len; i++)outbuf->data[i] = inbuf->data[i];/* Set number of bytes of data in the output argument buffer */outbuf->len = inbuf->len;}return 0; /* Return success */Note:Conceptually speaking, data flows to and from a $ZF external procedure, as if theexternal procedure were a device. The output component of an I/O translation is usedfor data that is passed to an external procedure because the data is “leaving” the<strong>Caché</strong> environment. The input component of an I/O translation is used for data thatis received from an external procedure because the data is “entering” the <strong>Caché</strong>environment.If the output component of an I/O translation is undefined and your application attempts topass anything but the null string using that I/O translation, <strong>Caché</strong> issues an error, because itdoes not know how to translate the data.If the input component of an I/O translation is undefined and an argument of type stringassociates that I/O translation with a $ZF output argument, <strong>Caché</strong> issues an error, becausean output argument with an undefined translation is purposeless.532 <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!