delpjihlplibは上記のリンクから最新のモジュールをダウンロードして
パッケージをインストールすることで使用可能になります。
以下試したソースコード
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls;
- type
- TForm1 = class(TForm)
- Button1: TButton;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- procedure Button1Click(Sender: TObject);
- private
- { Private 宣言 }
- public
- { Public 宣言 }
- end;
- var
- Form1: TForm1;
- implementation
- Uses DeHL.Nullable;
- {$R *.dfm}
- procedure TForm1.Button1Click(Sender: TObject);
- var
- i : Nullable <integer>
- begin
- //値を代入する前はNULL
- if i.IsNull then
- begin
- Label1.Caption := 'Null';
- end;
- //値を代入すると普通の型のように扱える
- i.Value := 100;
- Label2.Caption := IntToStr(i);
- //MakeNullでNullをセットできるようだ。
- i.MakeNull;
- if i.IsNull then
- begin
- Label3.Caption := 'Null';
- end;
- end;
- end.
delphihelplibには、そのほかにもいろいろなクラスがあるようなので、追々試してみようと思う。