Arbitrary number of input variables in scripts

Goodmorning,

As the subject says, is there a way of feeding a root script an arbitrary number of variables? Something along the lines of int argc, char **argv?

What I mean is not by compiling code, just by running the script. (And I stress this again, an arbitrary number of variables.)

Thanks a lot

Eleni

see the first 3 pages of the “Getting started manual”

Rene

Ok now I feel strange :blush: but I cannot find anything related.
Basically I’ve already searched through the whole manual (or so I think).

Eleni

Hi Eleni,

this does exist in C++ only with the ellipsis, used e.g. for printf. But you’ll have to specify a format of the parameters passed. I’d suggest you to ask Google how to extract the arguments from a C++ function.

Cheers, Axel.

Hi,

Did you try a typical variadic function (i.e. void myfunc(int, …); )?

Cheers,
Philippe.

Thank you all, what I want to do is read a (different each time) number of root files; the input can be either int of char.
For the time being I only input an int (=number of root files) and read their names by cint :wink:

Eleni

Finally I believe there is no point in looking for this, because “Non-static-const variable in array dimension” is also not allowed, so there aren’t any advantages in an arbitrary number of variables… However I thin kthis would be a useful feature.

Cheers,

Eleni

your simpliest solution is to store the filename into a local text file and pass the name of this text file …

Philippe

Sure, this can also work although it’s not as practical (this script will be used many times for small number of files) – but the problem with all the alternatives is that a fixed number of TFiles and other objects will have to be created since the beginning, and most of them will not be used…

Eleni

Hi,

Another alternative is to use the following files[code]// File decl.C
std::vectorstd::string gFiles;[/code[

// File reg.C (registering the files void reg(const char *file) { gFile.push_back(file); }and a file named (for example) actualUse.C and use it as follow:root.exe decl.C reg.C\(\"file1.root\") reg.C\(\"file2.root\") actualUse.C root.exe decl.C reg.C\(\"file1.root\") reg.C\(\"file2.root\") reg.C\(\"file3.root\") actualUse.C

Another alternative is to write a small shell script that takes the file names as input, create a (temporary) text file and pass this text file to your macro and root.exe

Cheers,
Philippe.