This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

glob question

Old posts that have not been replied to for several years.
Locked
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

glob question

Post by Ofloo »

hello all got question allready been reading tcl manual and looking at glob examples, my question is simple how do i print dirs out hmm like vdir or ls -all or just plan dir in windows envirement ..? also how do i get rid off {} when a dir contains spaces ..?

dccpath is set to c:\\

Code: Select all

catch { glob -type d $dccpath* } dirlist
result
c:/backupdump c:/cygwin {c:/Documents and Settings} c:/dump c:/eggdrop c:/lcc c:/Perl {c:/Program Files} c:/swsetup c:/temp c:/WINDOWS
XplaiN but think of me as stupid
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

try with:

Code: Select all

catch { glob -type d $dccpath/* } dirlist
Once the game is over, the king and the pawn go back in the same box.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

? have u read my question ?? if i set path to c:\\ = c:/ if i would add an extra / then it would result that it might or migth not work its not the glob that doesn't work i wana reformat the out put just not sur on how to do that ..

set dccpath c:\\

result is that it is in one strint and i wana replace \x20 <space> by \n

cause it is a list ... i did this with foreach (split on space) and it works but .. some dirs contain spaces and get out puted like this {c:/directory name} in the list also how do i remove these {} it has nothing to do with / char ..

tnx for trying tho .. :) and sorry if u missunderstood the question then its my falt :p for not making my self clear .. enough i gues ..
Last edited by Ofloo on Tue Dec 02, 2003 2:40 pm, edited 1 time in total.
XplaiN but think of me as stupid
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Try setting the dccpath to c://
Once the game is over, the king and the pawn go back in the same box.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

the glob works


i just want the output to be different
XplaiN but think of me as stupid
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

current out put

list : c:\test c:\test2 ...
i watn vertical list out put

list:

c:\test
c:\test2

several ways of doing this ..

like
output without foreach

c:/backupdump c:/cygwin {c:/Documents and Settings} c:/dump c:/eggdrop c:/lcc c:/Perl {c:/Program Files} c:/swsetup c:/temp c:/WINDOWS

Code: Select all

set dccpath c:\\
catch { glob -type d $dccpath* } dirlist
foreach line [split $dirlist \x20] {
  putdcc $idx $line
}
output:

[19:05] <Eggy> c:/backupdump
[19:05] <Eggy> c:/cygwin
[19:05] <Eggy> {c:/Documents
[19:05] <Eggy> and
[19:05] <Eggy> Settings}
[19:05] <Eggy> c:/dump
[19:05] <Eggy> c:/eggdrop
[19:05] <Eggy> c:/lcc
[19:05] <Eggy> c:/Perl
[19:05] <Eggy> {c:/Program
[19:05] <Eggy> Files}
[19:05] <Eggy> c:/swsetup
[19:05] <Eggy> c:/temp
[19:05] <Eggy> c:/WINDOWS
see my problem first of all = > dir contains spaces like "program files" it has chars {} also if i split on \x20 = > the output is messedup ..
XplaiN but think of me as stupid
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Have you ever read "The Manual"?
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

could u give some explanation what ur getting to ?? cause i realy don't get what i am supposed to do with that !! if its the c:\ u wana looze don't bother i know how i want vlist not hlist v = vertical .. cause ive read most of the stuff in the manual its not that i read it that i completly understand some off that stuff is to technical for me so .. maybe little xplanation where how to use it so i know what u mean there is like 50 places where i can use that stuff .. but i am still not sur what i am supposed to do with it .. and yes i read it 5 times allready before posting this still have no clue, also i will read it 50 times after ive posted this but i don't think i will get any wizer unless u give me some xplaination ..? but tnx for ur answer ..
XplaiN but think of me as stupid
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

How about this then? :)

Code: Select all

foreach file [glob -nocomplain -type d $dccpath*] {
  putdcc $idx [file nativename $file]
}
Have you ever read "The Manual"?
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

Thank u so mutch it works yay
XplaiN but think of me as stupid
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

lol

Post by user »

I seem to have solved your problem without understanding what it was :o
I thought your problem was having the backslashes in your windows paths replaced by forward slashes in the result.

Here's the answer to your real question: glob returns a LIST of files. DON'T split lists unless you want to mess them up. 'split' is for converting STRINGS to lists. OK? :P
Have you ever read "The Manual"?
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

ok tnx
XplaiN but think of me as stupid
Locked