Hello,
I have the following code. When connected to Google drive I search for the folder "MyFolder1" and I store the folder in the CloudItemFolder1 variable (using the OnSearch event).
It goes on the 1.st option. This works properly:
var
CloudItemFolder1 : TTMSFNCCloudItem;
CloudItemFolder2 : TTMSFNCCloudItem;
...
...
Class Procedure TTMSFNCCloudGoogleDriveService.EOnConnected(Sender: TObject);
begin
HowToSearch := 1;
f_CloudGoogleDrive.SearchFolder('MyFolder1',True) ;
end;
Class Procedure TTMSFNCCloudGoogleDriveService.EOnSearch(Sender: TObject;const ASearchResults: TTMSFNCCloudGoogleDriveItems;const ARequestResult: TTMSFNCCloudBaseRequestResult);
begin
case HowToSearch of
1:
Begin
CloudItemFolder1 :=ASearchResults.Items[0] ;
End;
2:
Begin
If ASearchResults.Count=0 Then //
Begin
CloudItemFolder2 :=ASearchResults.Items[0] ;
End;
End;
end;
end;
After the OnSearch the CloudItemFolder1 variable is set properly, pointing at the respective folder.
However when I click on a button and I call this, to search for MyFolder2:
Class Procedure TTMSFNCCloudGoogleDriveService.SecondFolder;
Begin
HowToSearch := 2;
f_CloudGoogleDrive.SearchFolder('MyFolder2',True) ;
End;
... and this calls the EOnSearch again:
Class Procedure TTMSFNCCloudGoogleDriveService.EOnSearch(Sender: TObject;const ASearchResults: TTMSFNCCloudGoogleDriveItems;const ARequestResult: TTMSFNCCloudBaseRequestResult);
begin
case HowToSearch of <- HERE ALREADY CloudItemFolder1 became NIL
...
How can it be that getting in the OnSearch the second time causes the previously set TTMSFNCCloudItem to become NIL?
My goal is to keep the most important folders "ready" in variables for the program user, so when he chooses to upload a file, I can immediately do so.
The code above would run only once, when the app starts.
Thank you for your help!