If you need help, try to find the answer through the following path: `Help` in the console ⇒ [Red by Example](https://www.red-by-example.org/) ⇒ [Official Red Docs](https://github.com/red/docs/blob/master/en/SUMMARY.adoc) ⇒ [Rebol Core Manual](http://www.rebol.com/docs/core23/rebolcore.html ⇒ [Red Wiki](https://github.com/red/red/wiki ⇒ Net search "redlang + your-question" ⇒ Ask us, we are here to help!
Thanks @hiiamboris Here is version without global words:
save/header %tmp.red [
#macro [ahead paren! into ['f some integer!]]
func [[manual] s e][change/only/part at s/1 2 to-block at s/1 2 tail s/1 s]
probe (f 1 2)
probe (f 10 20 30)
][]
do %tmp.red
;3
;60
;== 60
NB! tail a
is not e
NB! tail a is not e
Riiight. Good catch.
Thanks @Respectech.
@toomasv, the macro approach is cool, but some integer!
probably isn't that useful as a rule. :^) I think this is where evaluation complicates var-args in Red. Not that we can't solve it technically, but they may end up being harder to read, especially if any lit args are involved.
(my-fn 1 2 3)
vs my-fn [1 2 3]
.
dir?
?
@greggirwin I'd like to list all files in a given directory(which contains sub-directories) to a block with this:
Red []
all-files: function [dir] [
collect [
foreach i read dir [keep
either dir? i
[all-files i]
[i]
]]]
The return of all-files
just give file names, but absolute file path is also needed for the reason of later file loading. This is why I want to convert a relative file path to a absolute path.
all-files: function [
{Returns a block of fully qualified filenames for the directory.}
spec [file!] "Starting Directory"
block [block!] "Block to append to"
/deep "Recurse sub-directories."
][
spec: dirize spec
foreach file read spec [
f-spec: repend copy spec file
either all [deep dir? f-spec] [
all-files/deep f-spec block
][
append block f-spec
]
]
block
]
clean-path
your walker needs to change to the current dir you're reading as it goes.