PDA

View Full Version : How to list file in a special format?



Kelvin
07-15-2002, 05:08 AM
I want to list file in two or three columns ? just like what UNIX does (ls)
I've tried to use TAB, but failed.
Please help

raimo
07-15-2002, 10:54 AM
You have to see what is the biggest length of a filename in each column and then add enough spaces to make every name that long. Be sure that you know how many columns will fit before printing.

Kelvin
07-16-2002, 01:09 AM
You have to see what is the biggest length of a filename in each column and then add enough spaces to make every name that long. Be sure that you know how many columns will fit before printing.

How about two column, and the filename is fit ?
My code ? just add a \t when i is even in "for"
but some filename is too short, for example IO.sys, then the filename in the same line(the next file) will move to left.

raimo
07-16-2002, 09:14 AM
but some filename is too short, for example IO.sys, then the filename in the same line(the next file) will move to left.

If this is the only problem, then you only need to check if the filename is longer that the length of the tab and remove tabs according to that.
...
But what if the filenames are too long? ;)

Kelvin
07-16-2002, 09:31 AM
Originally posted by raimo

If this is the only problem, then you only need to check if the filename is longer that the length of the tab and remove tabs according to that.
...
But what if the filenames are too long? ;)

Thanks your opinion! :D