Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Streams and Visual Basic<br />
15.4 Streams and Visual Basic<br />
To make it easy to use streams efficiently within Visual Basic applications, the <strong>Caché</strong> ActiveX<br />
Binding projects stream properties using two special ActiveX stream objects:<br />
CacheActiveX.CharStream and CacheActiveX.BinaryStream. From your Visual Basic application<br />
you simply make calls to the methods provided by these objects.<br />
For example, suppose you have a Person object containing a character stream property, Memo.<br />
In addition to the standard stream methods Read and Write, you can use the client-side<br />
method Data, which will fetch the entire stream in one operation:<br />
' Visual Basic code<br />
Dim person As Object<br />
Dim memo As String1<br />
' Open a Person object and copy its memo into a local variable<br />
Set person=Factory.OpenId(id)<br />
memo=person.Memo.Data<br />
The GetPicture method is a similar mechanism that efficiently copies binary data containing<br />
a bitmap image into a picture control. For example, if the Person object has a binary stream<br />
property, Picture, containing a bitmap image (such as a .jpg or .png file), you can display this<br />
image in Visual Basic as follows:<br />
' Visual Basic code<br />
Dim person As Object<br />
Dim memo As String<br />
' Open a Person object and show its picture in an Image control<br />
Set person=Factory.OpenId(id)<br />
Image1.Picture = person.Picture.GetPicture<br />
The SetPicture method can be used to copy an image in the other direction, from an Image<br />
control to a binary stream property:<br />
' Visual Basic code<br />
person.Picture.SetPicture Image1.Picture<br />
<strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong> 139