I am using the Red binding to read and write files, and the hard-coded-file-names version works well. But I want to get file names from the command line dynamically. As Red
has no such utility right now. So I try to make it with Red/System
. I can get command line args now, but I don't know how to pass it to the Red
part. Like the example below, I need to pass source-file
and target-file
to read
and write
:
Red []
#include %input-output.red
#system-global [
args: system/args-list
args: args + 1
source-file: args/item
args: args + 1
target-file: args/item
print [source-file target-file ]
]
data: read source-file
probe data
write target-file data
Something like this should work, just convert your #system-global code to a routine function:
Then once compiled, you should get this result: