![]() |
Check if instance exist?
Hi,
In delphi, how do i check if a instance of a class has already been created or not? Something like this in VB:
Delphi-Quellcode:
I want to check if the Fo_FtpClient has already been created or not: Here is my code:
If (FtpClient Is Nothing) Then
Return End If
Delphi-Quellcode:
Then before creating it again in the onclick event, i first want to check if it doesnt already exist:
unit u_fdn_FTP_Dot_Net;
interface uses System.Net, System.Net.Sockets, System.Text, System.IO, Borland.Vcl.Classes, Borland.Vcl.StrUtils, Borland.Vcl.SysUtils, Borland.Vcl.Dialogs, TKFP.IO, TKFP.Net; type TFtp_Dot_Net = class(TObject) private [b]Fo_FtpClient : TKFP.Net.FtpClient;[/b]
Delphi-Quellcode:
Fo_FtpClient := FtpClient.Create(oLogon,Address,21);
|
Re: Check if instance exist?
hi
Delphi-Quellcode:
Assigned tests if the function is nil or not.
if not Assigned(Class) then
Class.Create(Param): hope this helpts. |
Re: Check if instance exist?
Zitat:
|
DP-Maintenance
Dieses Thema wurde von "Matze" von "Programmieren allgemein" nach "Object-Pascal / Delphi-Language" verschoben.
Delphi question |
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:44 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz