Rebol 程式設計/ls
外觀
LS dir
列印目錄的多列排序列表。
LS 是一個函式值。
- dir -- 要列出的目錄或無(型別:檔案 URL 未設定)
- 捕獲
ls: func [
{Prints a multi-column sorted listing of a directory.}
[catch]
dir [file! url! unset!] "Directory to list or nothing"
/local file max s
][
dir: throw-on-error [
either value? 'dir [
read dirize dir
] [
read %.
]
]
dir: sort dir
max: 0
foreach file dir [
if (length? file) > max [max: length? file]
]
max: max + 2
s: make string! 0
foreach file dir [
append s file
while [((length? s) // max) <> 0] [append s " "]
if (length? s) > 60 [
print s
clear s
]
]
if length? s [print s]
]