opening a file...
[1/4] from: mgkiourt::otenet::gr at: 7-Oct-2001 10:34
My rebol compiler is located on the C directory.
A file on the C directory can easily be opened with rebol e.g.
print read %frunlog.txt
How will I open a file located in a different directory, for example in my briefcase?
Thanks.
[2/4] from: carl:cybercraft at: 7-Oct-2001 21:16
On 07-Oct-01, mgkiourt wrote:
> My rebol compiler is located on the C directory. A file on the C
> directory can easily be opened with rebol e.g. print read
> %frunlog.txt How will I open a file located in a different
> directory, for example in my briefcase? Thanks.
Just give it the full path, a leading "/" being used to say it's one.
ie...
%/root-directory/another-directory/a-file.txt
You'll probably be asked (by REBOL) if it's okay to access the file
though, as the script's asking to access a file outside the REBOL
sandbox.
--
Carl Read
[3/4] from: sanghabum:aol at: 7-Oct-2001 4:21
[mgkiourt--otenet--gr] writes:
> A file on the C directory can easily be opened with rebol e.g.
> print read %frunlog.txt
> How will I open a file located in a different directory, for example in my
> briefcase?
print read %/c/my briefcase/frunlog.txt
Note use of forward slashes where you (as I assume a windows user) would
expect a colon or a backslash. Note also need for to escape a space.
Other ways include:
print read to-file "/c/my briefcase/frunlog.txt"
;; the quoted string allows an embedded space
print read to-rebol-file "c:\my briefcase\frunlog.txt"
;; Uses undocumented to-rebol-file function to convert
;; from a windows file name to a rebol one
;; This code isn't so portable!!
change-dir %/c/my briefcase
print read %frunlog.txt
;; Changes directory. Useful if you
;; have several files to read or write.
Hope that helps,
Colin.
[4/4] from: ingo:2b1 at: 7-Oct-2001 12:01
Once upon a time [Sanghabum--aol--com] spoketh thus:
> [mgkiourt--otenet--gr] writes:
>
> > A file on the C directory can easily be opened with rebol e.g.
> > print read %frunlog.txt
> > How will I open a file located in a different directory, for example in my
> > briefcase?
>
> print read %/c/my briefcase/frunlog.txt
... or ...
print read %"/c/my briefcase/frunlog.txt"
... use the quotes.
kind regards,
Ingo