I think this problem is similar to deleting a file. I would like
to put a directory listing into a Tcl list variable
and make a listbox out of it, without running "exec ls", so that
it runs smoothly on other platforms. I'd like to do something simple...
if {[file isdirectory $f]} {
set listing [ls $f]
}
Is it possible? To my knowledge, ls is a Unix and DOS command,
but not a native Tcl command. Is that right?
Giovanni Flammia
I believe the command you are looking for is glob. Use it like this:
set listing [glob /path/to/your/dir/*]
--
/-----------------\
| Brian Stoler |
| br...@feith.com |
\-----------------/
you have tried the glob command, right?
You want the 'glob' command in general. If you ever desire something
that is cross platform with more of the capabilities of 'ls', you can
look at the one in TkCon (http://www.cs.uoregon.edu/~jhobbs/work/tkcon/).
--
Jeffrey Hobbs Office: 541/346-3998
Univ of Oregon CIS GRF email: jho...@cs.uoregon.edu
URL: http://www.cs.uoregon.edu/~jhobbs/
>I think this problem is similar to deleting a file. I would like
>to put a directory listing into a Tcl list variable
>and make a listbox out of it, without running "exec ls", so that
>it runs smoothly on other platforms. I'd like to do something simple...
You may use the Tcl command glob instead.
Kind Regards Jesper.
GF> Hello:
GF>
GF> I think this problem is similar to deleting a file. I would like
GF> to put a directory listing into a Tcl list variable
GF> and make a listbox out of it, without running "exec ls", so that
GF> it runs smoothly on other platforms. I'd like to do something simple...
GF>
GF> if {[file isdirectory $f]} {
GF> set listing [ls $f]
GF> }
GF>
GF> Is it possible? To my knowledge, ls is a Unix and DOS command,
Just a Unix command, not a *native* MS-DOS command
GF> but not a native Tcl command. Is that right?
Yes. You don't need to use ls to get a directory listing. Tcl does have a
builtin for this:
if {[file isdirectory $f]} {
set listing [glob -nocomplain $f/*]
}
will give you the results you want and will won't on any platform -- Unix,
MS-DOS (-Windows), and MaxOS.
--
\/
Robert Heller ||InterNet: Hel...@CS.UMass.EDU
http://vis-www.cs.umass.edu/~heller ||FidoNet: 1:321/153
http://netmar.com/mall/shops/heller /\