Atozed Forums
lambda functions with classic 32 bit Borland compiler ? - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: lambda functions with classic 32 bit Borland compiler ? (/thread-1194.html)

Pages: 1 2


RE: lambda functions with classic 32 bit Borland compiler ? - JuergenS - 09-14-2019

Thanks for the example, I will give it a try.

Best Regards
Juergen


RE: lambda functions with classic 32 bit Borland compiler ? - MJS@mjs.us - 09-15-2019

Another option for anonymous function callbacks:


//Sample callback structure to pass/fill variables
//---------------------------------------------------------------------------
struct LookUpStruct
{
String *rip,*sts,*lac,*tid,*bnm;

LookUpStruct(String *_rip, String *_sts, String *_lac, String *_tid, String *_bnm) : rip(_rip),sts(_sts),lac(_lac),tid(_tid),bnm(_bnm) { };

void operator()(System::TObject* obj)
{
TIWApplication *ASession = (TIWApplication *)obj;
*rip = ((TIWUserSession*)ASession->Data)->realIP;
*sts = ASession->SessionTimeStamp.FormatString("yyyy-mm-dd hh:nnConfuseds");
*lac = ASession->LastAccess.FormatString("yyyy-mm-dd hh:nnConfuseds");
*tid = IntToStr(ASession->TrackID);
*bnm = ASession->Browser->BrowserName;
}
};
//---------------------------------------------------------------------------
typedef TMethodRef<Iwlfsessionlist::TSessionProc,LookUpStruct,void,System::TObject* > _LookUpStruct;
//---------------------------------------------------------------------------

//Sample callback struct usage
//---------------------------------------------------------------------------
void __fastcall TMJForm::btnRefreshAsyncClick(TObject *Sender, TStringList *EventParams)
{
auto_ptr<TStringList> sl(new TStringList);
gSessions->GetList(sl.get());

String ip,sts,lac,tid,bnm;

for(int i=0;i<sl->Count;i++) {
gSessions->LookUp(sl->Strings[i],new _LookUpStruct(LookUpStruct(&ip,&sts,&lac,&tid,&bnm)));
...
}
}


RE: lambda functions with classic 32 bit Borland compiler ? - JuergenS - 09-16-2019

I've tried the other example by now and it works fine, but this example is actually closest to what I need.

Thank you for your help
Juergen


RE: lambda functions with classic 32 bit Borland compiler ? - JuergenS - 09-17-2019

I changed everything according to the last example and it works fine.

Thanks again for your help.
Juergen


RE: lambda functions with classic 32 bit Borland compiler ? - kudzu - 09-17-2019

Thanks for the follow up.