I have to add a REST service to an android app I've created so I've opened the project and then I did File > New > Other > Data Module. Inside the data module there are the REST components so I separate UI logic from code logic.
I have to add a REST service to an android app I've created so I've opened the project and then I did File > New > Other > Data Module. Inside the data module there are the REST components so I separate UI logic from code logic.
In Project > Options the data module IS in the Auto-create form part. Inside the TForm1.FormCreate procedure I have written:
//the data module is called DataModuleF1
//declared as TDataModuleF1 = class(TDataModule)
if not Assigned(DataModuleF1) then
DataModuleF1 := TDataModuleF1.Create(Application);
DataModuleF1.DoSomething;
If the data module is in Auto-create, why I have to write the if cond? I mean, if I removed the if statement I would get an error. Is the creation with the constructor needed even if it's auto created in the project properties?
Of course withoud the call to "DataModuleF1.DoSomething;" I won't have to use the if. Thank you!
In Project > Options the data module IS in the Auto-create form part. Inside the TForm1.FormCreate procedure I have written:
//the data module is called DataModuleF1
//declared as TDataModuleF1 = class(TDataModule)
if not Assigned(DataModuleF1) then
DataModuleF1 := TDataModuleF1.Create(Application);
DataModuleF1.DoSomething;
If the data module is in Auto-create, why I have to write the if cond? I mean, if I removed the if statement I would get an error. Is the creation with the constructor needed even if it's auto created in the project properties?
Of course withoud the call to "DataModuleF1.DoSomething;" I won't have to use the if. Thank you!
Make sure the line in the DPR file that creates the datamodule comes before the line that creates the form.
ReplyDelete