4. Truncate method
The method is implemented by invoking the BDE API function. It is implemented as follows:
Procedure Tblobstream.truncate;
Begin
If Fopened Then
Begin
Check (Dbitruncateblob (Fdataset.handle, Frecord, Ffieldno, fposition));
Fmodified: = True;
End
End
This method deletes all data from the current position of the Blob stream and sets the Modify flag fmodified to True. Many parts in Delphi VCL, especially database applications, use the BDE API function to complete access to the database, such as data access and data control parts. Various database parts are BDE API functions the outer wrapper simplifies access to the database. The BDE API also provides functional support for bypassing the BDE Configuration tool to directly process the alias (build, modify, delete, and so on) in the program, which is not provided by the part. In the Delphi database application setup program, these alias operation functions are undoubtedly very important. For a detailed description of the BDE API functions, you can read the BDE API help file with the Delphi2.0 client/server suite.
Realization principle and application of 20.2 read-write Object
Read-Write objects (Filer) include Tfiler objects, Treader objects, and Twriter objects. The Tfiler object is the underlying object of file reading and writing, and is used primarily in Treader and twriter applications. Both Treader and Twriter objects are inherited directly from the Tfiler object. The Tfiler object defines the basic properties and methods of the Filer object.
The Filer object mainly accomplishes two major functions:
Accessing parts in form files and form files
Provides data buffering to speed data read and write operations
20.2.1 Tfiler Object
The Tfiler object is an abstract class of Treader and Twriter that defines the basic properties and methods used for part storage. It defines the root attribute, and root indicates the roots of the part being read or written, and its create method takes the stream object as an incoming parameter to establish a connection to the stream object, and the Filer object's specific read and write operations are done by the stream object. Therefore, as long as the stream object can access the media can be accessed by the Filer object parts. The Tfiler object also provides two methods for defining properties: DefineProperty and Definebinaryproperty, which enable the object to read and write properties that are not defined in the part published section.
Because the Filer object is mainly used to access the parts of the Delphi form file and the form file, it is necessary to clearly understand the structure of the Delphi form file (DFM file) for a clear understanding of the Filer object.
DFM files are used to store forms for Delphi. The form is the core of Delphi visual programming. The form corresponds to a window in the Delphi application, a visual part of the form corresponding to the interface elements in the window, and non-visual parts such as ttable and Topendialog, corresponding to a function of the Delphi application. The design of the Delphi application is actually centered on the design of the form. Therefore, the DFM file in the Delphi application design also occupies a very important position. All the elements in a form, including the properties of the form itself, are included in the DFM file.
In the Delphi application window, the interface elements are interconnected by owning relationships, so the tree structure is the most natural form of expression; Accordingly, the parts in the form are organized in a tree structure, and the relationship is expressed in the DFM file. The DFM file is physically stored in binary mode, and logically it is a tree-like structure to arrange the relationship of the components. The Delphi editing window supports the display of DFM files in text format. From this text, you can see the tree structure of the form. The following is the text display of the DFM file:
Object Form1:tform1
Left = 72
top = 77
ActiveControl = DBIMage1
...
Object Panell:tpanel
left = 6
...
Object Dblabel1:tdbtext
...
End
Object Dbimage1:tdbimage
...
End
End
Object Panel2:tpanel
left = 6
...
Object label1:tlable
...
End
End
Object Panel3:tpanel
left = 6
...
Object Dblabel2:tdbtext
...
End
End
End
For rules that store property values in the DFM file, see Customizing the chapter on part development.
Controls the properties of the Tfiler object. The root property represents the roots of the part tree--the form. Many of the methods for filer objects are all parts of the tree that are read from the root. The Ancestor property represents the ancestor object of the root, and the Ignorechildren property is the child node of the root that is ignored when the part is read.
The properties and methods of the Filer object are described below.