Re: How to use list effectively?



Gerald W. Lester wrote:
Why Tea wrote:
I have obtained a filelist with "find" in a clearcase vobs. There are
close to 10,000 files. I'm thinking of reading them into a list, then
for any given filename I can quickly search the list to obtain the full
path and spawn an external viewer. I'm sure there are other better and
more efficient ways of doing it. I'd appreciate any suggestion and
better still, with some sample code. Thanks.

It may be better to use an array with the file name as the key and the full
path as the value (or list of values if you want to allow a file with the
same name to exist in multiple directories).

Another option would be to use the full path (including the file name) as
the key with a "1" as the value.

Either way, [array names fileArray $searchPattern] will give you the list
you are looking for.

A big advantage of doing it this way is that [array name] and [array
get] does wildcard by default. So you can for example do searches like:

foreach {fname fpaths} [array get fileArray *.log] { ...

.



Relevant Pages

  • Re: Really Stuck, Please Help
    ... I am not sure how to construct an array. ... Reading Master Log", of the "Copreco Master Log" workbook. ... Dim sourceBook As String ...
    (microsoft.public.excel.programming)
  • Re: Problem with a script
    ... a loop there becomes impractical. ... You still have them as uniquely named array indexes... ... writing the code twice will only ... reading your entire code and parsing it in their head, ...
    (comp.lang.php)
  • Re: Problem with a script
    ... Okay, so variables have unique labels, that doesn't mean they still couldn't be handled in a loop. ... You still have them as uniquely named array indexes... ... I believe that for the new guy this code would be readable, and identifying problems should really not be any more difficult with this, plus I think that it actually might save some time to write the actual code from the beginnig, even though it's not at it's final stage, instead of first writing everything spread out, and then rewriting the same code again cleaned. ... If you expect a person to spend an hour reading your entire code and parsing it in their head, you wont get any help and have to solve the problem by yourself. ...
    (comp.lang.php)
  • Re: How to use list effectively?
    ... Why Tea wrote: ... I'm thinking of reading them into a list, ... for any given filename I can quickly search the list to obtain the full ... It may be better to use an array with the file name as the key and the full path as the value. ...
    (comp.lang.tcl)
  • Re: Reading Files Byte-For-Byte
    ... >> attempting to read the file into an array. ... to be slower due simply to the additional commands required to accomplish ... I think the misunderstanding came about due to your mentioning reading the ... of printable characters, you'll need to do something else if your file data falls ...
    (microsoft.public.vb.general.discussion)