[REBOL] Re: newbie: run .r
From: jason:cunliffe:verizon at: 15-Jan-2002 17:22
1. In REBOL/View click on the console icon:
2. check where you are:
>> what-dir
== %/C/rebol/view/
3. check to see if the file you want to load is visible by showing the
contents of the directory you are in:
>> list-dir
afile.png anindex.html
attach.r auverlot_book_sources.zip
barchart.r bay.jpg
bay.png buddha-script.r
test.r
... etc
... etc
4. if it is visible run it: "do" is the magic word to run scripts
>> do test.r
** Script Error: test.r has no value
** Near: do test.r
oops!!??? ... oh yeah forgot to include % before the file name ALWAYS*
[*unless an alias or some other REBOL code already includes it]
>> do %test.r
just testing %test.r <== the output when I run test.r
That's It :)
but wait there's more...
5. If your file is not in the current directory you have 3 choices:
a. move it there ['save as' or move or copy]
b. move yourself to where script is
c. run script from where you are now
Suppose your file is in %/c/rebol/tools/
>> list-dir %/c/rebol/tools
REBOL will probably pop up a box: REBOL Security Check
Script requests permission to open a port for read only on /c/rebol/tools
Yes | Allow All | No | Quit
So click 'Yes' or 'Allow All'
>> list-dir %/c/rebol/tools
** Access Error: Cannot open /c/rebol/tools
** Where: throw-on-error
** Near: list-dir %/c/rebol/tools
fuck you lie! Hmm.. let's try again. you can retype or if llazylaousy
ltypist liek me use the keyboard up arrows to recall the last thing you
typed.
[experiment with all the arrows, home, end, pageUp, pageDown and TAB keys]
revise your input so it reads:
>> list-dir %/c/rebol/tools/ <== the last "/" is important addbox.r
addimagebox.r
addimagebox.r.bak aliases.r
...etc
...etc
test.r
You can also show the results in relative style like urls:
>> list-dir %../tools/
likewise you can run scripts in another location:
>> do %/c/rebol/tools/somescript.r
or
>> do %../tools/somescript.r
Relative style is much more portable, and usually less typing. When you are
tired of paths, just move to the directory where your script is:
>> change-dir %/c/rebol/tools/
>> what-dir
== %/c/rebol/tools/
6.
>> ? dir
Found these words:
change-dir (function)
dir? (function)
dirize (function)
list-dir (function)
make-dir (function)
mkdir (function)
what-dir (function)
Remember ? is your #1 REBOL friend
TAB is #2 friend. Type a little bit of some recent input, and then hit TAB a
few times and see what happens [auto completion]
>> what ;[shows all the available words]
7. you can set up permanent aliases if these REBOL dir commands drive you
nuts:
create a file called say "aliases.r". Mine looks lives in %/c/rebol/tools/
and looks like this:
==============================
REBOL []
; jason lazy aliases
aliases: [
cd: :change-dir
ls: :list-dir
pwd: :what-dir
mkdir: :make-dir
]
reduce aliases
print "aliases loaded"
==============================
>> do %/c/rebol/tools/aliases.r
makes my aliases available
Since I want these to be avaiable by default I add this command into
%/c/rebol/view/user.r
Every time Rebol/View starts it will now automatically load aliases.r
Whenever I get around to it I will jazz up my alias definitions to mimic my
linux shell habits btter, add other cool stuff, shortcuts etc.
This technique can be widely exanded for all sorts of features and script
goodies you may want to include. But beware doing this until you knweo the
REBOL defaults and if you punlish your scripts make sure any customizations
are considered. This way your code will be easy to read and will run
correctly.
8. BACK to VIEW
>> desktop
hth
./Jason