Step Two Open a database object
This step will connect to a database. The BDE accesses all tables through the context of a database. Single-tier applications will generally create an alias to a file system directory and utilize that as the database context. The function DbiOpenDatabase is used to open a database dbiREAOWRITE, dbiOPENSHAREO, nil, 0, nil, nil, hOB This sample function call opens the DBDEMOS database, assuming that it has been properly configured within the BDE. The second parameter, STANDARD in this case,...
Renaming a file
To change a file name, simply use the RenameFile function function RenameFile const OldFileName, NewFileName string Boolean which changes a file name, identified by OldFileName, to the name specified by NewFileName. If the operation succeeds, RenameFile returns True. If it cannot rename the file, for example, if a file called NewFileName already exists, it returns False. For example if not RenameFile lOLDNAME.TXT','NEWNAME.TXTl then ErrorMsg 'Error renaming file ' You cannot rename move a file...
MibToId
Determines the smaller of two Integer values. function Min AValueOne Integer AValueTwo Integer Integer Unit IdGlobal IE Parameters AValueOne Integer The first Integer value. AValueTwo Integer The second Integer value. Return Value Integer - The smaller of the two Integer values. Description Min is an Integer function used to determine the smaller of two Integer values. Min is provided to avoid any dependency on the Borland Math.pas unit. Converts an ordinal facility number to its...
Invoking Methods
Not only does the new extended RTTI lets you access values and fields, but it also provides a simplified way for calling methods. In this case you have to define a TValue element for each parameter of the method. There is a global Invoke function which you can call for executing a method function Invoke CodeAddress Pointer const Args TArray lt TVa1ue gt CallingConvention TCallConv AResultType PTypelnfo TValue As a better alternative, there is a simplified Invoke overloaded method in the
Meaning TXC
Used for Paradox or any database that allows spaces in field names. Databases like Access need this set to false. MS SQL Server has bit fields that map to ftBoolean in the VCL but then SQL must be generated as Integers eg. 0 or 1 . Interbase, Paradox and xBase using the BDE don't like international dates so this forces the server to receive US formatted dates. Access likes it's SQL statements to be terminated with semi-colons. Use this if you don't want to use single quotes in dates and...
Sending commands to the server
All database connection components except TIBDatabase let you execute SQL statements on the associated server by calling the Execute method. Although Execute can return a cursor when the statement is a SELECT statement, this use is not recommended. The preferred method for executing statements that return data is to use a dataset. The Execute method is very convenient for executing simple SQL statements that do not return any records. Such statements include Data Definition Language DDL...
Adding a new index
There are three ways to add indexes to a client dataset To create a temporary index at runtime that sorts the records in the client dataset, you can use the IndexFieldNames property. Specify field names, separated by semicolons. Ordering of field names in the list determines their order in the index. This is the least powerful method of adding indexes. You can't specify a descending or case-insensitive index, and the resulting indexes do not support grouping. These indexes do not persist when...
Order of Events
Now, compile the program and launch it with the Windows Run command. Resize it several ways. Watch the shape of the rectangle as you do the resizing. Careful observation reveals that if the form only shrinks, the shape of the rectangle does not change. If the form enlarges either horizontally or vertically or both, the shape of the rectangle changes appropriately. An expected event is not firing. This calls for further investigation. In the variable declaration section add So that an Event.Log...
Data Link Files
So a TADOConnection allows us to centralize the definition of a connection string within a form or data module. However, even though this is a worthwhile step forward from scattering the same connection string throughout all ADO datasets, it still suffers from a fundamental flaw If you use a database engine that defines the database in terms of a filename, then the path to the database file s is hard-coded in the EXE. This makes for a very fragile application. The BDE uses aliases to overcome...
LISTING DataGrid Declaration aspx
1 lt Page language c Debug true Codebehind WebForm1.pas Inherits WebForm1.TWebForm1 gt 3 lt DOCTYPE HTML PUBLIC - W3C DTD HTML 4.0 Transitional EN gt 4 8 lt meta name GENERATOR content Borland Package Library 7.1 gt 11 lt body 12 lt form runat server gt 13 lt asp datagrid id DataGrid1 14 style Z-INDEX 1 LEFT 6px POSITION absolute TOP 6px 15 runat server height 243 width 523px font-names Arial borderwidth 1px bordercolor Gray cellspacing 2 cellpadding 2 18 pagesize 5 allowpaging True gt 19 lt...
IntraWeb Support
IntraWeb is a sophisticated, RAD component-based Web development tool that automatically maintains server-side state between Web page requests. As a result, IntraWeb has advantages over ASP.NET for creating Web sites that require the type of state persistence typically associated with traditional client applications. There are a number of features that make IntraWeb an attractive alternative to ASP.NET Web site development. As mentioned previously, IntraWeb supports several convenient levels of...
Creating persistent fields
Persistent field components created with the Fields editor provide efficient, readable, and type-safe programmatic access to underlying data. Using persistent field components guarantees that each time your application runs, it always uses and displays the same columns, in the same order even if the physical structure of the underlying database has changed. Data-aware components and program code that rely on specific fields always work as expected. If a column on which a persistent field...
Defining new persistent fields
Besides making existing dataset fields into persistent fields, you can also create special persistent fields as additions to or replacements of the other persistent fields in a dataset. New persistent fields that you create are only for display purposes. The data they contain at runtime are not retained either because they already exist elsewhere in the database, or because they are temporary. The physical structure of the data underlying the dataset is not changed in any way. To create a new...
Navigating data in client datasets
If an application uses standard data-aware controls, then a user can navigate through a client dataset's records using the built-in behavior of those controls. You can also navigate programmatically through records using standard dataset methods such as First, Last, Next, and Prior. For more information about these methods, see Navigating datasets on page 16-8. Also inherited from TDataSet are the Locate and Lookup methods, which search for a particular record based on the values of specified...
Table A Paradox validity checks Validity check Meaning
Required field Every record in the table must have a value in this field. SQL tables can also use this validity check equivalent to NOT NULL . The values entered in this field must be equal to or greater than the minimum you specify here. The values entered in this field must be less than or equal to the maximum you specify here. The value you specify here is automatically entered in this field. You can replace it with another value. You specify a character string that acts as a template for...
Using implements for delegation
Many classes have properties that are subobjects. You can also use interfaces as property types. When a property is of an interface type or a class type that implements the methods of an interface you can use the keyword implements to specify that the methods of that interface are delegated to the object or interface reference which is the value of the property. The delegate only needs to provide implementation for the methods. It does not have to declare the interface support. The class...
What is the Borland Local InterBase Server
The Borland Local InterBase Server is a single-user Windows-based version of Borland's InterBase Workgroup Server, an SQL-compliant relational database management system RDBMS . The Local InterBase Server includes Windows ISQL and the Server Manager, a Windows tool that can be used with Local InterBase Server or a remote InterBase server. Using the Local Interbase Server, you can access local databases through Windows ISQL or through a SQL application program. Figure 1-1 shows the relationships...
Records on Steroids
Another relevant family of value types is represented by structures in C jargon, or records as they are called in Delphi. If records have always been part of the language, in this version they gain a lot of new ground as records can now have methods associated with them and even operators, as we'll see later on in this chapter . A record with methods is somewhat similar to a class the most relevant difference beside the lack of inheritance and polymorphisms is that record type variables use...
Dynamic Arrays
More often than not, when you are programming some routine that requires an array, you don't know how many elements you want in that array. It may be ten, one hundred, or a thousand, but certainly it's only at run time that you can come up with the answer. Furthermore, because you don't know, it's hard to declare the array as a local variable declaring the maximum size you may encounter might put strains on the stack, especially in Delphi 1 it certainly makes sense to allocate it on the heap....
Creating a VCL Forms ActiveX Active Form
Like a Delphi control, an ActiveX control generates program code when you place the component on a form or other logical container in the IDE. The main difference between an ActiveX control and a Delphi control is that an ActiveX control is language independent. You can create ActiveX controls for deployment to a variety of programming environments on Windows, not just Delphi or C Builder, for example. This procedure uses the VCL forms ActiveX Active Form wizard to create an Active Form...
Definition 3
The third component of light from a light source is specular light. Ambient light has been scattered from many surfaces and seems to come from all directions. Diffuse light comes from a specific direction the source, of course , but scatters from surfaces, giving a soft, flat appearance to surfaces. Ambient and Diffuse components of a light source commonly share the same color. Specular light is also directional, but much tighter in reflection than diffuse light, often with a different color....
Transaction attributes
Every transactional object has a transaction attribute that is recorded in the MTS catalog or that is registered with COM . Delphi lets you set the transaction attribute at design time using the Transactional Object wizard or the Type Library editor. Each transaction attribute can be set to these settings Objects must execute within the scope of a transaction. When a new object is created, its object context inherits the transaction from the context of the client. If the client does not have a...
Borland 7
.NET version of TeeChart Standard will be available at the Steema Web site at http www.steema.com . From the Win32 tab, all components appear in VCL for .NET. Missing from the System tab are OleContainer, DdeClientConv, DdeClientltem, DdeServerConv, and DdeServerltem components. Even the Win 3.1 tab from VCL is present in VCL for .NET, with the exception of the TDBLookupList and TDBLookupCombo components. Finally, the Dialogs tab is completely present in VCL for .NET. Based on these components,...
Adding actions to the dispatcher
Open the action editor from the Object Inspector by clicking the ellipsis on the Actions property of the dispatcher. Action items can be added to the dispatcher by clicking the Add button in the action editor. Add actions to the dispatcher to respond to different request methods or target URIs. You can set up your action items in a variety of ways. You can start with action items that preprocess requests, and end with a default action that checks whether the response is complete and either...
Deletion from a RedBlack Tree
Compared with insertion, deletion from a red-black tree is filled with special cases, and can be difficult to follow. As usual with binary search trees, we start off by searching for the node to be deleted. Like before, we'll have three initial cases the node has no children or, in red-black tree terms, both of its children are external nodes the node has one actual child and one external child and, finally, the node has two real children. We delete the node in exactly the same way as we did...
The DataSource Component TDataSource
The DataSource component is the pipeline between a dataset and the data-aware components. This intermediary component is required any time that data-aware components and dataset components are to be utilized on a form. The DataSource component requires a matching DataSet component in every case. The DataSource control also enables the linking of datasets in master-detail parent-child relationships. The DataSource component surfaces a limited number of published properties for use at design or...
function WSACancelBlockingCall Winsockpas
WSACancelBlockingCall integer Description This function cancels a blocking call that is in progress and any outstanding blocking operation for this thread. You would use this function in two cases In the first case, suppose our application is processing a message that has been received while a blocking call is in progress. In this case, WSAIsBlocking will be TRUE. In the second case, suppose that a blocking call is in progress, and Winsock has called back to the application's blocking hook...
Data Access functions
These functions perform data access operations on tables.
Creating an Active Server Object
An Active Server Object is an Automation object that has access to information about the entire ASP application and the HTTP messages it uses to communicate with browsers. It descends from TASPObject or TASPMTSObject which is in turn a descendant of TAutoObject , and supports Automation protocols, exposing itself for other applications or the script in the Active Server page to use. You create an Active Server Object using the Active Server Object wizard. Your Active Server Object project can...
Locate
This generic search method sets the current record to be the first row matching a specified set of search criteria. By using the Locate method we can look for values of one or more fields, passed in a variant array. The next code puts the Locate method to work finding the first record that contains the string 'Zoom' in the Name field. If the call to Locate returns True - the record is found and is set to be the current one. var ffield, fvalue string opts TLocateOptions ffield 'Name' fvalue...
Cleaning up the example
After completing this example, you will want to restore Delphi to its original form. 1 Delete the objects on this Servers page Choose Component Install Packages. From the list, select the WordExample package and click remove. Click Yes to the message box asking for confirmation. Exit the Install Packages dialog by clicking OK. 2 Return the Microsoft Office Automation Server Wrapper Components package Choose Component Install Packages. In the resulting dialog, choose dclaxserver70.bpl,...
Expression Types
Every built-in assembler expression has a typeor, more correctly, a size, because the assembler regards the type of an expression simply as the size of its memory location. For example, the type of an Integer variable is four, because it occupies 4 bytes. The built-in assembler performs type checking whenever possible, so in the instructions the assembler checks that the size of QuitFlag is one a byte , and that the size of OutBufPtr is two a word . The instruction produces an error because DL...
TldMailBoxCreate
Constructor for the object instance. constructor Create AOwner TComponent override Parameters AOwner TComponent Owner of the object instance. Description Create is the Constructor for the object instance, and relies on the inherited Create method to initialize properties. Create also initializes the TldMessageCollection instance used in the MessageList propertie, using TldMessageltem C as the collection item class. Create calls Clear C to insure that other properties in the instance are reset...
FirstUnseenMsg [C
. ChangeableFlags C - empty set Clear also removes the contents of the DeleteMsgs, SearchResult, and MessageList C container properties. See Also TldlMAP4 C , TIdMailBoxAttributes C , TIdMessageFlagsSet C , TIdMessageFlagsSet C , TldMessageCollection C , TldMailBoxState C
function WSALookupServiceNext Unit Winsockpas
WSALookupServiceNext hLookup HANDLE dwControlFlags DWORD var lpdwBufferLength DWORD lpqsResults LPWSAQUERYSETW Integer stdcall We call this function with the hLookup parameter assigned by a previous call to WSALookupServiceBegin to retrieve the requested service information. The provider will pass back a pointer to the WSAQUERYSET record in the lpqs-Results buffer. The client should continue to call this function until it returns WSA_E_NO_MORE, indicating that all of the WSAQUERYSET records...
Form Constraints
When you choose a resizable border for a form, users can generally resize the form as they like and also maximize it to full screen. Windows informs you that the form's size has changed with the wm_Size message, which generates the OnResize event. OnResize takes place after the size of the form has already been changed. Modifying the size again in this event if the user has reduced or enlarged the form too much would be silly. A preventive approach is better suited to this problem. Delphi...
IdCookieU TIdNetscapeCookie Members Properties
ClientCookie Represents the Cookie name and value. Represents the textual representation for a Cookie including attribute Indicates the life time of the Cookie. Secure Indicates the Cookie requires a secure communications channel. Value Represents persistent state data associated with a Cookie name. Methods Copies property values to the current object instance. Represents the identity for a Cookie header. Indicates the host system where a Cookie is valid. Path Specifies the subset of URLs valid...
LISTING webconfig File Schema
lt configuration gt lt location gt lt authentication gt lt forms gt lt credentials gt lt passport gt lt authorization gt lt allow gt lt deny gt lt browserCaps gt lt result gt lt use gt lt filter gt lt case gt lt clientTarget gt lt add gt lt remove gt lt clear gt lt compilation gt lt compilers gt lt compiler gt lt assemblies gt lt add gt lt remove gt lt clear gt lt customErrors gt lt error gt lt globalization gt lt httpHandlers gt lt httpRuntime gt lt identity gt lt machineKey gt lt pages gt lt...
function lineConfigDialogEdit TAPlpas
function lineConfigDialogEdit dwDeviceID DWORD hwndOwner HWND lpszDeviceClass LPCSTR IpDeviceConfigIn Pointer dwSize DWORD IpDeviceConfigOut PVarString Longint stdcall This function causes the provider of the specified line device to display a dialog box attached to hwndOwner of the application that allows the user to configure parameters related to the line device. dwDeviceID A DWORD holding the line device to be configured
end 21
Now while these actions can be activated using the shortcut commands, the program has no menu to execute them, but the form adds gesture support, connecting three gestures to the actions, as you can see in the image of the Object Inspector here on the right. To have a clearer view of the actions connected to the active gestures for a control, what you can do is copy the properties of the GestureManager component, which will list the gestures binding for each control connected to it in this case...
Building a Value Replacer for UCSChar
Before we delve into the development of a debugger visualizer, let me point you to a specific situation in which the debugger provides limited information about the values of a type. Consider the following code snippet, which is part of the DebugVisual example which is also used to demonstrate the other debugger visualizers. procedure TForm39.btnUcs4CharClick Sender TObject var ShowMessage Character.ConvertFromUtf32 ch end If you put a breakpoint in the code above and look to the value of ch,...
The webconfig File
The web.config file, like the machine.config file, holds specific settings that apply to a specific ASP.NET application. You can also add your own settings to this file that would be needed by the application, such as database connection strings. In a sense, you can think of the web.config file as you would an .ini file. The web.config file is nowhere as wieldy as the machine.config file. The schema for the web.config file is shown in Listing 32.1 with the main sections in bold font.
Assemblies
The System .Reflection.Assembly class is important in much the same way as the Type class. Static Assembly methods load assemblies into the current application domain, and return an Assembly instance that describes the loaded assembly. An Assembly instance gives you access to the assembly's types and the assembly's resources. There are also static methods that reveal occasionally invaluable bits of information about the call stack, like GetExecutingAssembly, which returns the Assembly that...
String Immutability in NET
What exactly is meant by strings being immutable It means that once you instantiate a String type, you cannot change its value. This is not saying that the following code will fail procedure TWinForm.Button1_Click sender System.Object e System.EventArgs var s 'Classic Cars' s s.ToUpper s s.ToLower end It is saying that the preceding code requires two string instances or memory allocations even though they both are being referred to by the same variable. Consider the IL code generated for the...
Binary Search Tree Rearrangements
When discussing the binary search tree, I stated that adding items to a binary tree could make it woefully unbalanced, sometimes even degenerating into a long spindly tree like a linked list. The problem with this degeneration is not that the binary search tree stops functioning properly items are still being stored in sorted order , it's that the tree's good efficiency takes a fatal knock if it happens. For a perfectly balanced tree on average, all parent nodes have two children, and all...
Creating and Deleting Directories
The following code shows how to create a directory using the Directoryinfo class dirlnfo DirectoryInfo.Create 'c ddgtemp' if not dirlnfo.Exists then dirlnfo. amp Create First, an instance of Directoryinfo is created and assigned to the variable dirinfo. By passing a valid path to the Create constructor, you are associating that directory with the Directoryinfo object however, you are not creating the directory. To actually create the directory, you must call the Create method. Also, note the...
Disconnecting from a database server
There are two ways to disconnect a server using a connection component Set the Connected property to False. Call the Close method. Calling Close sets Connected to False. When Connected is set to False, the connection component generates a BeforeDisconnect event, where you can perform any cleanup before the connection closes. For example, you can use this event to cache information about all open datasets before they are closed. After the BeforeConnect event, the connection component closes all...
Mapping between XML nodes and data packet fields
XML provides a text-based way to store or describe structured data. Datasets provide another way to store and describe structured data. To convert an XML document into a dataset, therefore, you must identify the correspondences between the nodes in an XML document and the fields in a dataset. Consider, for example, an XML document that represents a set of email messages. It might look like the following containing a single message lt xml version 1.0 standalone yes gt lt email gt lt head gt lt...
end until iVl end
The running time of this program is dominated by the time spent processing edges in the priority queue. Suppose that the graph consists of two clusters of vertices all connected together by very short edges, and only one edge which is very long connecting the two clusters. Then the longest edge in the graph is in the minimum spanning tree, but it will be the last edge out of the priority queue. This shows that the running time could be proportional to ElogE in the worst case, although we might...
Procedure Declarations
A procedure declaration has the form procedure procedureName parameterList directives result to I. Function calls cannot appear on the left side of an assignment syntax is enabled x , function calls - can be used as complete where procedureName is any valid identifier, statements is a sequence of statements that execute when the procedure is called, and parameterList , directives , and localDeclarations are optional. Here is an example of a procedure declaration Given this declaration, you can...







