Delphi is a brand-new visual programming environment that provides us with a convenient and fast Windows application development tool.
The following are two practical experiences in Delphi programming that I hope to share with you:
1. Text link markup language (HTML) . Using the opening method in Windows (such as IE, etc.) to access HTML files is too restricted by the system and is not flexible enough. Delphi provides the THTML control, which can call HTML files, but its properties do not explain in detail how to call native HTML files. In fact, this function can be accomplished as long as the correct URL format is used. The format is as follows:
file:∥<host>/<path>
For example: If there is an HTML file with the path C:HelpHome??Htm; then its correct URL format should be: file:∥C:HelpHome??htm. Therefore, calling the HTML file for control HTML1 should be: HTML1??RequestDoc(file:∥c:HelpHome??Htm). In this way, you can write a program yourself to call HTML files to form an independent help file system.
2. Use SQL to implement fuzzy query of field data . An important symbol of Delphi as a powerful database application development tool is that it supports SQL programming. In the actual process, it is often necessary to perform fuzzy queries on certain fields. For example, when querying the "Name" field, when "Wang" is entered, all records with the surname Wang can be automatically listed. In fact, this function can be easily accomplished by combining the features of SQL and Delphi. The basic principle is: when querying, control the scope of the query to be between names greater than 'query string + chr (0)' and less than 'query string + chr ($ff)', and all records that meet the conditions can be queried. . Here are specific examples:
Var
NameStr:String;∥Set string intermediate variable
Begin
NameStr:='王';
Query1??SQL??Clear{Clear the SQL command statement in the SQL attribute}
Query1??SQL??Add(′Select*FromCustom??dbwhere(Name1>=N1)and(Name2<=N2)′);∥SQL command statement
Query1??params[0]??AsString:=NameStr+chr(0);∥The control parameter is in NameStr+Chr(0)
Query1??params[1]??AsString:=NameStr+chr($ff); between ∥ and NameStr+Chr($ff)
Query1??Open;∥Open the database and execute SQL query
End;