Hi,
It could be possible that the Compile function is resolving this to the Tformula version of strstr. But I want to use the normal C++ version - which is declared in <string.h>
Yes, I making it aware to the formula about these 'variables'. If you see my code below, before calling the Define function, I cam doing "gHaVars->Define("listClients",listClients);" & "gHaVars->Define("ordClient",ordClient);"
This defines these variables.
I think this is the problem of ambiguity between the OS strstr & Tformula strstr. How do we rsolve it? Should I define one cut for strstr & add it here? I just now emailed my test program. May be some more information could be found from it.
Thanks,
Ganesh
-----Original Message-----
From: Philippe Canal [mailto:pcanal_at_fnal.gov]
Sent: 29 November 2007 16:34
To: 'Borse, Ganesh'; roottalk_at_lxbuild091.cern.ch
Subject: RE: [ROOT] How to define the expression to check if a big char string contai ns small char string
> For this, I am using strstr() library function in C++.
Are you sure it is the C++ version (as opposed to the TFormula version)?
> Error in <THaCut::Compile>: strstr requires 2 string arguments
This sounds like the type of error message TFormula (or TTreeFormula) would issue.
If it is from TFormula/TTreeFormula, you need to make sure that the formula knows the 'variables' (listClients,ordClient) and that the formula knows that they are strings.
Cheers,
Philippe.
From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch] On Behalf Of Borse, Ganesh
Sent: Wednesday, November 28, 2007 10: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
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
This archive was generated by hypermail 2.2.0 : Thu Nov 29 2007 - 11:50:02 CET