Getting Started With View
I'm sure you thought that getting started was fun, but it really didn't do anything to show off REBOL. I'd like to go through almost exactly the same process, but this time focussing my attention on [REBOL/View](http://www.rebol.com/prod-view.html.) So let's give it a try!
NOTE: REBOL/View is not formally available for OS X yet, but you can grab an alpha copy from the RT site if you feel especially bold.
I'm going to skim through this very quickly. The goal is just for you to see how much potential there is in the REBOL/View dialect. You want to see "Hello World"? Here it is.
>> view layout [ text "Hello World!" ]
One way to interpret that series of
commands is along the lines of: We want to
view the layout defined as
containing the text "Hello World".
I'll be the first to admit that this is not an
impressive demonstration of GUI
prgramming - unless you've actually done some, then
you might notice how quick it was to put together
compared to using a lot of other toolkits and
platforms.
Still, the whole point of using a GUI is having something to click. Let's revisit our script from "last time" and putting some pointy-clicky goodness into it.
>> view layout [
text "Enter your name"
field
button "Hi!"
]
Neat. Except that it doesn't
actually do anything if you click the button. Pretty, but
non-functional - sort of like my neighbor's car.
Let's give the button a block of
commands along with the string "Hi!".
>> view layout [
text "Enter your name"
field
button "Hi!" [
alert "Hello there!"
]
]
Sorry, I haven't gotten a screenshot of the alert
just yet. Trust me, though. It's pretty standard fare
for alert boxes. It still doesn't have that personal
touch that the script from last time
did, though. Let's add a few touches: a little
variable assignment here, a little phrase-building there
with the join function and some refinements.
There, how about this?
>> view layout [
text "Enter your name"
name: field
button "Hi!" [
message: join "Hello " [
name/text " - great to see you!"
]
alert message
]
]
Hey, that was neat. We've got a pointy-clicky version of the "Hello" script we made last time. Let's turn it into a script so we can share our newfound REBOL/View knowledge with our other friends who have REBOL/View installed.
A REBOL/View Script
Just rewrite the code in your favorite text editor. Don't forget the script header we talked about last time!
REBOL [
Title: "Hello World!"
File: %vHello.r
Author: Brian Wisti
]
view layout [
text "Enter your name"
name: field
button "Hi!" [
message: join "Hello " [
name/text " - great to see you!"
]
alert message
]
]
You still have the same execution options as before, but REBOL/View under Windows gives you an additional choice. You can find your View script via Explorer and double-click. Easy as that!
All Done
This overview didn't even scratch the surface of REBOL/View. It didn't even touch the surface, but instead just gave the surface a sideways glance while hurrying to an urgent appointment. I encourage you to take a closer look at REBOL/View and its official documentation.
