RE: How to define the expression to check if a big char st ring contai ns small char string

From: Fine, Valeri <fine_at_bnl.gov>
Date: Fri, 30 Nov 2007 01:05:57 -0500


> we cannot access the variables of gHaCuts like this.
> This does not work.

May be. i have not seen you code yet.  

I though what you want to do can be done like this:  

THaVarList * gHaVars = new THaVarList();

    THaCutList * gHaCuts = new THaCutList(gHaVars);     const char* listClients="ABCD,EFGH,HIJK,NEWONE,JUNK,DONE";     const char* ordClient = "DONE";
    gHaVars->Define("listClients",listClients);     gHaVars->Define("ordClient",ordClient);     if (strstr(listClients,ordClient))

       gHaCuts->Define("Expr","((size < 1000) && (vol < (0.001 * ADV)) && (prod == value) )");     else

       gHaCuts->Define("Expr","0");    

Best regards, Valeri


From: owner-roottalk_at_root.cern.ch on behalf of Borse, Ganesh Sent: Thu 11/29/2007 10:47 PM
To: Fine, Valeri; roottalk_at_root.cern.ch
Subject: RE: [ROOT] How to define the expression to check if a big char st ring contai ns small char string

we cannot access the variables of gHaCuts like this. This does not work.

-----Original Message-----
From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch] On Behalf Of Fine, Valeri Sent: 30 November 2007 02:35
To: roottalk_at_root.cern.ch
Subject: FW: [ROOT] How to define the expression to check if a big char string contai ns small char string

The message is correct. I believe your method "Define" has no idea those listClients, ordClient are defined as the variables within the scope of another method.

Try something like this:

gHaCuts->Define("Expr",Form("((size < 1000) && (vol < (0.001 * ADV)) &&
gHaCuts->(prod == value) && strstr(\"%s\",\"%s\") )",
gHaCuts->listClients,ordClient));

Best Regards
                         Valeri Fine


Brookhaven National Laboratory
Upton, NY 11973, USA
Phone: +1 631 344 7806
Fax: +1 631 344 4206
E-mail: fine_at_bnl.gov
-----Original Message-----
From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch] On Behalf Of Borse, Ganesh Sent: Wednesday, November 28, 2007 11:05 PM To: 'roottalk_at_lxbuild091.cern.ch'
Subject: [ROOT] How to define the expression to check if a big char string contai ns small char string

Hi,
I am trying to "Define" an expression to check whether a long char string contains another small char string. For this, I am using strstr() library function in C++. Expression is like this:

    THaVarList * gHaVars = new THaVarList();     THaCutList * gHaCuts = new THaCutList(gHaVars);     const char* listClients="ABCD,EFGH,HIJK,NEWONE,JUNK,DONE";     const char* ordClient = "DONE";

    gHaVars->Define("listClients",listClients);
    gHaVars->Define("ordClient",ordClient);
    gHaCuts->Define("Expr","((size < 1000) && (vol < (0.001 * ADV)) && (prod == value) && strstr(listClients,ordClient) )"); Program compiles fine, but when I run this program, the Define() function call fails with an error message:
Error in <THaCut::Compile>: strstr requires 2 string arguments Error in <THaCutList::Define>: expression error, cut not created: Expr ((size < 1000) && (vol < (0.001 * ADV)) && (prod == value) && strstr((listClients),(ordClient)) ) block: Default I have given the correct number & type of input parameters to strstr, but then why is the "::Compile" still failing? How can we achieve this type of checks?
Please help.
Thanks and Regards,
Ganesh

Please access the attached hyperlink for an important electronic communications disclaimer:

http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html




Please access the attached hyperlink for an important electronic communications disclaimer:

http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html


Received on Fri Nov 30 2007 - 07:09:01 CET

This archive was generated by hypermail 2.2.0 : Fri Nov 30 2007 - 11:50:01 CET