Smarter Records in Turbo Delphi / Delphi 2006
type
TTurboRecord = record
strict private
fNameValue : integer;
function GetName: string;
public
NamePrefix : string;
constructor Create(const initNameValue : integer) ;
property Name : string read GetName;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
constructor TTurboRecord.Create(const initNameValue : integer) ;
begin
fNameValue := initNameValue;
NamePrefix := '"record constructor"';
end;
function TTurboRecord.GetName: string;
begin
Inc(fNameValue) ;
result := Format('%s %d',[NamePrefix, fNameValue]) ;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
turboRecord : TTurboRecord;
anotherTurboRecord : TTurboRecord;
begin
//no Constructor needed - fNameValue = 0 by default
turboRecord.NamePrefix := 'turboRecord';
Memo1.Lines.Add(turboRecord.Name) ;
Memo1.Lines.Add(turboRecord.Name) ;
//constructor used
turboRecord := TTurboRecord.Create(2006) ;
Memo1.Lines.Add(turboRecord.Name) ;
Memo1.Lines.Add(turboRecord.Name) ;
anotherTurboRecord := turboRecord;
anotherTurboRecord.NamePrefix := 'anotherTurboRecord';
Memo1.Lines.Add(anotherTurboRecord.Name) ;
Memo1.Lines.Add(anotherTurboRecord.Name) ;
Memo1.Lines.Add(turboRecord.Name) ;
Memo1.Lines.Add(turboRecord.Name) ;
//NO need to FREE record types
end;
Records can have constructor, with at least one parameter.
Records support properties and static methods.
Records support operator overloading.
Records can have methods (functions, procedures).
Records do NOT support virtual methods ("virtual", "dynamic", and "message")
Records do NOT support destructors.
Ïà¹ØÎĵµ£º
ÓÃDelphi×÷µÄ³ÌÐòµÄÔ´´úÂëÖг£¼ûµÄÎļþÀ©Õ¹Ãû£¬²¢¸ø³öÁËÕâЩÎļþÀ©Õ¹ÃûµÄÒâÒ壬ÒÔ±ãÔ´´úÂë¹ÜÀíʱ×÷Ϊ²ÎÕÕ£¬À©Õ¹ÃûÒÔ×ÖĸΪÐò£¨²»ÐèÒª½øÔ´´úÂë¿â²»±íʾ²»ÐèÒª½ø¿â£©¡£
¡¡¡¡~*
¡¡¡¡DelphiÉú³ÉµÄ±¸·ÝÎļþ£¬ÔÚ°æ±¾¿ØÖƿ⼰·¢²¼´úÂëÖв»Ó¦¸Ã³öÏÖÕâЩÎļþ£¬Èç¹ûÐÞ¸ÄÁËij¸öÎļþÈ´ÒòijЩÔÒòûÓб£´æµÄ»°£¬¿ÉÒÔ³¢ÊÔʹÓÃÕâЩÎļþ» ......
TStringsÊÇÒ»¸ö³éÏóÀ࣬ÔÚʵ¼Ê¿ª·¢ÖУ¬ÊdzýÁË»ù±¾ÀàÐÍÍ⣬ӦÓõÃ×î¶àµÄ¡£
³£¹æµÄÓ÷¨´ó¼Ò¶¼ÖªµÀ£¬ÏÖÔÚÀ´ÌÖÂÛËüµÄһЩ¸ß¼¶µÄÓ÷¨¡£
ÏȰÑÒªÌÖÂ۵öÊôÐÔÁгöÀ´£º
1¡¢CommaText
2¡¢Delimiter & DelimitedText
3¡¢Names & Values & ValuefromIndex
ÏÈ¿´µÚÒ»¸ö£ºCommaText¡£ÔõôÓÃÄØ£¿ÓôúÂë˵»°£º
const
......
½áºÏDelphi
¿Í»§¶Ë×ÀÃæ¿ª·¢µÄÓÅÊÆºÍJavaµÄÎȽ¡Ç¿×³ÌØÐÔ£¬²ÉÓÃDelphi
Client + Java ServerµÄϵͳ¼Ü¹¹Ó¦¸ÃÊǺÜÓÐÊг¡µÄ£¬¾¹ýÒ»¶Îʱ¼äµÄʵ¼ÊÏîĿʵ¼ù£¬ÊµÏּܹ¹ÊÇÕâôʵÏֵ쬹©ÌÖÂÛ£º
1.ºǫ́ӦÓ÷þÎñ²ã¿É²ÉÓûùÓÚSpring+HibernateµÄÇáÁ¿¼¶J2EEʵÏÖ£¬²¢Ê¹ÓÃApache XML-RPC
Ìṩ¿Í»§¶Ëµ÷Óýӿڣ»
2.ǰ̨²ÉÓà Delphi
......
ö¾ÙÀàÐÍ
¡¡¡¡Pascal³ÌÐò²»½öÓÃÓÚÊýÖµ´¦Àí£¬»¹¸ü¹ã·ºµØÓÃÓÚ´¦Àí·ÇÊýÖµµÄÊý¾Ý¡£ÀýÈ磬ÐÔ±ð¡¢Ô·ݡ¢ÐÇÆÚ¼¸¡¢ÑÕÉ«¡¢µ¥Î»Ãû¡¢Ñ§Àú¡¢Ö°ÒµµÈ¡£
1¡¢Ã¶¾ÙÀàÐ͵͍Òå
¸ñʽ:¡¡type ö¾ÙÀàÐͱêʶ·û=(±êʶ·û1,±êʶ·û2,…,±êʶ·ûn)
2¡¢Ã¶¾ÙÀàÐÍÊý¾ÝÌØµã
¢Ù ö¾ÙÔªËØÖ»ÄÜÊDZêʶ·û£»
ÀýÈ磬ÏÂÁÐÀàÐͶ¨ÒåÊǺϷ¨µÄ£º
¡¡¡¡ type ......
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
......