INSTRUCTIONS:

Download REBOL/View from http://www.rebol.com/download-view.html (.6 MB)

Run REBOL, click the "Console" icon, and paste in any of these examples.

   *** THAT'S EVERYTHING YOU NEED TO GET STARTED WITH THIS TEXT ***

To make REBOL automatically open to the console every time it starts,
click the "User" link, and then uncheck "Open desktop at startup".

To use REBOL's built in text editor, type "editor none" at the console.
Press the F5 key while in the editor to save and run any edited code.
Be sure to type the header "REBOL []" at the top of any edited scripts.
If you install REBOL, any file saved with a ".r" extension will run
when its file icon is clicked (.r code files run just like .exe files).

Type "desktop" to reopen REBOL's default graphic desktop.  See thousands
of additional code examples by clicking the "REBOL" and "Public" icons.

See http://re-bol.com for a complete REBOL tutorial with line-by-line
explanations of all the code in these examples.  See the last example
in this document for a useful quick reference manual.

Metapad (http://liquidninja.com/metapad/download.html) is a great editor
for REBOL.  Click Options -> Settings -> Primary External Viewer, and set
your REBOL path (usually C:\Program Files\rebol\view\rebol.exe).


DEMO APPLICATION (10 apps in 2890 characters):

REBOL[title:"Demo"]p: :append kk: :pick r: :random y: :layout q: 'image
z: :if gg: :to-image v: :length? g: :view k: :center-face ts: :to-string
tu: :to-url sh: :show al: :alert rr: :request-date co: :copy g y[style h
btn 150 h"Paint"[g/new k y[s: area black 650x350 feel[engage: func[f a e][
z a = 'over[p pk: s/effect/draw e/offset sh s]z a = 'up[p pk 'line]]]
effect[draw[line]]b: btn"Save"[save/png %a.png gg s al"Saved 'a.png'"]btn
"Clear"[s/effect/draw: co[line]sh s]]]h"Game"[u: :reduce x: does[al join{
SCORE: }[v b]unview]s: gg y/tight[btn red 10x10]o: gg y/tight[btn tan
10x10]d: 0x10 w: 0 r/seed now b: u[q o(((r 19x19)* 10)+ 50x50)q s(((r
19x19)* 10)+ 50x50)]g/new k y/tight[c: area 305x305 effect[draw b]rate 15
feel[engage: func[f a e][z a = 'key[d: select u['up 0x-10 'down 0x10 'left
-10x0 'right 10x0]e/key]z a = 'time[z any[b/6/1 < 0 b/6/2 < 0 b/6/1 > 290
b/6/2 > 290][x]z find(at b 7)b/6[x]z within? b/6 b/3 10x10[p b u[q s(last
b)]w: 1 b/3:((r 29x29)* 10)]n: co/part b 5 p n(b/6 + d)for i 7(v b)1[
either(type?(kk b i)= pair!)[p n kk b(i - 3)][p n kk b i]]z w = 1[clear(
back tail n)p n(last b)w: 0]b: co n sh c]]]do[focus c]]]h"Puzzle"[al{
Arrange tiles alphabetically:}g/new k y[origin 0x0 space 0x0 across style
p button 60x60[z not find[0x60 60x0 0x-60 -60x0]face/offset - x/offset[
exit]tp: face/offset face/offset: x/offset x/offset: tp]p"O"p"N"p"M"p"L"
return p"K"p"J"p"I"p"H"return p"G"p"F"p"E"p"D"return p"C"p"B"p"A"x: p
white edge[size: 0]]]h"Calendar"[do bx:[z not(exists? %s)[write %s ""]rq:
rr g/new k y[h5 ts rq aa: area ts select to-block(find/last(to-block read
%s)rq)rq btn"Save"[write/append %s rejoin[rq" {"aa/text"} "]unview do bx]]
]]h"Video"[wl: tu request-text/title/default"URL:"join"http://tinyurl.com"
"/m54ltm"g/new k y[image load wl 640x480 rate 0 feel[engage: func[f a e][
z a = 'time[f/image: load wl show f]]]]]h"IPs"[parse read tu join"http://"
"guitarz.org/ip.cgi"[thru<title>copy my to</title>]i: last parse my none
al ts rejoin["WAN: "i" -- LAN: "read join dns:// read dns://]]h"Email"[
g/new k y[mp: field"pop://user:pass@site.com"btn"Read"[ma: co[]foreach i
read tu mp/text[p ma join i"^/^/^/^/^/^/"editor ma]]]]h"Days"[g/new k y[
btn"Start"[sd: rr]btn"End"[ed: rr db/text: ts(ed - sd)show db]text{Days
Between:}db: field]]h"Sounds"[ps: func[sl][wait 0 rg: load sl wf: 1 sp:
open sound:// insert sp rg wait sp close sp wf: 0]wf: 0 change-dir
%/c/Windows/media do wl:[wv: co[]foreach i read %.[z %.wav = suffix? i[p
wv i]]]g/new k y[ft: text-list data wv[z wf <> 1[z error? try[ps value][al
"Error"close sp wf: 0]]]btn"Dir"[change-dir request-dir do wl ft/data: wv
sh ft]]]h{FTP}[g/new k y[px: field"ftp://user:pass@site.com/folder/"[
either dir? tu va: value[f/data: sort read tu va sh f][editor tu va]]f:
text-list[editor tu join px/text value]btn"?"[al{Type a URL path to browse
(nonexistent files are created). Click files to edit.}]]]]


LANGUAGE BASICS:

print "Hello world"
alert "Alert is a FUNCTION.  This text is its PARAMETER (or ARGUMENT)."
alert ("Parentheses can enclose parameters, but they aren't required.")
editor "This text is a parameter of the 'editor' function ... edit it."
browse http://rebol.com ; this function is 'browse' the parameter is a URL
request "Functions perform ACTIONS.  Parameters are DATA.  Make sense?"
; this is a comment
{
   This is a multi line comment.
   Comments don't do anything in a program.
   They just remind the programmer what's happening in the code.
}
request-text   ; These requester functions don't require any parameters,
request-date   ; but like most functions, they RETURN a useful value.
request-color
request-file
request-dir
request-pass

alert request-text  ; In all these examples, the 1st function uses a value
editor request-date ; RETURNED by the 2nd function, as its parameter.  To
print request-file  ; complete the 1st function, user response is needed.
editor request request-text         ; Here, return values are CASCADED.

alert "First function on this line" alert "Second function, same line"
alert "No"  alert "line"  alert "endings"  alert "are"  alert "required"
alert "functions are" editor "automatically grouped with their parameters"

request-text/default "Text"  ; many functions have "refinements" (options)
request-text/title  "The /title refinement sets this header text"
request-text/title/default  "Name:"  "John Smith"     ; 2 options together
request-text/title/offset "/offset repositions the requester" 10x100
request-pass/offset/title 10x100 "title" alert "Processing"  ; 2 functions
request-file/file %temp.txt          ; default file name
request-file/filter ["*.txt" "*.r"]  ; only show .txt and .r files
request-file/only  ; limit selection to a single file
request-file/save  ; save dialog (instead of open dialog)
request-file/save/file/filter %temp.txt ["*.txt" "*.r"]

print   10  +  12  /  2   ;  22 / 2 = 11  Math is ALWAYS evaluated left to
print  (10  +  12) /  2   ;  22 / 2 = 11  right.  The only exception:
print   10  + (12  /  2)  ;  10 + 6 = 16  Parentheses are evaluated first.

print "This is a string of text."
print {
    Curly braces are used for
    multi line text strings
    (instead of quotes).
}
alert {To use "quotes" in a text string, put them inside curly braces.}
alert "You can use {curly braces} inside quotes."
alert "'Single quotes' can go inside double quotes..."
alert {'...or inside curly braces'}
alert {"ANY quote symbol" {can actually be used within} 'curly braces'}
alert "In many cases"  alert {curly braces and quotes are interchangable.}

rejoin ["Hello " "World"]  ; "rejoin" CONCATENATES (joins together) values
rejoin [{Concatenate } {as } {many items } {as } {you } {want.}]
rejoin [request-date {  } request-color {  } now/time {  } $29.99]
alert rejoin ["You chose: " request "Choose one:"] ; CASCADE return values
join {"Join" only concatenates TWO items } {("rejoin" is more powerful).}
print rejoin ["This text is followed by a carriage return." newline]
print "This text is also followed by a carriage return.^/"
prin {'Prin' } prin {doesn't } prin {print } print {a carriage return.}
prin newpage  ; clear console screen

print read http://rebol.com  ; "read" retrieves the data from many sources
editor http://rebol.com   ; the built in editor can also read many sources
print read %./   ; the % symbol is used for local files and folders
editor %./
write %temp.txt "test"   ; write takes TWO parameters (file name and data)
editor %temp.txt
editor request-file/only   ; "only" refinement limits choice to 1 file
write clipboard:// (read http://rebol.com)  ; 2nd parameter in parentheses
editor clipboard://
print read dns://msn.com   ; REBOL can read many built in protocols
print read nntp://public.teranews.com 
write/binary %/c/bay.jpg (read/binary http://rebol.com/view/bay.jpg)
write/binary %tada.wav (read/binary %/c/windows/media/tada.wav)
write/binary %temp.dat (compress read http://rebol.com)  ; COMPRESS DATA
print decompress read/binary %temp.dat                   ; DECOMPRESS DATA
print read ftp://user:pass@website.com/name.txt       ; user/pass required
write ftp://user:pass@website.com/name.txt "text"     ; user/pass required
editor ftp://user:pass@website.com/name.txt  ; can save changes to server!
editor pop://user:pass@website.com    ; read all emails in this account
send user@website.com "Hello"   ; send email
send user@website.com (read %file.txt)   ; email the text from this file
send/attach user@website.com "My photos" [%pic1.jpg %pic2.jpg pic3.jpg]

call/show "notepad.exe c:\config.sys"   ; run OS shell command 
view layout [image %pic1.jpg]           ; view an image
view layout [image request-file/only]   ; view a user selected image
insert s: open sound:// load request-file/only wait s close s ; play sound
insert s: open sound:// load %/c/windows/media/tada.wav wait s close s

rename %temp.txt %temp2.txt   ; change file name
write %temp.txt read %temp2.txt   ; copy file
write/append %temp2.txt ""   ; create file (or if it exists, do nothing)
delete %temp2.txt
change-dir %../
what-dir 
list-dir
make-dir %./temp
print read %./

x: 10    ; The COLON symbol assigns a value to a word label (a "variable")
print x
x: x + 1    ; increment variable by 1 (add 1 to the current value of x)
print x
y: "hello"  z: " world"
print rejoin [y z]
probe rejoin [y z]   ; PROBE shows RAW DATA (PRINT formats nice output)
print join y z
person: "john"   ; variables (word labels) ARE ** NOT ** CASE SENSITIVE
print person   print PERSON   print PeRsOn
value1: value2: value3: "yes "   ; here, all 3 variables are set to "yes "
print rejoin [value1 value2 value3]
name: ask "Enter your name:  "   ; "ask" gets text input from the user
print rejoin ["Hello " name]
filename: request-file/only
alert rejoin ["You chose " filename]
osfile: to-local-file filename   ; REBOL uses its own multiplatform syntax
to-rebol-file osfile  ; Convert from native OS file notation back to REBOL
the-url: http://website.com/subfolder
split-path the-url   ; "split-path" breaks any file or URL into 2 parts

some-text:  {
    This is a multi line string of text.
    Strings are a native data type, delineated by
    quotes or curly braces, which enclose text.
    REBOL has MANY other built in data types, all
    delineated by various characters and text formats.
    The "type" function returns a value's data type.
    Below are just a few more native data types:
}                                          
type? some-text

an-integer: 3874904                        type? an-integer
a-decimal: 7348.39                         type? a-decimal    
web-site: http://musiclessonz.com          type? web-site 
email-address: user@website.com            type? email-address      
the-file: %/c/myfile.txt                   type? the-file 
money-amount: $343.56                      type? money-amount
color-tuple: 123.54.212                    type? color-tuple
a-character: #"z"                          type? a-character
a-word: 'asdf                              type? a-word                   
html-tag: <br>                             type? html-tag    
binary-info:  #{ddeedd}                    type? binary-info    
image: load http://rebol.com/view/bay.jpg  type? image
a-sound: load %/c/windows/media/tada.wav   a-sound/type

to-decimal an-integer     ; Convert values TO different types ("cast")
to-string web-site        ; now the web site URL is surrounded by quotes
form web-site             ; "form" also converts various values to string
form $29.99
alert form $29.99         ; the alert function REQUIRES a string parameter
alert $29.99              ; (this throws an error)
5 + 6                     ; you can perform math operations with integers
"5" + "6"                 ; (error) you can't perform math with strings
(to-integer "5") + (to-integer "6")    ; this eliminates the math problem
to-pair [12 43]           ; creates a coordinate pair
as-pair 12 43             ; a better way to create a coordinate pair
to-binary 123.54.212      ; convert a REBOL color value to hex color value
to-binary request-color   ; convert the color chosen by the user, to hex
to-tuple #{00CD00}        ; convert a hex color value to REBOL color value
form to-tuple #{00CD00}   ; covert the hex color value to a string
write/binary %floorplan8.pdf debase read clipboard://  ; email attachment

6:30am + 00:37:19      ; REBOL computes values appropriately for type
now  
now + 0:0:59  
now - 10   
23x54 + 19x31
22x66 * 2
22x66 * 2x3
192.168.1.1 + 0.0.0.37
11.22.33.44 * 9        ; note that each IP segment value is limited to 255
0.250.0 / 2            ; an easy way to adjust color values
$29.99 * 5
x: 12  y: 33  q: 18  p: 7
(as-pair x y) + (as-pair q p)  ; very common in graphics apps using coords
remove form to-money 1 / 233
remove/part form to-time (1 / 233) 6

random/seed now/time   ; always use this line to get real random values
random 50              ; a random number between 0 and 50
random 50x100          ; left side is limited to 50, right limited to 100
random 222.222.222     ; each segment is limited to #s between 0 and 222
random $500
random "asdfqwerty"    ; a random mix of the given characters


FLOW CONTROL (Conditional Evaluations and Loops):

if now/time > 12:00 [alert "It's after noon."]      ; if (true) [do this]
if not now/time > 12:00 [alert "It's morning."]
unless now/time => 12:00 [alert "It's morning."]
if not now/time = 12:00 [alert "It's not noon."]
if now/time <> 12:00 [alert "It's not noon."]

if error? try [0 / 0] [alert "Divide by 0 error"]   ; if error [do this]
if attempt [1 / 1] [alert "Successful"]          ; if no error [do this]
attempt [0 / 0]                                  ; ignore error

either now/time > 8:00am [                       ; same as if/else
    alert "It's time to get up!"
][
    alert "You can keep on sleeping."
] 

favorite-day:  request-text/title "What's your favorite day of the week?"
switch/default favorite-day [
    "Monday"    [alert "Monday is the worst!  The work week begins..."]
    "Tuesday"   [alert "Tuesdays and Thursdays are both ok, I guess..."]
    "Wednesday" [alert "The hump day - the week is halfway over!"]
    "Thursday"  [alert "Tuesdays and Thursdays are both ok, I guess..."]
    "Friday"    [alert "Yay!  TGIF!"]
    "Saturday"  [alert "Of course, the weekend!"]
    "Sunday"    [alert "Of course, the weekend!"]
] [alert "You didn't type in the name of a day!"]

name: "john"
case [
    find name "a" [print {Your name contains the letter "a"}]
    find name "e" [print {Your name contains the letter "e"}]
    find name "i" [print {Your name contains the letter "i"}]
    find name "o" [print {Your name contains the letter "o"}]
    find name "u" [print {Your name contains the letter "u"}]
    true [print {Your name doesn't contain any vowels!}]
]

name: "brian" 
found: false
case/all [            ; /all evaluates ALL conditions, without breaking
    find name "a" [print {Your name contains the letter "a"} found: true]
    find name "e" [print {Your name contains the letter "e"} found: true]
    find name "i" [print {Your name contains the letter "i"} found: true]
    find name "o" [print {Your name contains the letter "o"} found: true]
    find name "u" [print {Your name contains the letter "u"} found: true]
    found = false [print {Your name doesn't contain any vowels!}]
]

value1: true   value2: false
if ((value1 = true) and (value2 = true)) [
    print "both true"
]
if ((value1 = true) or (value2 = true)) [
    print "either one OR the other is true"
]

alarm-time: now/time + :00:10
forever [if now/time = alarm-time [alert "10 seconds have passed" break]]

while [now/date < 21-dec-2012] [print "Press [ESC] to quit"]
until [now/date >= 21-dec-2012] [print "It's now December 21, 2012"]

loop 50 [print "REBOL is great!"]

count: 0
loop 50 [
    count: count + 1
    print rejoin ["This is loop #: " count]
]

repeat count 50 [print rejoin ["This is loop #: " count]]

for counter 1 10 1 [print counter] 
for counter 10 1 -1 [print counter] 
for counter 10 100 10 [print counter] 
for counter 1 5 .5 [print counter] 
for timer 8:00 9:00 0:05 [print timer] 
for dimes $0.00 $1.00 $0.10 [print dimes] 
for date 1-dec-2005 25-jan-2006 8 [print date]
for alphabet #"a" #"z" 1 [prin alphabet]

folder: read %. 
foreach file folder [print file] 


SERIES ("blocks", data lists):

new-block: copy []  ; a new, empty block
some-names: ["John" "Bill" "Tom" "Mike"]   ; a list of text strings
more-names: copy some-names   ; a copy of the above list
probe more-names
same? more-names some-names   ; NOT the exact same list, but a copy
same-names: some-names   ; THESE labels now refer to the EXACT SAME list
probe same-names
same? same-names some-names ; change some-names and same-names CHANGES TOO
sortednames: sort copy some-names  ; "copy" keeps some-names from changing
sortednames: sort some-names  ; here, the some-names block has been sorted
print first sortednames  ; here are 3 different ways to pick the 1st item:
print sortednames/1 
print pick sortednames 1 
print second sortednames   ; 3 different ways to pick the 2nd item:
print sortednames/2
print pick sortednames 2
find some-names "John"
first find some-names "John"
find/last some-names "John" 
select some-names "John"   ; use series like dictionaries
reverse sortednames 
length? sortednames 
head sortednames 
next sortednames 
back sortednames 
last sortednames 
tail sortednames  
at sortednames 2
skip sortednames 1
extract sortednames 3  ; every third item
index? sortednames 
insert (at sortednames 3) "Lee" 
append sortednames "George" 
remove sortednames 
remove find sortednames "Mike" 
change sortednames "Phil" 
change third sortednames "Phil"
poke sortednames 3 "Phil" 
copy/part sortednames 2 
replace/all sortednames "Lee" "Al"
probe form sortednames
probe mold sortednames
join some-names sortednames 
intersect sortednames more-names  
difference sortednames more-names 
exclude sortednames more-names 
union sortednames more-names 
unique sortednames 
clear sortednames
empty? sortednames
probe same-names
probe more-names

index-num: length? more-names
print pick more-names index-num
print pick more-names (index-num - 1)
print pick more-names (random length? more-names)

index-num: ((index? (find more-names "Tom")) - 1)
print pick more-names index-num ; 4 ways to pick items at a variable index
print more-names/:index-num
print compose [more-names/(index-num)]
print reduce [more-names/(index-num)]  

; "READ" reads data byte-for-byte from file, "LOAD" performs a CONVERSION
; "WRITE" writes series byte-for-byte to file, "SAVE" performs CONVERSION

save %names.txt more-names         ; series data saved to a text file
loaded-names: load %names.txt      ; use "load" to read it into a variable
write %names2.txt mold more-names  ; series saved but WITH SQUARE BRACKETS
loaded-names2: load %names2.txt    ; "load" also correctly loads that file
read-names: to-block read %names.txt  ; "read" requires "to-block" convert
read-names2: to-block read %names2.txt  ; block within a block
probe read-names2                       ; [["John" "Phil" "Tom" "Mike"]]
first read-names2                       ; ["John" "Phil" "Tom" "Mike"]

write/binary %compressed.dat compress mold more-names  ; compress and save
probe load decompress read/binary %compressed.dat  ; read and decompress
save %compressed.dat compress mold more-names  ; another way to save
probe load decompress load %compressed.dat  ; and load compressed series

foreach name more-names [print name]    ; FOR EACH item in list [do this]
foreach month system/locale/months [print month]
foreach file (read %./) [print file]

items: ["car" "boat" "house"]
foreach item items [print rejoin ["I like my " item]]

count: 0
foreach item items [
    count: count + 1
    print rejoin ["^/Item #" count ": " item]
]

big-block: [
    [may june july] 
    [ 
        [1 2 3] 
        [
            [yes no]
            [monday tuesday friday]
        ]
    ]
]

; Indentation makes the block easier to read, but is not required:
big-block: [[may june july][[1 2 3][[yes no][monday tuesday friday]]]]

probe first big-block          ; 3 ways to get the first item in the block
probe big-block/1
probe pick big-block 1
probe second big-block        ; 3 ways to get the second item in the block
probe big-block/2
probe pick big-block 2 
probe first second big-block     ; 1st block in the 2nd block in big-block
probe big-block/2/1
probe second second big-block    ; 2nd block in the 2nd block in big-block
probe big-block/2/2
probe first second second big-block
probe big-block/2/2/1
probe second second second big-block
probe big-block/2/2/2
probe big-block/2/2/2/1
probe big-block/2/2/2/2
probe big-block/2/2/2/3

users: [
    "John Smith" "123 Tomline Lane Forest Hills, NJ" "555-1234"
    "Paul Thompson" "234 Georgetown Pl. Peanut Grove, AL" "555-2345"
    "Jim Persee" "345 Pickles Pike Orange Grove, FL" "555-3456"
    "George Jones" "456 Topforge Court Mountain Creek, CO" ""
    "Tim Paulson" "" "555-5678"
]

probe extract users 3           ; the name column (every 3rd item)
probe extract/index users 3 2   ; address column (skip 3, starting on 2)
probe extract/index users 3 3   ; phone column (skip 3, starting on 3)

probe form users  ; convert entire block to a string

foreach [name address phone] users [  ; get groups of 3 consecutive items
    print rejoin [
        "^/Name:     " name 
        "^/Address:  " address 
        "^/Phone:    " phone 
    ]
]

foreach name (extract users 3) [
    if find name "a" [
        print pick users ((index? find users name) + 2)
    ]
]     ; prints phone numbers for all names that contain the letter "a"

do [
    prin newpage
    field: to-integer ask {Field to search (1=name, 2=address, 3=phone): }
    search-text: ask {Text to search for: }
    foreach [name address phone] users [
        if find (pick reduce [name address phone] field) search-text [
            print rejoin [
                newline
                "Name:     " name    newline
                "Address:  " address newline
                "Phone:    " phone   newline
            ]
        ]
    ]
]   ; "do" allows us to run some interactive console code such as "ask"

forever [
    prin newpage
    count: 1
    sorted-names: sort extract users 3
    foreach name sorted-names [
        print rejoin [newline count " - " name]
        count: count + 1
    ]
    choice: to-integer ask "^/^/Selection: "
    unless choice > (length? sorted-names) [
        chosen: index? find users (pick sorted-names choice)
        print newline
        for i chosen (chosen + 2) 1 [print pick users i]
        continue: ask "^/^/[ENTER] to continue, 'Q' to quit..."
        if continue = "q" [prin newpage halt]
    ]
]

append users ["Joe Thomas" "" "555-321-7654"]  ; append to end of list

name: "Alex Sharp"  address: "937 Boll Rd"  phone: "555-294-2834"
repend users [name address phone]              ; append variable values

insert (at users 4) [
    "Tom Adams" "321 Way Lane Villageville, AZ" "555-987-6543"
]

remove (at users 4)  ; remove 1 item
remove/part (at users 4) 2  ; remove 2 items
change (at users 1) "Jonathan Smith"
remove (at users 1) insert (at users 1) "Jonathan Smith"
foreach item users [
    replace item "John Smith" "Jonathan Smith"
]

new-users: copy []
foreach [name address phone] users [
    append/only new-users reduce [name address phone]
] ; append/only inserts blocks as blocks, instead of as individual items
editor new-users

field: 2  sort/compare new-users func [a b] [(at a field) < (at b field)]
editor new-users                   ; sorted by the 2nd field (by address)

users: copy []
foreach block new-users [append users reduce block]     ; "flatten" block
editor users

copy/part users 3
copy/part (at users 4) 3
copy at tail users -3
copy/part (at users 7) 3
copy/part (find users "Jim Persee") -3
copy/part (skip (find users "Jim Persee") -6) 3
alert form (copy/part users 3)

chosen: request-list "Choose a person: " (extract users 3)
alert form reduce [copy/part find users chosen 3]
alert reform [copy/part find users chosen 3]
chosen: request-list "Choose an address: " (extract/index users 3 2)
alert reform [copy/part at (find users chosen) -1 3]

x: ["one" "two" "three" "four" "five" "six"]
move/to (find x "five") 2
print x               ; item position changed

x: ["asdf" "qwer" "zxcv" "uiop" "hjkl" "vbnm"]
y: head clear skip tail x -2
probe y               ; last 2 items removed

data: [
    1 2 3 [4 5 6]
    7 8 9 [0 9 8 7 6 5 4 3 2 1]
    3 4 5 [6 3 1 7 8 0] 
]
counter: 1
foreach [col1 col2 col3 col4] data [
    print rejoin [
        "Row: " counter newline
        "Column1: " col1 newline
        "Column2: " col2 newline
        "Column3: " col3 newline
        "Column4 (sorted): " (sort col4) newline newline
    ]
    counter: counter + 1
]

foreach file read %. [
    if (suffix? file) = %.tester [
        rename file to-file (replace to-string file ".tester" ".test")
    ]
]   ; directories are just lists of files - all series operations work
list-dir

for i 1 length? pp: open pop://user@site.com 1 compose [
    ask find pp/(i) "Subject:"
]

foreach line reverse copy system/console/history [print line]

replace/all replace/all replace/all replace/all form now/precise trim {
    /} "" ":" "x" "-" "q" "." ""       ; useful unique string generator

some-items: ["item1" "item2" "item3" "item4"]
an-image: load http://rebol.com/view/bay.jpg
append some-items an-image  ; block now contains 4 strings and an image
save/all %some-items.txt some-items  ; save it all to a simple text file
some-items: load %some-items.txt     ; load it back and use it later
view layout [image fifth some-items]

photo1: load http://rebol.com/view/bay.jpg
photo2: load http://rebol.com/view/demos/palms.jpg
photo-block: reduce [photo1 photo2]
; or  photo-block: compose [(photo1) (photo2)]
foreach photo photo-block [view layout [image photo]]


STRINGS (series of characters):

the-string: "abcdefghijklmnopqrstuvwxyz"
copy/part the-string 7
copy at tail the-string -7
copy/part (at the-string 12) 7
copy/part (find the-string "m") -7
copy/part (skip (find the-string "t") -12) 7
the-string/7 
pick the-string 7
seventh the-string
replace the-string "cde" "123"
change (at the-string 7) "7"
poke the-string 7 #"7"
poke the-string 7 (to-char "7")
print the-string
remove/part (at the-string 3) 15
print the-string
insert (at the-string 3) "cdefghijklmnopq"
print the-string
insert/dup head the-string "-+ " 3
print the-string
replace/all the-string "-+ "  " "
print the-string
trim the-string
print the-string
extract the-string 3
to-integer third the-string
to-char 99
to-string to-char 99
to-string now
to-string $2344.44
to-string to-char 99
to-string system/locale/months
form now
form $2344.44
form to-char 99
form system/locale/months
the-block: copy []
foreach item the-string [append the-block item]
probe the-block


GUI WINDOWS (graphic user interfaces):

; VIEW LAYOUT [block of widgets]   ; basic syntax
;
; view layout [
;     widget1 properties [BLOCK OF ACTIONS TO BE PERFORMED BY WIDGET1]
;     widget2 properties [BLOCK OF ACTIONS TO BE PERFORMED BY WIDGET2]
; ]

view layout [area btn "Click Me"]   ; text area and button with some text

view layout [
    area 
    btn "Click Me" [alert "You can type in the square area."]
]

view center-face layout [         ; center the GUI window on the screen
    a: area                       ; label this text area "a"
    btn "Save" [                  ; do this when the button is clicked:
        write %temp.txt a/text    ; write the text in the area to a file
        alert "Saved"             ; notify the user
    ]
]

view layout [      
    f1: field "123"                 ; Text fields ONLY hold string values.
    f2: field "http://rebol.com"
    btn "Show Data Types" [
        print type? f1/text         ; Field text must be CONVERTED to
        print type? f2/text         ; expected REBOL data types for use:
    ]
    btn "Multiply" [print (to-integer f1/text) * 2]    ; convert to number
    btn "Browse" [browse (to-url f2/text)]             ; convert to URL
    btn "Error" [print f1/text * 2]    ; you can't perform math on strings
]

; ALWAYS use "show" to update ANY screen changes, as in this text editor:

view layout [
    a: area 600x350 wrap          ; 600 pixels wide by 350 pixels tall
    across                        ; layout next widgets horizontally
    f: field 500 "filename.txt"   ; 500 pixels across, with default text
    btn "Load" [                  ; do the following lines when clicked:
        f/text: request-file/file f/text  ; set text to selected file name
        show f                    ; TEXT CHANGED so widget must be updated
        a/text: read to-file f/text ; set area text to data read from file
        show a                    ; TEXT CHANGED so widget must be updated
    ]
    btn "Save" [                  ; do the following lines when clicked:
        write (request-file/only/save/file f/text) a/text     ; write the
        alert "Saved"             ; text in the area widget, to a file
    ]                             ; selected by the user, notify when done
]

view gui: layout [                ; label the entire GUI layout
    size 600x400                  ; set the window size
    backdrop white                ; set the window background color
    field1: field 560
    field2: field 560
    area1: area 560x235 wrap
    btn "Save" [
        save-block: copy []
        append save-block field1/text 
        append save-block field2/text 
        append save-block area1/text
        save %save.txt save-block
        alert {SAVED -- Now try running this script again, and load
            the data back into the fields.}
    ]
    btn "Load" [
        save-block: load %save.txt
        field1/text: save-block/1
        field2/text: save-block/2
        area1/text: save-block/3
        show gui                  ; UPDATE ENTIRE GUI to show changes
    ]
]

view layout[
    h1 "Send:"  ; big bold text widget (h1, h2, h3, ...)
    btn "Server settings" [  ; save user's email settings in REBOL:
        system/schemes/default/host: request-text/title "SMTP Server:"
        system/schemes/pop/host:     request-text/title "POP Server:"
        system/schemes/default/user: request-text/title "SMTP User Name:"
        system/schemes/default/pass: request-text/title "SMTP Password:"
        system/user/email:  to-email request-text/title "Email Address:"
    ]
    a: field "user@website.com"
    s: field "Subject" 
    b: area
    btn "Send" [attempt [
        send/subject (to-email a/text) b/text s/text
        alert "Sent"
    ]]  ; "attempt" handles potential errors sending mail
    h1 "Read:" 
    f: field "pop://user:pass@site.com"
    btn "Read" [editor to-url f/text]
]

REBOL [title: "My Title"]  ; this appears in the title bar of a GUI window
view layout [
    h3 "SOME POSITIONING EXAMPLES:"
    across
    btn "side" btn "by" btn "side"
    return
    btn "on the next line"
    tab 
    btn "over a bit"
    tab
    btn "over more"
    below
    btn 160 "underneath" btn 160 "one" btn 160 "another"
    at 359x256 
    btn "at 359x256"
]

write/append %save.txt ""            ; A useful data management program
view center-face gui: layout [
    text "Part Number:"
    x: field 560
    text "Part Name:"
    y: field 560
    text "Description:"
    z: area wrap 560x235
    across
    btn "Save" [
        do-face d 1   ; do all the delete button's code
        save %save.txt repend file [x/text y/text z/text]
    ]
    btn "Load" [
        chosen: request-list "Select:" extract (file: load %save.txt) 3
        if chosen = none [return]
        i: index? find file chosen
        x/text: pick file i
        y/text: pick file (i + 1)
        z/text: pick file (i + 2)
        show gui
    ]
    d: btn "Delete" [
        if true = request "Sure?" [
            remove/part (find (file: load %save.txt) x/text) 3
            save %save.txt file
            alert "Done"
        ]
    ]
    btn "Clear" [x/text: copy "" y/text: copy "" z/text: copy "" show gui]
    do [focus x]
]

write/append %recipes.txt ""  ; The program above, altered to hold recipes
view center-face gui: layout [
    text "Recipe Name:"
    x: field 560
    text "Ingredients:"
    y: area wrap 560x135
    text "Preparation Instructions:"
    z: area wrap 560x135
    across
    btn "Save" [
        do-face d 1   ; do all the delete button's code
        save %recipes.txt repend file [x/text y/text z/text]
    ]
    btn "Load" [
        chosen: request-list "Select:" extract (file: load %recipes.txt) 3
        if chosen = none [return]
        i: index? find file chosen
        x/text: pick file i
        y/text: pick file (i + 1)
        z/text: pick file (i + 2)
        show gui
    ]
    d: btn "Delete" [
        if true = request "Sure?" [
            remove/part (find (file: load %recipes.txt) x/text) 3
            save %recipes.txt file
            alert "Done"
        ]
    ]
    btn "Clear" [x/text: copy "" y/text: copy "" z/text: copy "" show gui]
    do [focus x]
]

write/append %s ""           ; A very compact version of the above program
view center-face g: layout [
    h3 "Name:"   x: field   h3 "Info:"   z: area wrap   across
    btn "Save" [do-face d 1  save %s  repend f [x/text z/text]]
    btn "Load" [
        c: request-list" Select:" extract (f: load %s) 2
        if c = none [return]
        x/text: first find f c  z/text: select f x/text  show g
    ]
    btn "New" [x/text: copy ""  z/text: copy ""  show g  focus x]
    d: btn "Delete" [
        if true = request "Sure?" [
            remove/part (find (f: load %s) x/text) 2 save %s f alert "ok"
        ]
    ]
]

s: ftp://user:pass@website.com/public_html/s.txt  ; edit this account info
write/append s ""               ; an Internet version of the above program
view center-face g: layout [
    h3 "Name:"   x: field   h3 "Info:"   z: area wrap   across
    btn "Save" [do-face d 1  save s  repend f [x/text z/text]]
    btn "Load" [
        c: request-list" Select:" extract (f: load s) 2
        if c = none [return]
        x/text: first find f c  z/text: select f x/text  show g
    ]
    btn "New" [x/text: copy ""  z/text: copy ""  show g  focus x]
    d: btn "Delete" [
        if true = request "Sure?" [
            remove/part (find (f: load s) x/text) 2 save s f alert "ok"
        ]
    ]
]
; browse s

; The word "value" refers to data contained in a currently active widget:

view layout [
    text "Some widgets with values and size/color properties.  Try them:"
    button red "Click Me" [alert "You clicked the red button."]
    f: field 400 "Type some text here, then press the [Enter] key" [
        alert value                 ; SAME AS alert f/text
    ]
    t: text-list 400x300 "Select this line" "Then this one" "Now this" [
        alert value                 ; SAME AS alert t/text
    ]
    check yellow [alert "You clicked the yellow check box."]
    button "Quit" [quit]    
]

print "GUI Output:^/"
view layout [
    h1 "Some More GUI Widgets:"
    box red 500x2
    drop-down 200 data system/locale/months [
        a/text: join "Month:  " value show a
    ]
    a: field
    slider 200x18 [bar1/data: value show bar1]
    bar1: progress
    scroller 200x16 [bar2/data: value show bar2]
    bar2: progress
    across 
    toggle "Click here" "Click again" [print value]
    rotary "Click" "Again" "And Again" [print value]
    choice "Choose" "Item 1" "Item 2" "Item 3" [print value]
    return
    x: radio y: radio z: radio
    btn "Get Radio States" [print [x/data y/data z/data]]
    return
    led
    arrow
    below
    code "Code text"
    tt "Typewriter text"
    text "Little Text" font-size 8
    title "Centered title" 500
]

; List Widget:

y: read %.   c: 0   x: copy []
foreach i y [append/only x reduce [(c: c + 1) i (size? to-file i)]]
slider-pos: 0
view center-face layout [
    across space 0
    the-list: list 400x400 [
        across  space 0x0
        text 50 purple
        text 250 bold [editor read to-file face/text]
        text 100 red italic
        return box green 400x1
    ] supply [
        count: count + slider-pos
        if none? q: pick x count [face/text: none exit]
        face/text: pick q index
    ]
    scroller 16x400 [
        slider-pos: (length? x) * value
        show the-list
    ]
]

view layout [
    area 400x400 load http://rebol.com/view/bay.jpg effect [
        Fit Flip Emboss              ; you can fit images on most widgets
    ]
]

effects:  [                          ; and there are MANY more effects:
  invert contrast 40 colorize 0.0.200 gradcol 1x1 0.0.255 255.0.0 tint 100
  luma -80 multiply 80.0.200 grayscale emboss flip 0x1 flip 1x0 rotate 90
  reflect 1x1 blur sharpen aspect tile tile-view
]

view layout [area effect [gradient red blue]]  ; gradients are color fades
view layout [
    size 500x400
    backdrop effect [gradient 1x1 tan brown]
    box effect [gradient 123.23.56 254.0.12]
    box effect [gradient blue gold/2]
]

view layout [
    btn "Right/Left Click Me" [alert "left click"] [alert "right click"]
]

gui: layout [
    across
    btn "Fields"      [window/pane: pane1 show window]
    btn "Text List"   [window/pane: pane2 show window]
    return
    window: box 400x200
]
pane1: layout/tight [field 400 field 400 area 400]
pane2: layout/tight [text-list 400x200 data system/locale/days]
window/pane: pane1
view center-face gui

svv/vid-face/color: white
alert "New global background color is now white."

; The word "offset" refers to a widget's coordinate position.
; The word "style" builds a new widget with the specified style & actions:

view center-face layout [    
    origin 0x0 space 0x0 across   
    style piece button 60x60 [
        if not find [0x60 60x0 0x-60 -60x0] (face/offset - empty/offset) [
            return  ; exit from the widget action (don't do anything else)
        ]
        temp: face/offset
        face/offset: empty/offset 
        empty/offset: temp
    ]
    piece "1"   piece "2"   piece "3"   piece "4" return
    piece "5"   piece "6"   piece "7"   piece "8" return
    piece "9"   piece "10"  piece "11"  piece "12" return
    piece "13"  piece "14"  piece "15"
    empty: piece 200.200.200 edge [size: 0]
]

view center-face layout [
    size 600x440 
    h3 "Press the left or right arrow key"
    key keycode [left]  [alert "You pressed the LEFT arrow key"]
    key keycode [right] [alert "You pressed the RIGHT arrow key"]
    btn #"a" "Click Me or Press the 'a' Key" [alert "clicked or pressed"]
]

; Here's a little program to show all key codes:
insert-event-func func [f e] [if e/type = 'key [print mold e/key] e]
view layout [text "Type keys to see their character/keycode"]

view gui: layout [       ; how to refer to the main layout window:
    btn1: btn "Button 1"
    btn2: btn "Remove all widgets from window" [
        foreach item system/view/screen-face/pane/1/pane [
            remove find system/view/screen-face/pane/1/pane item
        ]
        show gui
    ]
]

; "Feel" and "Engage" together detect events:

view layout [
    text "Mouse me." feel [
        engage: func [face action event] [
            if action = 'up [print "You just released the mouse."]
        ]
    ]
]

print "Click anywhere in the window, then click the text."
view center-face layout [
    size 400x200
    box 400x200 feel [
        engage: func [f a e] [     ; f a e = face action event
            print rejoin ["Mouse " a " at " e/offset]
        ]
    ]
    origin 
    text "Click me" [print "Text clicked"] [print "Text right-clicked"]
    box blue [print "Box clicked"]
]

movestyle: [                     ; generic click and drag code
    engage: func [f a e] [
        if a = 'down [
            initial-position: e/offset
            remove find f/parent-face/pane f
            append f/parent-face/pane f
        ]
        if find [over away] a [
            f/offset: f/offset + (e/offset - initial-position)
        ]
        show f
    ]
]
view layout/size [
    style moveable-object box 20x20 feel movestyle
    at random 600x400 moveable-object (random 255.255.255)
    at random 600x400 moveable-object (random 255.255.255)
    at random 600x400 moveable-object (random 255.255.255)
    at random 600x400 moveable-object (random 255.255.255)
    at random 600x400 moveable-object (random 255.255.255)
    text "This text and all the boxes are movable" feel movestyle
] 600x440

; The following box code creates a repeating, multitasking loop in a GUI.
; The "within" function checks for graphic collisions:

view center-face layout [
    size 400x400
    btn1: btn red
    at 175x175 btn2: btn green
    box 0x0 rate 0 feel [engage: func [f a e] [if a = 'time [
        btn1/offset: btn1/offset + 5x5
        show btn1
        if within? btn1/offset btn2/offset 1x1 [alert "Collision" unview]
    ]]]
]

; Here's another, faster performing way to do GUI loops and multitasking:

gui: view/new center-face layout [
    size 400x400
    btn1: btn red
    at 175x175 btn2: btn green
]
forever [
    wait .02
    btn1/offset: btn1/offset + 5x5  show gui  ;  show btn1
    if within? btn1/offset btn2/offset 1x1 [alert "Collision"]
    if btn1/offset/1 > 300 [alert "done" quit]
]

view center-face layout [                    ; follow all mouse movements
    size 600x440
    at 270x209 b: btn "Click Me!" feel [
        detect: func [f e] [
            if e/type = 'move [
                if (within? e/offset b/offset 59x22) [
                    b/offset: b/offset + ((random 50x50) - (random 50x50))
                    if not within? b/offset -59x-22 659x462 [
                        b/offset: 270x209
                    ]
                    show b
                ]
            ]
            e
        ]
    ]
]

; To trap other events (this example traps and responds to close events):

insert-event-func [
    either event/type = 'close [
        really: request "Really close the program?"
        if really = true [unview]
    ] [event]  ; always return other events
]
view center-face layout [size 600x400]

insert-event-func [                    ; this example traps resize events
    either event/type = 'resize [
        fs: t1/parent-face/size
        t1/offset: fs / 2x2
        t2/offset: t1/offset - 50x25
        t3/offset: t1/offset - 25x50
        show gui  none
    ] [event]
]
svv/vid-face/color: white
view/options gui: layout [
    across
    t1: text "50x50"
    t2: text "- 50x25"
    t3: text "- 25x50"
] [resize]

; Use "to-image" to create a SCREEN SHOT of any layout:

picture: to-image layout [
    page-to-read: field "http://rebol.com"
    btn "Display HTML"
]
save/png %layout.png picture     ; save the image to a file
browse %layout.png

flash "Waiting..."  wait 3  unview         ; a simple info screen
inform layout [btn "Click Me" [flash "Waiting..." wait 3 unview]]

; Embed files (images, sounds, etc.) in code:

system/options/binary-base: 64
editor picture: compress to-string read/binary to-file request-file/only
view layout [image load (to-binary decompress picture)]

logo-pic: load to-binary decompress #{
789C018A0375FC89504E470D0A1A0A0000000D49484452000000640000001808
020000008360CFB90000001374455874536F667477617265005245424F4C2F56
6965778FD916780000033249444154789CD599217402310C86F7CE6227B1481C
1637874362B1382C1687C4A15168240A89C5A2B058ECDEBE47DFFA429276DCEE
10FDCD582F97267FD33F2D7CF47ABDCF32D1ED76E7F3F9ED76FB4EE0743A8D46
A3B6A683A80FFE540562381C1E8FC7144D12DBEDB6951C3B9D4E91648DC7E34C
41B925465D349C14A2CA230BA65EA729E27C3E37CCB43CB228905A3525B1DBED
9A4CED93851C7C193088A0667C0D0603FB5640BFDFB7F648C0D0836B1C41C22E
11D7EBF57038F074BFDF534429BE2693891B4626CE1C59BC7CB95CDC99EEF7FB
66B349F922D65A4B4A8DE0D0B547B9DD85212B6B4CB4D3E994B055FEE8943566
30134626BBDA64052C974BD757A637B1DA2E599959A05EE61F4032D62C55EFBC
6EED01878954188DC80AE714C07126D24F91BBBE6265A129B3D96C2A4085BB64
459FEBF51A1B2692E5A9FA17A428B562EBE595A1F29650AD5C6B9525FD4621E0
A95D73491606F9046C94101A06178B4518E19122023655DA184B03ECA15BE98E
6D9D302E536E8D2C96A5FF0061458FEE9EAA045958720EDCFC82CF145A9E2C7C
52BC6CF0503B8C2B2200DAACD24698A4B710361E6421930E05A85E9484BE51B3
0885AE9727CB22A5591981B73D1AC6A58D2ABD5892DF46C5993DCFF25BC8828E
14538AACEB3390A43C59D890213B5D2AA3D2AC3C59ABD54ACE2E85C29E36DE42
162B8C0AC47F0942B512972CCCF0D91170ED6594ECC130288549ED44744DE52C
771381C571D5AFEDB14B2E79CB022F13C834A056049EFCE35C2A7449877A2B00
2D872635082FEA2D267D8BC047AD910D3875CE9247078A826259FC8234F264E1
9FAD4AAC52015465D973193B3755B611B417FB562A0C66C77EF7001F5463FD83
2CF20F83B2B8E0C22DAE760FA556B32AAF87B86A18C18259CFAA3567C250C7C3
1AE72CD95350531BD93FAE3B6CEADB33188174FCBBD77B7B7A0841DAB6C3EBEE
F13DE8696B6455E222ADCE23F162ECF644064709A47AA8FD3632BFAD78EA5E92
D947500C3BB04CAD419F3D5B05580DC127118E3D2866CAFB8AC6CAFCEB68F895
56796455CF47AAD741F5B957D4D751245980BD569729B723D742A964558FFB4D
EAB6A440BF6ACE54157EB028F7A730B695BDF749D05EA9C1B612C4CF0F396EDC
8E943F5C020000000049454E44AE426082CAEBA2D78A030000
}  ; this example embedded image was created with the script above
view layout [image logo-pic]

; Here are all the main GUI words that you should get to know:

VID-STYLES--GUI-WIDGETS: [
    face blank-face IMAGE BACKDROP BACKTILE BOX BAR SENSOR KEY BASE-TEXT
    VTEXT TEXT BODY TXT BANNER VH1 VH2 VH3 VH4 LABEL VLAB LBL LAB TITLE
    H1 H2 H3 H4 H5 TT CODE BUTTON CHECK CHECK-MARK RADIO CHECK-LINE
    RADIO-LINE LED ARROW TOGGLE ROTARY CHOICE DROP-DOWN ICON FIELD INFO
    AREA SLIDER SCROLLER PROGRESS PANEL LIST TEXT-LIST ANIM BTN BTN-ENTER
    BTN-CANCEL BTN-HELP LOGO-BAR TOG
]
LAYOUT-WORDS: [
    return at space pad across below origin guide tab tabs indent style
    styles size backcolor backeffect do
]
STYLE-FACETS--ATTRIBUTES: [
    edge font para doc feel effect effects keycode rate colors texts help
    user-data with bold italic underline left center right top middle
    bottom plain of font-size font-name font-color wrap no-wrap as-is
    shadow frame bevel ibevel
]
SPECIAL-STYLE-FACETS: [
    ARROW: [up right down left]  ROTARY: data  CHOICE: data  DROP-DOWN: 
    [data rows]  FIELD: hide  INFO: hide  AREA: hide  LIST: [supply map
    data]  TEXT-LIST: data  ANIM: [frames rate]
]


FUNCTIONS:

; ANY string or block of data can be treated like a function:

some-actions: [
    alert "Here is one action." 
    print "Here's a second action."
    write %/c/anotheraction.txt "Here's a third action."
]
do some-actions

write clipboard:// {alert "This code was run from the clipboard"}
do read clipboard://     ; copy, paste and run ANY code this way

write %some-code.r {
    REBOL [] ; executable code saved to a file must begin with this header
    print rejoin [newpage "The code in %some-code.r just ran." newline]
}
do %some-code.r

write ftp://user:pass@site.com/public_html/some-code.r {
    REBOL []
    print "The code in http://site.com/some-code.r just ran."
}
do http://site.com/some-code.r

the-word: to-word request-list "choose a word:" (first system/words)
do rejoin ["help " the-word]         ; you can DO any rejoined text

cls: does [prin "^(1B)[J"]          ; same as "prin newpage"
cls     ; no "do" required when a word is defined with "does"

x: 10
change-x-globally: func [y z] [x: y + z]
change-x-globally 10 20
print x

x: 10
change-x-locally: func [y z /local x] [x: y + z]
change-x-locally 10 20
print x 

compute: func [x y /multiply /divide /subtract] [
    if multiply [return x * y]
    if divide   [return x / y]
    if subtract [return x - y]
    return x + y
]
compute/multiply 10 20
compute/divide 10 20
compute/subtract 10 20
compute 10 20

concatenate-string-or-num: func [
    "This function will only concatenate strings or integers."
    val1 [string! integer!] "First string or integer"
    val2 [string! integer!] "Second string or integer"
] [
    join val1 val2
]
help concatenate-string-or-num
concatenate-string-or-num "Hello " "there."  ; this works correctly
concatenate-string-or-num 10 20              ; this works correctly
concatenate-string-or-num 10.1 20.3          ; this creates an error

do [
    print "^/This example builds a line of code, and then executes it.^/"
    function: ask "Enter a function, such as 'print' or 'editor':  "
    parameter: ask "Enter a parameter, such as some random text:  "
    print rejoin [function { "} parameter {"}]
    do rejoin [function { "} parameter {"}]
    do compose [(to-word function) (parameter)]
    print "That's a very simple way to accomplish metaprogramming tasks."
]

write %imported-func.r {
    REBOL [title: "play-sound"]
    play-sound: func [sound-file] [
        wait 0
        insert sound-port: open sound:// load sound-file
        wait sound-port
        close sound-port
    ]
}
do %imported-func.r
play-sound %/C/WINDOWS/Media/chimes.wav

editor mold :read-cgi                     ; get the code of any function

request: do replace/all mold :request "bold" ""      ; redefine function
request/ok/type "An alert without bold text" 'alert


SEVERAL APPLICATION EXAMPLES:

REBOL [title: "Data Card File"]
write/append %data.txt ""   ; create the file if it doesn't exist
database: load %data.txt
view center-face gui: layout [
    text "Load an existing record:"
    name-list: text-list blue 400x100 data sort (extract database 4) [
        if value = none [return]
        marker: index? find database value
        n/text: pick database marker
        a/text: pick database (marker + 1)
        p/text: pick database (marker + 2)
        o/text: pick database (marker + 3)
        show gui
    ]
    text "Name:"       n: field 400
    text "Address:"    a: field 400
    text "Phone:"      p: field 400
    text "Notes:"      o: area  400x100
    across
    btn "Save" [
        if n/text = "" [alert "You must enter a name." return]
        if find (extract database 4) n/text [
            either true = request "Overwrite existing record?" [
               remove/part (find database n/text) 4
            ] [
               return
            ]
        ]
        save %data.txt repend database [n/text a/text p/text o/text]
        name-list/data: sort (extract copy database 4)
        show name-list
    ]
    btn "Delete" [
        if true = request rejoin ["Delete " n/text "?"] [
            remove/part (find database n/text) 4
            save %data.txt database
            do-face clear-button 1
            name-list/data: sort (extract copy database 4)
            show name-list
        ]
    ]
    clear-button: btn "New" [
        n/text: copy  ""
        a/text: copy  ""
        p/text: copy  ""
        o/text: copy  ""
        show gui
    ]
]


REBOL [title: "Calculator"]
prev-val: cur-val: 0   cur-eval: "+"   display-flag: false
print "0"
view center-face layout/tight [
    size 300x350 space 0x0 across
    display: field 300x50 font-size 28 "0" return
    style butn button 100x50  [
        if display-flag = true [display/text: "" display-flag: false]
        if display/text = "0" [display/text: ""]
        display/text: rejoin [display/text value] 
        show display
        cur-val: display/text
    ]
    style eval button 100x50 brown font-size 13 [
        prev-val: cur-val
        display/text: "" show display
        cur-eval: value
    ]
    butn "1"  butn "2"  butn "3"  return
    butn "4"  butn "5"  butn "6"  return
    butn "7"  butn "8"  butn "9"  return 
    butn "0"  butn "."  eval "+" return
    eval "-" eval "*" eval "/" return
    button 300x50 gray font-size 16 "=" [
        if display-flag <> true [ 
            if ((cur-eval = "/") and (cur-val = "0")) [
                alert "Division by 0 is not allowed." break
            ]
            prin rejoin [prev-val " " cur-eval " " cur-val " = "]
            print display/text: cur-val: do rejoin [
                prev-val " " cur-eval " " cur-val
            ]
            show display
            display-flag: true
        ]
    ]
]


REBOL [title: "Simple Search"]
phrase: request-text/title/default "Text to Find:" "the"
start-folder: request-dir/title "Folder to Start In:"
change-dir start-folder
found-list: ""
recurse: func [current-folder] [ 
    foreach item (read current-folder) [ 
        if not dir? item [  if error? try [
            if find (read to-file item) phrase [
                print rejoin [{"} phrase {" found in:  } what-dir item]
                found-list: rejoin [found-list newline what-dir item]
            ]] [print rejoin ["error reading " item]]
        ]
    ]
    foreach item (read current-folder) [ 
        if dir? item [
            change-dir item 
            recurse %.\
            change-dir %..\
        ] 
    ]
]
print rejoin [{SEARCHING for "} phrase {" in } start-folder "...^/"]
recurse %.\
print "^/DONE^/"
editor found-list
halt


REBOL [title: "Catch Game"]
alert "Arrow keys move left/right (up: faster, down: slower)"
random/seed now/time   speed: 11   score: 0
view center-face layout [
    size 600x440   backdrop white   across
    at 270x0 text "Score:"  t: text bold 100 (form score)
    at 280x20  y: btn 50x20 orange
    at 280x420 z: btn 50x20 blue
    key keycode [left] [z/offset: z/offset - 10x0  show z]
    key keycode [right]  [z/offset: z/offset + 10x0  show z]
    key keycode [up]  [speed: speed + 1]
    key keycode [down]  [if speed > 1 [speed: speed - 1]]
    box 0x0 rate 0 feel [engage: func [f a e] [if a = 'time [
        y/offset: y/offset + (as-pair 0 speed)  show y
        if y/offset/2 > 440 [
            y/offset: as-pair (random 550) 20   show y
            score: score - 1
        ]
        if within? z/offset (y/offset - 50x0) 100x20 [
            y/offset: as-pair (random 550) 20   show y
            score: score + 1
        ]
        t/text: (form score)  show t
    ]]]
]


REBOL [title: "Catch Game"]
random/seed now  s: 0  p: 10
r: func [x] [y/offset: as-pair random 550 20  s: s + x]
view/new center-face g: layout [
    size 600x440  backdrop white  across
    at 270x0    t: text  100    "Score: 0"
    at 280x20   y: btn   50x20  orange
    at 280x420  z: btn   50x20  blue
    key keycode [left]   [z/offset: z/offset - 10x0]
    key keycode [right]  [z/offset: z/offset + 10x0]
    key keycode [up]     [p: p + 1]
    key keycode [down]   [if p > 1 [p: p - 1]]
]
forever [
    y/offset: y/offset + as-pair 0 p
    if overlap? z y [r +1]  if y/offset/2 > 440 [r -1]
    t/text: join "Score: " s  show g  wait .02
]


REBOL [title: "Catch Game"]
s: 1  p: 3  d: 10  n: now/time  random/seed now
r: func [x] [y/offset: random 550x-20  s: s + x  p: p + .1]
view/new g: layout [
    size 600x440  backdrop white  t: text 200
    y: btn red #" " [d: negate d]  at 350x415 z: btn blue 
]
forever [
    y/offset/2: y/offset/2 + round p  z/offset/1: z/offset/1 - d
    if overlap? z y [r +1]  if y/offset/2 > 435 [r -1]
    t/text: rejoin ["Pieces: " s  "  |  Score: " now/time - n]
    show g  wait .01  if s = 0 [alert "Game Over" quit] 
]


REBOL [title: "Catch Game Stop"]
s: 1  p: 3  d: 10  n: now/time  random/seed now
r: func [x] [y/offset: random 550x-20  p: p + .1  s: s + x]
view/new center-face g: layout [
    size 600x440  backdrop white  t: text 200
    y: btn red #" " [d: negate d]  at 350x415 z: btn blue 
]
forever [
    y/offset/2: y/offset/2 + round p   z/offset/1: z/offset/1 - d
    z/offset/1: switch/default z/offset/1 [0 [0 + d] 550 [550 + d]][
        z/offset/1
    ]
    if overlap? z y [r +1]  if y/offset/2 > 420 [r -1]
    t/text: rejoin ["Pieces: " s  "  |  Time: " now/time - n]
    wait .01  if s = 0 [alert t/text quit] show g  
]


REBOL [title: "Catch Game Stop Minimal (favorite)"]
s: 1   p: 3   d: 10   n: now/time   random/seed now 
r: func [x] [y/offset: random 550x-20   p: p + .1   s: s + x]
view/new center-face g: layout[
   size 600x440 t: text 200 y: btn red #" "[d: negate d] at 350x415 z: btn
]
forever [
   y/offset/2: y/offset/2 + round p   z/offset/1: z/offset/1 - d 
   z/offset/1: switch/default z/offset/1[0[0 + d]550[550 + d]][z/offset/1]
   if overlap? z y [r +1]   if y/offset/2 > 420 [r -1]
   t/text: form now/time - n  wait .01  if s = 0[alert t/text quit] show g
]


REBOL [title: "Catch Game Stop Minimal High Score (favorite)"]
s: 1   p: 3   d: 10   n: now/time   random/seed now 
r: func [x] [y/offset: random 550x-20   p: p + .1   s: s + x]
view/new center-face g: layout[
   size 600x440 t: text 200 y: btn red #" "[d: negate d] at 350x415 z: btn
]
forever [
   y/offset/2: y/offset/2 + round p   z/offset/1: z/offset/1 - d 
   z/offset/1: switch/default z/offset/1[0[0 + d]550[550 + d]][z/offset/1]
   if overlap? z y [r +1]   if y/offset/2 > 420 [r -1]
   t/text: form now/time - n  wait .01  show g  if s = 0 [
       write/append %h "" save %h append h: load %h reduce 
       [request-text/title "Name:"t/text now]request-list"High Scores:"h q
   ]
]


REBOL [title: "Catch"]
bonuses: 1
speed: 3   
direction: 10   
starttime: now/time  
random/seed now 
restart: func [add-or-subtract] [
    faller/offset: random 550x-20   
    speed: speed + .1   
    bonuses: bonuses + add-or-subtract
]
view/new center-face gui: layout[
    size 600x440 
    scoreboard: text 200 
    faller: btn red #" " [direction: negate direction]
    at 350x415 player: btn
]
forever [
    faller/offset/2: faller/offset/2 + round speed   
    player/offset/1: player/offset/1 - direction 
    player/offset/1: switch/default player/offset/1 [
       0   [0 + direction]
       550 [550 + direction]
    ][
       player/offset/1
    ]
    if overlap? player faller [restart 1]   
    if faller/offset/2 > 420 [restart -1]
    scoreboard/text: form now/time - starttime
    wait .01
    if bonuses = 0 [
       alert scoreboard/text quit
       write/append %highscores.txt ""
       save %highs.txt append highscores: load %high.txt reduce [
           request-text/title "Name:" scoreboard/text now
       ]
       request-list "High Scores:" highscores
       quit
    ]
    show gui
]


REBOL[]s: 1 p: 3 d: 10 n: now/time random/seed now r: func[x][y/offset:
random 550x-20 p: p + .1 s: s + x]view/new g: layout[size 600x440 t: text
200 y: btn red #" "[d: negate d]at 350x415 z: btn]forever[y/offset/2:
y/offset/2 + round p z/offset/1: z/offset/1 - d z/offset/1: switch/default
z/offset/1[0[0 + d]550[550 + d]][z/offset/1]if overlap? z y[r +1]if
y/offset/2 > 420[r -1]t/text: form now/time - n wait .01 if s = 0[alert
t/text quit]show g]


REBOL[title: "Catch Bounce"]
s: 1   p: 3   d: 10   n: now/time   random/seed now 
r: func [x] [y/offset: random 550x-20   p: p + .1   s: s + x]
view/new center-face g: layout[
   size 600x440 t: text 200 y: btn red #" "[d: negate d] at 350x415 z: btn
]
forever [
   y/offset/2: y/offset/2 + round p   z/offset/1: z/offset/1 - d 
   d: switch/default z/offset/1 [0 [negate d] 550 [negate d]] [d]
   if overlap? z y [r +1]   if y/offset/2 > 420 [r -1]
   t/text: form now/time - n  wait .01  if s = 0[alert t/text quit] show g
]


REBOL[title: "Catch Bounce"]
count: 1   speed: 3   dir: 10   start: now/time   random/seed now 
restart: func [x] [
    faller/offset: random 550x-20
    speed: speed + .1   
    count: count + 1
]
view/new center-face gui: layout [
   size 600x440 
   timer: text 200 
   faller: btn red #" " [dir: negate dir] 
   at 350x415 player: btn
]
forever [
   faller/offset/2: faller/offset/2 + round speed  
   player/offset/1: player/offset/1 - dir 
   if find [0 550] player/offset/1 [dir: negate dir]  
   if overlap? player faller [restart 1]   
   if faller/offset/2 > 420 [restart -1]
   timer/text: form now/time - start
   if count = 0 [alert timer/text quit] 
   wait .01  show gui
]


REBOL [title: "Simple Data Retrieval App - Console"]
users: [
    ["John" "Smith" "123 Tomline Lane" "Forest Hills, NJ" "555-1234"]
    ["Paul" "Thompson" "234 Georgetown Pl." "Peanut Grove, AL" "555-2345"]
    ["Jim" "Persee" "345 Pickles Pike" "Orange Grove, FL" "555-3456"]
    ["George" "Jones" "456 Topforge Court" "Mountain Creek, CO" ""]
    ["Tim" "Paulson" "" "" "555-5678"]
]
a-line: copy [] loop 65 [append a-line "-"]
a-line: trim to-string a-line
print-all: does [
    foreach user users [
        print a-line
        print rejoin ["User:     " user/1 " " user/2]
        print a-line
        print rejoin ["Address:  " user/3 "  " user/4]
        print rejoin ["Phone:    " user/5]
        print newline
    ]
]    
forever [
    prin "^(1B)[J"
    print "Here are the current users in the database:^/"
    print a-line
    foreach user users [prin rejoin [user/1 " " user/2 "  "]]
    print "" print a-line
    prin "Type the name of a user below "
    print "(part of a name will perform search):^/"
    print "Type 'all' for a complete database listing."
    print "Press [Enter] to quit.^/"
    answer: ask {What person would you like info about?  }
    print newline
    switch/default answer [
        "all"     [print-all]
        ""        [ask "Goodbye!  Press any key to end." quit]
        ][
        found: false
        foreach user users [
            if find rejoin [user/1 " " user/2] answer [
                print a-line
                print rejoin ["User:     " user/1 " " user/2]
                print a-line
                print rejoin ["Address:  " user/3 " " user/4]
                print rejoin ["Phone:    " user/5]
                print newline
                found: true
            ]
        ]
        if found <> true [
            print "That user is not in the database!^/"
        ]
    ]
    ask "Press [ENTER] to continue"
]


REBOL [title: "Simple Data Retrieval App - GUI"]
users: [
    ["John" "Smith" "123 Tomline Lane" "Forest Hills, NJ" "555-1234"]
    ["Paul" "Thompson" "234 Georgetown Pl." "Peanut Grove, AL" "555-2345"]
    ["Jim" "Persee" "345 Pickles Pike" "Orange Grove, FL" "555-3456"]
    ["George" "Jones" "456 Topforge Court" "Mountain Creek, CO" ""]
    ["Tim" "Paulson" "" "" "555-5678"]
]
user-list: copy []
foreach user users [append user-list user/1]
user-list: sort user-list
view display-gui: layout [
    h2 "Click a user name to display their information:"
    across
    list-users: text-list 200x400 data user-list [
        current-info: []
        foreach user users [
            if find user/1 value [
                current-info: rejoin [
                    "FIRST NAME:  " user/1 newline newline
                    "LAST NAME:   " user/2 newline newline
                    "ADDRESS:     " user/3 newline newline
                    "CITY/STATE:  " user/4 newline newline
                    "PHONE:       " user/5
                ]
            ]
        ]
        display/text: current-info
        show display show list-users
    ]
    display: area "" 300x400 wrap
]


REBOL [title: "Blogger"]
page: "blog.html"
ftp-url: ftp://user:pass@site.com/public_html/folder/ ; USER/PASS REQUIRED
html-url: join http://site.com/folder/ page
save/png %dot.png to-image layout/tight [box white 1x1]  ; blank image
view center-face gui: layout [
    h2 (form html-url)
    text "Title:"       t: field 400
    text "Link:"        l: field 400
    text "Image:"       i: btn 400 [i/text: request-file show i]
    text "Text:"        x: area  400x100
    across
    btn "Upload" [
        if error? try [existing-text: read html-url] [
            make-dir ftp-url
            write (join ftp-url page) ""
            existing-text: copy ""
        ]
        picture: last split-path to-file i/text
        write/binary (join ftp-url picture) (read/binary to-file i/text)
        write (join ftp-url page) rejoin [
            {<h1>} t/text {</h1>}
            {<img src="} picture {"><br><br>}
            now/date { } now/time { &nbsp; &nbsp; }
            {<a href="} l/text {">} l/text {</a><br><br>}
            {<center><table width=80%><tr><td><pre><strong>}
                x/text 
            {</strong></pre></td></tr></table></center><br><hr>}
            existing-text
        ]
        browse html-url
    ]
    btn "View" [browse html-url]
    btn "Edit" [editor (join ftp-url page)]
]


REBOL [title: "FTP Chat Room"]
webserver: to-url request-text/title/default {
    URL of text file on your server:} "ftp://user:pass@site.com/chat.txt"
name: request-text/title "Enter your name:"
cls: does [prin "^(1B)[J"]
write/append webserver rejoin [now ": " name " has entered the room.^/"]
forever [
    current-chat: read webserver 
    cls
    print rejoin [ 
        "--------------------------------------------------"
        newline {You are logged in as: } name newline 
        {Type "room" to switch chat rooms.} newline
        {Type "lock" to pause/lock your chat.} newline
        {Type "quit" to end your chat.} newline 
        {Type "clear" to erase the current chat.} newline 
        {Press [ENTER] to periodically update the display.} newline 
        "--------------------------------------------------" newline
    ]
    print rejoin ["Here's the current chat text at: " webserver newline]
    print current-chat
    sent-message: copy rejoin [
        name " says: "
        entered-text: ask "You say:  "
    ]
    switch/default entered-text [
        "quit" [break] 
        "clear" [
            if/else request-pass = ["secret" "password"] [
                write webserver ""
            ] [
                alert {
                    You must know the administrator password to clear
                    the room!
                }
            ]
        ]
        "room" [
            write/append webserver rejoin [
                now ": " name " has left the room." newline
            ]
            webserver: to-url request-text/title/default {
                New Web Server Address:} to-string webserver
            write/append webserver rejoin [
                now ": " name " has entered the room." newline
            ]
        ]
        "lock" [
            alert {The program will now pause for 5 seconds. 
                You'll need the correct username and password 
                to continue.
            }
            pause-time: now/time + 5  
            forever [
                if now/time = pause-time [
                    while [
                        request-pass <> ["secret" "password"]
                    ][
                        alert "Incorrect password - look in the source!"
                    ]
                    break
                ]
            ]
        ]
    ][
        if entered-text <> "" [
            write/append webserver rejoin [sent-message newline]
        ]
    ]
]
cls print "Goodbye!" 
write/append webserver rejoin [now ": " name " has closed chat." newline]
wait 1


REBOL [title: "Image Effector"] 
effect-types: [
    "Invert" "Grayscale" "Emboss" "Blur" "Sharpen" "Flip 1x1" "Rotate 90"
    "Tint 83" "Contrast 66" "Luma 150" "None"
]
either exists? %/c/play_sound.r [
    do %/c/play_sound.r
    sound-available: true
][
    sound-available: false
]
image-url: to-url request-text/title/default {
    Enter the URL of an image to use:} trim {
    http://rebol.com/view/demos/palms.jpg}
gui: [
    across 
    space -1 
    at 20x2 choice 160 tan trim {
        Save Image} "View Saved Image" "Download New Image" trim {
            -------------} "Exit" [
        if value = "Save Image" [ 
            filename: to-file request-file/title/file/save trim {
                Save file as:} "Save" %/c/effectedimage.png
            wait 1 save/png filename to-image picture 
        ]
        if value = "View Saved Image" [
            view-filename: to-file request-file/title/file {
                View file:} "" %/c/effectedimage.png
            view/new center-face layout [image load view-filename]
        ]
        if value = "Download New Image" [
            new-image: load to-url request-text/title/default trim {
                Enter a new image URL} trim {
                http://www.rebol.com/view/bay.jpg}
            picture/image: new-image
            show picture
        ]
        if value = "-------------" []  ; don't do anything
        if value = "Exit" [
            if sound-available = true [
                play-sound %/c/windows/media/tada.wav
            ]
            quit
        ]         
    ]
    choice tan "Info" "About" [
        alert "Image Effector - Copyright 2005, Nick Antonaccio"
    ] 
    below 
    space 5 
    pad 2 
    box 550x1 white
    pad 10
    vh1 "Double click each effect in the list on the right:"
    return across
    picture: image load image-url
    text-list data effect-types [
        current-effect: value 
        picture/effect: to-block form current-effect 
        show picture
    ]
]
view/options center-face layout gui [no-title]


rebol [title: "hangman"]
body: [
    [line 1x20 400x20]     [line 200x20 200x40]   [circle 200x60 20]
    [line 200x80 200x120]  [line 200x100 160x80]  [line 200x100 240x80]
    [line 200x120 170x150] [line 200x120 230x150]
]
wrds: remove-each wrd copy first system/words [(length? form wrd) < 4]
foreach c "!?-.~+*'1234567890" [remove-each wrd wrds [find form wrd c]]
random/seed now   wrd: form first random wrds
gui: [
    a: area 400x200 effect [draw []]  across
    starred: text 130 font-size 30 
    text "Guesses: "  guesses: text 200 font-size 25  return
    style bt btn 38x38 [
        append guesses/text copy face/text
        if not find wrd face/text [
            append a/effect/draw body/1
            remove head body
        ]
        foreach char starred/text: copy wrd [
            if not find guesses/text char [
                replace/all starred/text char "*"
            ]
        ] show g
        if wrd = starred/text [alert "You win!"  quit]
        if empty? body [alert join "No, it was: " uppercase wrd  quit]
    ]
    do [loop length? wrd [append starred/text "*"]]
]
repeat c length? chars: "abcdefghijklmnopqrstuvwxyz" [
    append gui reduce ['bt form pick chars c]
    if 0 = (c // 9) [append gui 'return]
]
view center-face g: layout gui


rebol [title: "hangman"]
body: [[circle 200x60 20] [line 200x80 200x120] [line 200x100 160x80]
[line 200x100 240x80] [line 200x120 170x150] [line 200x120 230x150]]
random/seed now   wrd: form first random ["men" "women" "kids"]
view center-face g: layout [
    a: area 400x200 effect [draw []]  across
    s: text 130
    k: text 200   return
    text-list data [a b c d e f g h i j k l m n o p q r s t u v w x y z][
        append k/text form face/picked
        if not find wrd face/picked [
            append a/effect/draw body/1  remove head body
        ]
        foreach char s/text: copy wrd [if not find k/text char [
            replace/all s/text char "*"
        ]] show g
        if wrd = s/text [alert "You win!"  q]
        if empty? body [alert join "No, it was: " wrd  q]
    ]
]


REBOL [Title: "Guitar Chord Diagram Maker"]
fretboard: load 64#{
iVBORw0KGgoAAAANSUhEUgAAAFUAAABkCAIAAAB4sesFAAAACXBIWXMAAAsTAAAL
EwEAmpwYAAAA2UlEQVR4nO3YQQqDQBAF0XTIwXtuNjfrLITs0rowGqbqbRWxEEL+
RFU9wJ53v8DN7Gezn81+NvvZXv3liLjmPX6n/4NL//72s9l/QGbWd5m53dbc8/kR
uv5RJ/QvzH42+9nsZ7OfzX62nfOPzZzzyNUxxh8+qhfVHo94/rM49y+b/Wz2s9nP
Zj+b/WzuX/cvmfuXzX42+9nsZ7OfzX4296/7l8z9y2Y/m/1s9rPZz2Y/m/vX/Uvm
/mWzn81+NvvZ7Gezn8396/4l2/n+y6N/f/vZ7Gezn81+tjenRWXD3TC8nAAAAABJ
RU5ErkJggg==
}
barimage: load 64#{
iVBORw0KGgoAAAANSUhEUgAAAEoAAAAFCAIAAABtvO2fAAAACXBIWXMAAAsTAAAL
EwEAmpwYAAAAHElEQVR4nGNsaGhgGL6AaaAdQFsw6r2hDIa59wCf/AGKgzU3RwAA
AABJRU5ErkJggg==
}
dot: load 64#{
iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAACXBIWXMAAAsTAAAL
EwEAmpwYAAAAFElEQVR4nGNsaGhgwA2Y8MiNYGkA22EBlPG3fjQAAAAASUVORK5C
YII=
}
movestyle: [
    engage: func [f a e] [
        if a = 'down [
            initial-position: e/offset
            remove find f/parent-face/pane f
            append f/parent-face/pane f
        ]
        if find [over away] a [
            f/offset: f/offset + (e/offset - initial-position)
        ]
        show f
    ]
]
gui: [
    backdrop white
    currentfretboard: image fretboard 255x300
    currentbar: image barimage 240x15 feel movestyle
    text "INSTRUCTIONS:" underline
    text "Drag dots and other widgets onto the fretboard."
    across    
    text "Resize the fretboard:"
    tab 
    rotary "255x300" "170x200" "85x100" [
        currentfretboard/size: to-pair value show currentfretboard
        switch value [
            "255x300" [currentbar/size: 240x15 show currentbar]
            "170x200" [currentbar/size: 160x10 show currentbar]
            "85x100" [currentbar/size: 80x5 show currentbar]
        ]
    ]
    return
    button "Save Diagram" [
        filename: to-file request-file/save/file "1.png"
        save/png filename to-image currentfretboard
    ]
    tab
    button "Print" [
        filelist: sort request-file/title "Select image(s) to print:"
        html: copy "<html><body>"
        foreach file filelist [
            append html rejoin [
                {<img src="file:///} to-local-file file {">}
            ]
        ]
        append html [</body></html>]
        write %chords.html trim/auto html
        browse %chords.html 
    ]
]
loop 50 [append gui [at 275x50 image dot 30x30 feel movestyle]]
loop 50 [append gui [at 275x100 image dot 20x20 feel movestyle]]
loop 50 [append gui [at 275x140 image dot 10x10 feel movestyle]]
loop 6 [append gui [at 273x165 text "X" bold feel movestyle]]
loop 6 [append gui [at 273x185 text "O" bold feel movestyle]]
view layout gui


REBOL [Title: "Thumbnail Maker"]
view center-face layout [
    text "Resize input images to this height:"
    height: field "200"
    text "Create output mosaic of this width:"
    width: field "600"
    text "Space between thumbnails:"
    padding-size: field "30"
    text "Color between thumbnails:"
    btn "Select color" [background-color: request-color/color white]
    text "Thumbnails will be displayed in this order:"
    the-images: area
    across
    btn "Select images" [
        some-images: request-file/title trim/lines {Hold
            down the [CTRL] key to select multiple images:} ""
        if some-images = none [return] 
        foreach single-image some-images [
           append the-images/text single-image
           append the-images/text "^/"
        ]
        show the-images
    ]
    btn "Create Thumbnail Mosaic" [
        y-size: to-integer height/text
        mosaic-size: to-integer width/text
        padding: to-integer padding-size/text
        if error? try [background-color: to-tuple background-color][
            background-color: white
        ]
        images: copy parse/all the-images/text "^/"   ; see "PARSE" below
        if empty? images [alert "No images selected." break]
        mosaic: compose [
            backcolor (background-color) space (padding) across
        ]
        foreach picture images [
             flash rejoin ["Resizing " picture "..."]
             original: load to-file picture
             unview
             either original/size/2 > y-size [
                 new-x-factor: y-size / original/size/2
                 new-x-size: round original/size/1 * new-x-factor
                 new-image: to-image layout/tight [
                     image original as-pair new-x-size y-size
                 ]
                 append mosaic compose [image (new-image)]
             ][
                 append mosaic compose [image (original)]
             ]
             current-layout: layout/tight mosaic
             if current-layout/size/1 > mosaic-size [
                 insert back back tail mosaic 'return
             ]
        ]
        filename: to-file request-file/file/save "mosaic.png"
        save/png filename (to-image layout mosaic)
        view/new layout [image load filename]
    ]
]


REBOL [title: "Table Grid Example"]
x: copy [] for i 1 179 1 [append x reduce [i random "abcd"]]
update: does [q: copy [] foreach face g/pane/pane [append q face/text]]
do qq: [grid: copy [across space 0]
forskip x 2 [append grid compose [
    field (form x/1) 40 edge none 
    field (form x/2) 260 edge [size: 1x1] return
]]
view center-face gui: layout [across space 0
    g: box 300x290 with [pane: layout/tight grid pane/offset: 0x0]
    slider 16x290 [
        g/pane/offset/y: g/size/y - g/pane/size/y * value show g
    ]
    return btn "Add" [
        row: (to-integer request-text/title "Insert at Row #:") * 2 - 1
        update insert at q row ["" ""] x: copy q unview do qq
    ]
    btn "Remove" [
        row: (to-integer request-text/title "Row # to delete:") * 2 - 1
        update remove/part (at q row) 2 x: copy q unview do qq
    ]
    btn "Col 1" [update editor extract q 2]
    btn "Col 2" [update editor extract/index q 2 2]
    btn "Save" [update save to-file request-file/save q]
    btn "Load" [x: load to-file request-file do qq]
    btn "History" [
        m: copy "ITEMS YOU'VE EDITED:^/^/" update for i 1 (length? q) 1 [
            if (to-string pick x i) <> (to-string pick q i) [
                append m rejoin [pick x i " " pick q i newline]
            ]
        ] editor m 
    ]
]]


REBOL [title: "Jigsaw Puzzle - press SPACE for original image"]
random/seed now
pic: load request-file/only/filter ["*.png" "*.gif" "*.jpg" "*.bmp"]
siz: pic/size
while [any [
    siz/1 > system/view/screen-face/size/1 
    siz/2 > system/view/screen-face/size/2
]] [
    siz: siz * .8   pic: to-image layout/tight [image pic siz]
]
divs: request-list "How many pieces?" [4 16 36 64 100 144 256 400]
sqr: square-root divs
x-size: round (siz/x / sqr)
y-size: round (siz/y / sqr)
p-size: as-pair x-size y-size
end: false
movestyle: [
    engage: func [f a e] [if end = false [
        if a = 'down [
            f/data: e/offset
            remove find f/parent-face/pane f
            append f/parent-face/pane f
        ]
        if find [over away] a [
            unrounded-pos: (f/offset + e/offset - f/data)
            snap-x: (round/to first unrounded-pos x-size)
            snap-y: (round/to second unrounded-pos y-size)
            either any [
                snap-x >= siz/1  snap-x < 0  snap-y >= siz/2  snap-y < 0
            ] [f/offset: unrounded-pos] [f/offset: as-pair snap-x snap-y]
        ]
        show f
        if all [a = 'up  pic = to-image system/view/screen-face/pane/1] [
            end: true  alert "Congratulations - you finished!"
        ]
    ]]
]
gui: compose [size (siz) key #" " [view/new layout [image (pic)]]]
repeat i (to-integer sqr) [
    repeat ii (to-integer sqr) [
        pos: as-pair (x-size * (ii - 1)) (y-size * (i - 1))
        append gui compose/deep [
            at random (siz - p-size) image pic (p-size) effect compose [
                crop (pos) (p-size)
            ] feel movestyle
        ]
    ]
]
alert {Press the space bar at any time to view the original image.}
view center-face layout/tight gui


HOW TO CREATE WINDOWS .EXE PROGRAMS FROM REBOL SCRIPTS:

1) Download XpackerX from: 
    http://www.marmaladefoo.com/downloadables/XpackerX-v0.3.2-setup.exe
2) Edit the following .xml file (save it in same folder as your script).
3) Click the red "!" button (make executable) in XpackerX.

<?xml version="1.0"?>
<xpackerdefinition>
    <general>
        <!--shown in taskbar -->
        <appname>your_program_name</appname>
        <exepath>your_program_name.exe</exepath>
        <showextractioninfo>false</showextractioninfo>
        <!-- <iconpath>c:\icon.ico</iconpath> -->
    </general>
    <files>
        <file>
            <source>your_rebol_script.r</source>
            <destination>your_rebol_script.r</destination>
        </file>
        <file>
            <source>C:\Program Files\rebol\view\Rebol.exe</source>
            <destination>rebol.exe</destination>
        </file>
        <!--put any other data files here -->
    </files>
    <!-- $FINDEXE, $TMPRUN, $WINDIR, $PROGRAMDIR, $WINSYSDIR -->
    <onrun>$TMPRUN\rebol.exe -si $TMPRUN\your_rebol_script.r</onrun>
</xpackerdefinition>

XpackerX is just an "sfx" packager that compresses the REBOL interpreter
and your scripts into an executable zip file.  When that .exe file is run,
it automatically unpacks your file(s) then runs REBOL with the script file
you specify.  You can use most zip programs to do the same thing.  Find
the option in your zipping program to "create sfx", "self-extracting zip",
or "executable zip" file.  Put the REBOL interpreter, your script(s), and
any other supporting files (images, sounds, dlls, executables, etc.), and
be sure that the sfx file automatically runs "rebol.exe -si 
your_rebol_script.r" (or whatever you name the main script to be run).

To create a Linux executable:

1) Tar REBOL interpreter, script(s), and resources into %rebol_files.tgz
2) Create this %sh_commands file (without the beginning tabs):
    #!/bin/sh
    SKIP=`awk '/^__REBOL_ARCHIVE__/ { print NR + 1; exit 0; }' $0`
    tail +$SKIP $0 | tar xz    
    exit 0
    __REBOL_ARCHIVE__
3) Combine the above script with the bundled .tgz file, using this line:
    cat sh_commands rebol_files.tgz > rebol_program.sh
4) Set permissions and run:
    chmod +x rebol_program.sh  (or run it with "sh rebol_program.sh")

In general, instead of creating executable files, it's easiest to have
users simply download and install the REBOL interpreter, and then just
click any downloaded ".r" file icons in their file manager.


PARSE (goodbye regex):

my-text: {"apple","orange","pear"}
parsed-block: parse my-text none

code: "text1 <% replace this %> <% replace this %> text3"
parse/all code [
    any [thru "<%" copy new to "%>" (replace code new " text2 ")] to end
]
print code

some-text: {    First Name
           Last Name
           Street Address
           City, State, Zip}
parsed-block: parse/all some-text "^/"
foreach item parsed-block [trim item]
probe parsed-block

parse read http://guitarz.org/ip.cgi [
    thru <title> copy my-ip to </title>
]
parse my-ip [
    thru "Your IP Address is: " copy stripped-ip to end
]
alert to-string rejoin [
    "External: " trim/all stripped-ip "  "
    "Internal: " read join dns:// read dns://
]

html: read http://musiclessonz.com/ScreenShots.html
x: copy []
parse html [any [thru {src="} copy link to {"} (append x link)] to end]
make-dir %./downloaded-images
change-dir %./downloaded-images
foreach i x [attempt [
    print rejoin ["downloading:  " i] 
    write/binary (to-file last split-path to-url i) (read/binary to-url i)
]]
foreach i read %. [view center-face layout [image (load i)]]

bb:  "some text http://guitarz.org http://yahoo.com"
bb_temp: copy bb
append bb_temp " "
append bb " "
parse bb [any [thru "http://" copy link to " " (
    replace bb_temp (rejoin [{http://} link]) (rejoin [
    {<a href="} {http://} link {" target=_blank>http://} 
    link {</a>}]))] to end
]
bb: copy bb_temp
print bb

code: {
    view layout [
        btn "some text"
        btn "some more text"
    ] 
}
strings: copy []
parse code [
    any [thru {"} copy a-string to {"} (append strings a-string)] to end
]
foreach str strings [
    if true = request rejoin [{Change "} str {"?}] [
        replace/all code str request-text/title rejoin [
            {Change "} str {" to:}
        ]
    ]
]
editor code

code: read to-file request-file
parse/all code [any [
    to #";" begin: thru newline ending: (
        remove/part begin ((index? ending) - (index? begin))) :begin
    ]
]
editor code  ; all comments removed

filename: %filename.csv
data: copy []
lines: read/lines filename
foreach line lines [
    append/only data parse/all line ","
]
info: copy ""
foreach line data [
    either find "Header" line/1 [
        info: line/1
    ][
        append line info
    ]
]
remove-each line data [find "Header" line/1/1]
remove-each line data [
    (line/3 = "TITLE") or (line/3 = "DESCRIPTION")
]

format-decimal: func [x /local q] [ 
    either find form x "E-" [ 
        insert/dup (head replace (first q: parse form x "E-") "." "")
            "0" ((to-integer q/3) - 1) 
        insert head q/1 "0." 
        q/1 
    ] [form x] 
]    
format-decimal 1 / 233 
format-decimal 1 / 4 
format-decimal 5 * 7 
format-decimal 1 / 83723923452346546467
1 / to-decimal format-decimal 1 / pi


DLLs, SO, and DYLIB LIBRARIES:

lib: load/library %kernel32.dll
play-sound: make routine! [
    return: [integer!] pitch [integer!] duration [integer!]
] lib "Beep"
for hertz 37 3987 50 [
    print rejoin ["The pitch is now " hertz " hertz."]
    play-sound hertz 50
]
free lib

lib: load/library %winmm.dll
mciExecute: make routine! [c [string!] return: [logic!]] lib "mciExecute"
if not exists? %test.avi [
    flash "Downloading test video..."
    write/binary %test.avi read/binary http://re-bol.com/test.avi
    unview
]
video: to-local-file %test.avi
mciExecute rejoin ["OPEN " video " TYPE AVIVIDEO ALIAS thevideo"]
mciExecute "PLAY thevideo WAIT"
mciExecute "CLOSE thevideo"
free lib
quit

do [
    lib: load/library %winmm.dll
    mciExecute: make routine! [ 
        command [string!]
        return: [logic!] 
    ] lib "mciExecute"
    file: to-local-file to-file request-file/save/title/file "Save as:" {
        } %rebol-recording.wav
    mciExecute "open new type waveaudio alias buffer1 buffer 6"
    mciExecute "record buffer1"
    ask "RECORDING STARTED (press [ENTER] when done)...^/"
    mciExecute "stop buffer1"
    mciExecute join "save buffer1 " file
    free lib
    print "Recording complete.  Here's how it sounds:^/"
    insert snd: open sound:// load to-rebol-file file wait snd close snd
    print "DONE.^/"
]

do [
    if not exists? %AutoItDLL.dll [
        write/binary %AutoItDLL.dll
        read/binary http://musiclessonz.com/rebol_tutorial/AutoItDLL.dll
    ]
    lib: load/library %AutoItDLL.dll
    move-mouse: make routine! [
        return: [integer!] x [integer!] y [integer!] z [integer!]
    ] lib "AUTOIT_MouseMove"
    print "Press the [Enter] key, and your mouse will move to the top"
    ask "corner of your screen, and then down diagonally to 200x200:  " 
    for position 0 200 5 [
        move-mouse position position 10 
    ]
    free lib
    print "^/Done.^/"
    halt
]

avicap32.dll: load/library %avicap32.dll
user32.dll: load/library %user32.dll
find-window-by-class: make routine! [
    ClassName [string!] WindowName [integer!] return: [integer!]
] user32.dll "FindWindowA"
sendmessage: make routine! [
    hWnd [integer!] val1 [integer!] val2 [integer!] val3 [integer!]
    return: [integer!]
] user32.dll "SendMessageA"
sendmessage-file: make routine! [
    hWnd [integer!] val1 [integer!] val2 [integer!] val3 [string!]
    return: [integer!]
] user32.dll  "SendMessageA"
cap: make routine! [
    cap [string!] child-val1 [integer!] val2 [integer!] val3 [integer!]
    width [integer!] height [integer!] handle [integer!] 
    val4 [integer!] return: [integer!]
] avicap32.dll "capCreateCaptureWindowA"
view/new center-face layout/tight [
    image 320x240
    across
    btn "Take Snapshot" [
        sendmessage cap-result 1085 0 0
        sendmessage-file cap-result 1049 0 "scrshot.bmp"
        browse %scrshot.bmp
    ]
    btn "Exit" [
        sendmessage cap-result 1205 0 0
        sendmessage cap-result 1035 0 0
        free user32.dll   quit
    ]
]
hwnd: find-window-by-class "REBOLWind" 0
cap-result: cap "cap" 1342177280 0 0 320 240 hwnd 0
sendmessage cap-result 1034 0 0
sendmessage cap-result 1077 1 0
sendmessage cap-result 1075 1 0
sendmessage cap-result 1074 1 0
sendmessage cap-result 1076 1 0
do-events

tt: "Your Title"
user32.dll: load/library %user32.dll
gf: make routine![return:[int]]user32.dll"GetFocus"
sc: make routine![hw[int]a[string!]return:[int]]user32.dll"SetWindowTextA"
so: :show show: func[face][so[face]hw: gf sc hw tt]
view layout [text 400x400 "No 'REBOL -' in the title bar!"]


CGI:

#! /home/your_user_path/public_html/rebol/rebol -cs
REBOL [title: "Photo Viewer"]
print {content-type: text/html^/}
print {<HTML><HEAD><TITLE>Photos</TITLE></HEAD><BODY>}
; print read %template_header.html
folder: read %.
count: 0
foreach file folder [
    foreach ext [".jpg" ".gif" ".png" ".bmp"] [
        if find file ext [
            print [<BR> <CENTER>]
            print rejoin [{<img src="} file {">}]
            print [</CENTER>]
            count: count + 1
        ]
    ]
]
print {<BR>}
print rejoin [{Total Images: } count]
print {</BODY></HTML>}
; print read %template_footer.html
quit

#! ./rebol -cs
REBOL [title: "Generic CGI Application, With HTML Form"]
print {content-type: text/html^/}
submitted: decode-cgi system/options/cgi/query-string
print {<HTML><HEAD><TITLE>Page title</TITLE></HEAD><BODY>}
either empty? submitted [
    print {
        <FORM ACTION="http://yourwebserver.com/this_rebol_script.cgi">
        <INPUT TYPE="TEXT" NAME="username" SIZE="25">
        <INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit">
        </FORM>
        </BODY></HTML>
    }
] [ 
    print rejoin [{Hello } second submitted {!}]
    print {</BODY></HTML>}
]

#! ./rebol -cs
REBOL [title: "CGI Logic"]
print {content-type: text/html^/}
submitted: decode-cgi system/options/cgi/query-string
if submitted/2 = "option1" [
    print "Now Doing Code For Option 1"
    quit
]
if submitted/2 = "option2" [
    print "Now Doing Code For Option 2"
    quit
]
options: ["option1" "option2"]
print {
    <FORM ACTION="./options.cgi">
    <select NAME="option">}
    foreach o options [prin rejoin [{<option>} o]]
    print {</option> </select>
    <INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit">
    </FORM>
    </BODY></HTML>
}
quit

#! ./rebol -cs
REBOL [title: "Generic GET and POST Form Handler"]
write %form.html {
    <FORM action="form.cgi">
        Name:<BR><INPUT type="TEXT" name="name"><BR><BR>
        Email:<BR><INPUT type="TEXT" name="email"><BR><BR>
        Message:<BR>
            <TEXTAREA cols="75" rows="5" name="message">
            </TEXTAREA><BR><BR>
        <INPUT type="SUBMIT" name="Submit" value="Submit">
    </FORM>
}
print {content-type: text/html^/}
switch system/options/cgi/request-method [
    "POST" [
        cgi-data: copy ""  cgi-buffer: copy ""
        while [positive? read-io system/ports/input cgi-buffer 16380] [
            append cgi-data cgi-buffer clear cgi-buffer
        ]
    ]
    "GET" [cgi-data: system/options/cgi/query-string]
]
submitted: decode-cgi cgi-data
print {
    <HTML><HEAD><TITLE>Your Form Has Been Submitted</TITLE></HEAD>
    <BODY><CENTER><TABLE border=0 cellPadding=10 width="80%"><TR><TD>
}
entry: rejoin [{[^/ "Time Stamp:" } {"} form (now + 3:00) {"^/}]
foreach [title value] submitted [
    entry: rejoin [entry { } {"} mold title {" } mold value {^/}]
]
append entry {]^/}
write/append %submitted_forms.txt entry
html: copy ""
foreach [title value] submitted [
    repend html [
        <TR><TD width=20%> mold title </TD><TD> mold value </TD></TR>
    ]
]
print rejoin [
    {
         <FONT size=5>Thank You! The following information has been
         submitted: </FONT><BR><BR>Time Stamp:
    } 
    now + 3:00  {<BR><BR><TABLE border=1 cellPadding=10 width="100%">}
    html  {</TABLE><BR>}
    {  
        You'll hear from us shortly!<BR><BR><CENTER><FONT size=1>
        Copyright  2009 This Web Site.  All rights reserved.</FONT>
        </CENTER></TD></TR></CENTER></BODY></HTML>
    }
]
quit

#! ./rebol -cs
REBOL [title: "Copy All Files to New Web Server"]
print "content-type: text/html^/"
print [<HTML><HEAD><TITLE>"wgetter"</TITLE></HEAD><BODY>]
foreach file (read ftp://user:pass@site.com/public_html/path/) [
    print file
    print <BR>
    write/binary (to-file file) 
        (read/binary (to-url (rejoin [http://site.com/path/ file])))
]
print [</BODY></HTML>] quit


#!/usr/bin/rebol.exe -cs
REBOL [title "HTML form builder (CRUD app maker)"]
print "content-type: text/html^/"
print [<HTML><HEAD><TITLE>"Formbuilder"</TITLE></HEAD><BODY>]
submitted: decode-cgi submitted-bin: read-cgi
if ((submitted/2 = none) or (submitted/4 = none)) [
    print rejoin [{
    <FORM METHOD="post">
      Form File: <BR>
      <input type=text size="50" value="form1.html" name="formtitle"><BR>
      Data File: <br>
      <input type=text size="50" value="form1data.db" name="datafile"><BR>
      FORM CHECK BOX OPTIONS:<BR>
      <TEXTAREA COLS="40" ROWS="3" NAME="checks">}
          {Uploaded To Server^/Private/Secure</TEXTAREA><br>
      FORM TEXT ENTRY FIELDS:<br>
      <TEXTAREA COLS="40" ROWS="3" NAME="texts">}
          {Name^/Date^/Location^/Device Model^/File Name</TEXTAREA><br>
      FORM TEXT ENTRY AREAS:<br>
      <TEXTAREA COLS="40" ROWS="3" NAME="areas">}
          {Description^/Notes</TEXTAREA><br>
      FORM DROPDOWN SELECTIONS:<br>
      <TEXTAREA COLS="40" ROWS="3" NAME="drops">}
          {---COLOR^/Red^/Green^/Blue^/---OPTION^/AAA^/BBB^/CCC}
          {</TEXTAREA><br><br>
      <INPUT TYPE=hidden NAME="formsubmitted" VALUE="formsubmitted">
      <INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit">
    </FORM>
    </BODY></HTML>}]
    quit
]
if submitted/14 ="formsubmitted" [
    checks: parse/all submitted/6 "^/" remove-each i checks [i = ""]
    texts: parse/all submitted/8 "^/" remove-each i texts [i = ""]
    areas: parse/all submitted/10 "^/" remove-each i areas [i = ""]
    drops: parse/all submitted/12 "^/" remove-each i areas [i = ""]
    title: submitted/2
    data-file: to-file submitted/4
    poll: copy {<FORM METHOD="post" action="index.cgi">^/}  
    ; EDIT ABO8VE TO MATCH FILE NAME OF THIS SCRIPT
    append poll {<INPUT TYPE=hidden NAME="formdata" VALUE="formdata">^/}
    append poll rejoin [
        {<INPUT TYPE=hidden NAME="datafile" VALUE="} data-file {">^/}
    ]
    repeat i len: length? checks [
        append poll rejoin [
            {<input type="checkbox" name="checks" value="} i {">}
            checks/:i {<br>} newline
        ]
    ]
    append poll {<br>}
    repeat i len: length? texts [
        append poll rejoin [
            texts/:i {:<br><INPUT TYPE="TEXT" NAME="text} i 
            {" SIZE="38"><br>} newline
        ]
    ]
    append poll {<br>}
    repeat i len: length? areas [
        append poll rejoin [
            areas/:i {:<br><TEXTAREA COLS="40" ROWS="3" NAME="area} i
            {"></TEXTAREA><br>} newline
        ]
    ]
    append poll {<br>}
    repeat i len: length? drops [
        either find drops/:i "---" [
            closer: either i = 1 [{}][{</option></select><br>}]
            append poll rejoin [
                closer newline droptitle: replace/all drops/:i "---" ""
                {: <select NAME="} droptitle {">}
            ]
        ][
            append poll rejoin [{<option>} drops/:i]
        ]
    ]
    append poll {</option></select><br>^/}
    append poll {<br><INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit">
        </FORM>}
    write to-file submitted/2 poll 
    print rejoin [
        {<strong><a href="./} submitted/2 {">} submitted/2
        {</a></strong> created:<br><br>}
    ]
    print poll
]
if submitted/2 = "formdata" [
    append submitted reduce [to-set-word 'timestamp now]
    write/append to-file submitted/4 mold at submitted 5
    print "<strong>Saved:</strong><br><br>" 
    probe submitted
]
quit



DRAW:

view layout [
    box 400x400 black effect [
        draw [
            pen red
            line 0x400 400x50
            pen white
            box 100x20 300x380
            fill-pen green
            circle 250x250 100
            pen blue
            fill-pen orange
            line-width 5
            spline closed 3 20x20 200x70 150x200
            polygon 20x20 200x70 150x200 50x300
        ]
    ]
]

view layout [
    box 400x220 effect [
        draw [
            fill-pen 200.100.90
            polygon 20x40 200x20 380x40 200x80
            fill-pen 200.130.110
            polygon 20x40 200x80 200x200 20x100
            fill-pen 100.80.50
            polygon 200x80 380x40 380x100 200x200
        ]
        gradmul 180.180.210 60.60.90
    ]
]

view layout [
    scrn: box black 400x400 feel [
        engage: func [face action event] [
            if find [down over] action [
                append scrn/effect/draw event/offset
                show scrn
            ]
            if action = 'up [append scrn/effect/draw 'line]
        ]
    ] effect [draw [line]]
]

pos: 300x300
view layout [
    scrn: box pos black effect [
        draw [image logo.gif 0x0 300x0 300x300 0x300]
    ]
    btn "Animate" [
        for point 1 140 1 [
            scrn/effect/draw: copy reduce [
                'image logo.gif 
                (pos - 300x300)
                (1x1 + (as-pair 300 point))
                (pos - (as-pair 1 point))
                (pos - 300x0)
            ]
            show scrn
        ]
        scrn/effect/draw: copy [
            image logo.gif 0x0 300x0 300x300 0x300
        ]
        show scrn
    ]
]


HELP:

what
help call
? call
? "request"
? system
? system/console/history
? system/options
? system/locale/months
? system/network/host-address
? system/view/VID
? svv
editor extract svv/vid-styles 2
editor svv/vid-words
editor svv/facet-words
svv/vid-styles/TEXT-LIST/words

source for
editor mold :for

echo %words.txt what echo off   ; "echo" saves console activity to a file
echo %help.txt
foreach line read/lines %words.txt [
    word: first to-block line
    print "___________________________________________________________^/"
    print rejoin ["word:  " uppercase to-string word]  print "" 
    do compose [help (to-word word)]
]
echo off
editor at read %help.txt 4


PORTS:

help open

write/append %temp.txt "1234"  ; this line is the same as:
temp: open %temp.txt
append temp "1234"
close temp

; See ALL the properties of a port using "probe":

temp: open %temp.txt
probe temp
close temp

temp: open %temp.txt
print temp/date
print temp/path
print temp/size
close temp

my-file: open %temp.txt
set-modes my-file [
    world-read: true
    world-write: true
    world-execute: true
]
close my-file

write %temp.txt ""
print read %temp.txt
temp: open %temp.txt
append temp "1234"
print temp/state/inBuffer
print read %temp.txt
update temp
print read %temp.txt
temp: head temp
insert temp "abcd"
print temp/state/inBuffer
print read %temp.txt
close temp
print read %temp.txt
append temp "1q2w3e4r"  ; (error)

print second read pop://user:pass/site.com ; requires download of ALL mail
my-email: open pop://user:pass/site.com
print second my-email         ; port version only downloads single message

the-sound: load %/c/windows/media/tada.wav
insert s: open sound:// the-sound wait s close s

print ""
q: open/binary/no-wait console://
forever [if wait q [print join "You typed:  " to-integer copy q]]

q: open/binary/no-wait console:// 
while [120 <> x: to-integer copy wait q] [print join "You typed:  " x]
print "Goodbye!" wait 2

x: open/direct/lines %input.txt                    ; for very large files
while [not empty? data: copy/part x 10] [
   probe data
   ask "continue..."
]
close file


NETWORK PORTS:

; server (run this script first):

port: first wait open/lines tcp://:55555
print join "Received: "first wait port

; client (run this script second, in a separate instance of REBOL):

port: open/lines tcp://localhost:55555
insert port ask "Send:  "


REBOL [title: "Network Text Messenger"]
view layout [ across
    q: btn "Serve"[focus g p: first wait open/lines tcp://:8 z: 1]text"OR"
    k: btn "Connect"[focus g p: open/lines rejoin[tcp:// i/text ":8"]z: 1]
    i: field form read join dns:// read dns://  return
    r: area rate 4 feel [engage: func [f a e][if a = 'time and value? 'z [
        if error? try [x: first wait p] [quit]
        r/text: rejoin [x "^/" r/text] show r
    ]]]  return
    g: field "Type message here [ENTER]" [insert p value  focus face]
]


REBOL [title: "Network Binary File Transfer"]
; server/receiver - run first:
if error? try [port: first wait open/binary/no-wait tcp://:8] [quit]
mark: find file: copy wait port #""
length: to-integer to-string copy/part file mark
while [length > length? remove/part file next mark] [append file port]
view layout [image load file]
; client/sender - run after server (change IP address if using on 2 pcs):
save/png %image.png to-image layout [box blue "I traveled through ports!"]
port: open/binary/no-wait tcp://127.0.0.1:8  ; adjust this IP address
insert file: read/binary %image.png join l: length? file #""
insert port file


REBOL [title: "VOIP Intercom"] do [write %ireceive.r {REBOL []
if error? try [port: first wait open/binary/no-wait tcp://:8] [quit]
wait 0  speakers: open sound://
forever [
    if error? try [mark: find wav: copy wait port #""] [quit]
    i: to-integer to-string copy/part wav mark
    while [i > length? remove/part wav next mark] [append wav port]
    insert speakers load to-binary decompress wav
]} launch %ireceive.r
lib: load/library %winmm.dll
mci: make routine! [c [string!] return: [logic!]] lib "mciExecute"
if (ip: ask "Connect to IP (none = localhost):  ") = "" [ip: "localhost"]
if error? try [port: open/binary/no-wait rejoin [tcp:// ip ":8"]] [quit]
mci "open new type waveaudio alias wav"
forever [
    mci "record wav"  wait 2  mci "save wav r"  mci "delete wav from 0"
    insert wav: compress to-string read/binary %r join l: length? wav #""
    if l > 4000 [insert port wav]  ; squelch (don't send) if too quiet
]]


REBOL [title: "HTML Form Generator and Server"]
view center-face gui: layout [
    style area area 500x100
    across
    h4 200 "Form Title:" 
    h4 200 "Data File:" return
    f1: field 200 "Form #1"
    f2: field 200 "form1.db"
    below
    h4 "FORM CHECK BOX OPTIONS:"
    a1: area {Uploaded To Server^/Private/Secure}
    h4 "FORM TEXT ENTRY FIELDS:"
    a2: area {Name^/Date^/Location^/Device Model^/File Name}
    h4 "FORM TEXT ENTRY AREAS:"
    a3: area {Description^/Notes}
    h4 "FORM DROPDOWN SELECTIONS:"
    a4: area {---COLOR^/Red^/Green^/Blue^/---OPTION^/AAA^/BBB^/CCC}
    across
    btn "SUBMIT" [
        checks: parse/all a1/text "^/" remove-each i checks [i = ""]
        texts: parse/all a2/text "^/" remove-each i texts [i = ""]
        areas: parse/all a3/text "^/" remove-each i areas [i = ""]
        drops: parse/all a4/text "^/" remove-each i areas [i = ""]
        title: join uppercase f1/text ":"
        data-file: to-file f2/text
        unview
    ]
    btn "Save" [
        save to-file request-file/save/file %formsettings reduce [
            f1/text f2/text a1/text a2/text a3/text a4/text
        ]
    ]
    btn "Load" [attempt [
        settings: load to-file request-file/file %formsettings
        f1/text: settings/1 f2/text: settings/2 a1/text: settings/3
        a2/text: settings/4 a3/text: settings/5 a4/text: settings/6
        show gui
    ]]
]
poll: copy "^/"
repeat i len: length? checks [
    append poll rejoin [
        {<input type="checkbox" name="checks" value="} i {">}
        checks/:i {<br>} newline
    ]
]
append poll {<br>}
repeat i len: length? texts [
    append poll rejoin [
        texts/:i {:<br><INPUT TYPE="TEXT" NAME="text} i 
        {" SIZE="38"><br>} newline
    ]
]
append poll {<br>}
repeat i len: length? areas [
    append poll rejoin [
        areas/:i {:<br><TEXTAREA COLS="40" ROWS="3" NAME="area} i 
        {"></TEXTAREA><br>} newline
    ]
]
append poll {<br>}
repeat i len: length? drops [
    either find drops/:i "---" [
        closer: either i = 1 [{}][{</option></select><br>}]
        append poll rejoin [
            closer newline droptitle: replace/all drops/:i "---" ""
            {: <select NAME="} droptitle {">}
        ]
    ][
        append poll rejoin [{<option>} drops/:i]
    ]
]
append poll {</option></select><br>^/}
append poll {<br><INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit">^/}
either exists? data-file [responses: load data-file][responses: copy[]]
port: open/lines tcp://:80
l: read join dns:// read dns://
print rejoin ["Waiting on:  " l] 
browse join l "?"
forever [
    p: first port
    if error? try [
        z: decode-cgi replace next find first p "?" " HTTP/1.1" ""
        if not empty? z [
            append z reduce [to-set-word 'timestamp now]
            append/only responses z
            save data-file responses
            received: construct z  ?? received
        ]
        d: rejoin [
            {HTTP/1.0 200 OK^/Content-type: text/html^/^/
            ^/<HTML><BODY><FORM ACTION="} l {">} title {<br><br>} poll
            {</FORM></BODY></HTML>}
        ] 
        write-io p d length? d
    ] [] ;[print "(empty submission)"]
    close p
]
halt


rebol [title: "Search HTML Logs"]
; Searching data using 'construct to create objects, see more below
data: load %./form1.db
view layout [
    h4 "Search Phrase:"
    f1: field
    h4 "Search Fields: (CTRL to select multiple)"
    t1: text-list data ["text1" "text2" "text3" "text4" "text5" "area1"]
    btn "Search" [
        foreach record data [
            obj: construct record
            foreach field t1/picked [
                if find (get in obj to-lit-word field) f1/text [
                    print rejoin [
                        mold f1/text " found in " field ", " obj/timestamp
                    ]
                ]
            ]
        ]
    ]
    h4 "View Record (paste timestamp in field)"
    f2: field
    btn "View" [
        foreach record data [
            obj: construct record
            if (form get in obj 'timestamp) = f2/text [
                editor obj 
            ]
        ]
    ]
]


REBOL [Title: "UDP Group Chat"]
net-in: open udp://:9905  ; This is UDP, so NO known IP addresses required
net-out: open/lines udp://255.255.255.255:9905
set-modes net-out [broadcast: on]
name: request-text/title "Your name:"
gui: view/new layout [
    a1: area wrap rejoin [name ", you are logged in."] 
    f1: field 
    k1: at 0x0 key #"^M" [
        if f1/text = "" [return]
        insert net-out rejoin [name ":  " f1/text]
    ]
]
forever [
    focus f1
    received: wait [net-in]
    if not viewed? gui [quit]
    insert (at a1/text 1) copy received  show a1
]


OBJECTS:

account: make object! [
    first-name: last-name: address: phone: email-address: none
]

account/phone: "555-1234"
account/address: "4321 Street Place Cityville, USA 54321"
get in account 'first-name
get in account 'address
? account
next first account
foreach item (next first account) [print item]
foreach item (next first account) [print get in account item]

count: 0
foreach item (next first account) [
    count: count + 1
    print rejoin ["Item " count ":   " item]
    print rejoin ["Value:    " (get in account item) newline]
]

user1: make account [
    first-name: "John"
    last-name: "Smith"
    address: "1234 Street Place  Cityville, USA 12345"
    email-address: "john@hisdomain.com"
]

complex-account: make object! [
    first-name: 
    last-name:
    address:
    phone:
    none
    email-address: does [
        return to-email rejoin [
            first-name "_" last-name "@website.com"
        ]
    ]
    display: does [
        print ""
        print rejoin ["Name:     " first-name " " last-name]
        print rejoin ["Address:  " address]
        print rejoin ["Phone:    " phone]
        print rejoin ["Email:    " email-address]
        print ""
    ]
]

user1: make complex-account []

user2: make complex-account [
    first-name: "John"
    last-name: "Smith"
    phone:  "555-4321"
]

user3: make complex-account [
    first-name: "Bob"
    last-name: "Jones"
    address: "4321 Street Place Cityville, USA 54321"
    phone:  "555-1234"
    email-address: "bob@mysite.net"  ; default function overwritten
]

user1/display   user2/display   user3/display

REBOL [title "Object Game"]
hidden-prize: random 15x15
character: make object! [
    position: 0x0
    move: does [
        direction: ask "Move up, down, left, or right:  "
        switch/default direction [
            "up" [position: position + -1x0]
            "down" [position: position + 1x0]
            "left" [position: position + 0x-1]
            "right" [position: position + 0x1]
        ] [print newline print "THAT'S NOT A DIRECTION!"]
        if position = hidden-prize [
            print newline
            print "You found the hidden prize.  YOU WIN!"
            print newline
            halt
        ]
        print rejoin [
            newline
            "You moved character " movement " " direction
            ".  Character " movement " is now " 
            hidden-prize - position
            " spaces away from the hidden prize.  "
            newline
        ]
    ]
]
character1: make character []
character2: make character [position: 3x3]
character3: make character [position: 6x6]
character4: make character [position: 9x9]
character5: make character [position: 12x12]
loop 20 [
    prin "^(1B)[J"
    movement: ask "Which character do you want to move (1-5)?  "
    if find ["1" "2" "3" "4" "5"] movement [
        do rejoin ["character" movement "/move"]
        print rejoin [
            newline
            "The position of each character is now:  "
            newline newline
            "CHARACTER ONE:   " character1/position newline
            "CHARACTER TWO:   " character2/position newline
            "CHARACTER THREE: " character3/position newline
            "CHARACTER FOUR:  " character4/position newline
            "CHARACTER FIVE:  " character5/position
        ]
        ask "^/Press the [Enter] key to continue."
    ]
]

money: make object! [
    var: 1234.56
    bank: does [
        print ""
        print rejoin ["Your bank account balance is:  $" var]
        print ""
    ]
]
place: make object! [
    var: "Wabash"
    bank: does [
        print ""
        print rejoin [
            "Your favorite place is on the bank of the:  " var]
        print ""
    ]
]

money/bank
place/bank
money/var
place/var

deposit: make money [
    view layout [
        button "Deposit $10" [
            var: var + 10
            bank
        ]
    ]
]
travel: make place [
    view layout [
        new-favorite: field 300 trim {
            Type a new favorite river here, and press [Enter]} [
            var: value
            bank
        ]
    ]
]


THIRD PARTY LIBRARIES:

REBOL [title: "PDF example"]
do http://www.colellachiara.com/soft/Misc/pdf-maker.r
write/binary %example.pdf layout-pdf [[textbox ["Hello PDF world!"]]]
call %example.pdf

REBOL [title: "PDF example 2"]
do http://www.colellachiara.com/soft/Misc/pdf-maker.r
write/binary %example.pdf layout-pdf compose/deep [
    [
        page size 215.9 279.4  ; American Letter Size
        textbox ["Here is page 1.  It just contains this text."]
    ] 
    [
        textbox 55 55 90 100 [
            {Here's page 2.  This text box contains a starting
             XxY position and an XxY size.  Coordinates are in
             millimeters and extend from the BOTTOM LEFT of the
             page (this box extends from starting point 55x55
             and is 90 mm wide, 100 mm tall).
             All the following page sizes are the default ISO A4,
             or 211297 mm.  That is SLIGHTLY SMALLER than the
             standard American Letter page size.}
        ]
    ]
    [
        textbox 0 200 200 50 [
            center font Helvetica 10.5
            {This is page 3.  The text inside this box is centered
             and formatted using Helvetica font, with a character
             size of 10.5 mm.}
        ]
    ]
    [
        apply rotation 20 translation 35 150 [
            textbox 4 4 200 20 [
                {This is page 4.  The textbox is rotated 20 degrees
                 and translated (moved over) 35x150 mm.  Graphics
                 and images can also be rotated and translated.}
            ]
        ]
    ]
    [
        textbox 5 200 200 40 [
            {Here's page 5.  It contains this textbox and several
             images.  The first image is placed at starting point
             50x150 and is 10mm wide by 2.4mm tall.  The second
             image is 2x bigger and rotated 90 degrees.  The last
             image is placed at starting point 100x150 and is
             streched to 10x its size.  Notice that this ENTIRE
             layout block has been evaluated with compose/deep to
             evaluate the images in the following parentheses.}
        ]
        image 50 150 10 2.4 (system/view/vid/image-stock/logo)
        image 50 100 20 4.8 rotated 90 
            (system/view/vid/image-stock/logo)
        image 100 150 100 24 (system/view/vid/image-stock/logo)
    ]
    [
        textbox [
            {This page contains this textbox and several generated
             graphics:  a line, a colored and filled box with a
             colored edge, and a circle.}
        ]
        line width 3  20 20 100 50   ; starting and ending XxY positions
        solid box edge width 0.2 edge 44.235.77 150.0.136 100 67 26 16
        circle 75 50 40   ; starting point 75x50, radius 40mm
    ]
]
call %example.pdf
; see http://www.colellachiara.com/soft/Misc/pdf-maker-doc.pdf

REBOL [title: "REBOL/Flash example"]
do http://box.lebeda.ws/~hmm/rswf/rswf_latest.r
make-swf/save/html http://tinyurl.com/yhex2cf 
browse %starfield1.html
; see http://box.lebeda.ws/~hmm/rswf/ 
; and http://re-bol.com/rebol.html#section-9.17

REBOL [title: "RebGUI Example"]
do http://re-bol.com/rebgui.r
display/close "Tab Panel" [
    main-screen: tab-panel data [
        "Spreadsheet" [
            x: sheet data [
                A1 32 A2 12 A3 "=a1 + a2" A4 "=1.06 * to decimal! a3"
            ]
            a: area
            reverse
            button -1 " Show Data " [x/save-data set-text a x/data]
            button -1 " Quit! " [if true = question "Quit?" [quit]]
        ]
        "Pie Chart" [
            pie-chart data ["VID" yellow 19 "RebGUI" red 81]
                tip "Pie Chart!"
        ]
        "Menu" [
            menu #LHW data [
                "File" [
                     "Open" [x/text: read to-file request-file show x]
                     "Save" [write to-file request-file/save x/text]
                 ]
                 "About" [
                     "Info" [alert "RebGUI is great!"]
                 ]
            ] 
            return
            x: area #LHW "[CTRL-Z: Undo CTRL-Y: Redo CTRL-S: Spell Check]"
        ]
        "VID style"  [
            style -1 data [text bold "Back to Spreadsheet" [
                main-screen/select-tab 1
            ]]
        ]
        action [wait .2 face/color: 230.230.230]  "Text" [
            text "Tabs are a great way to maximize screen real estate."
        ]
        action [wait .2 set-focus z]  "Fields" [
            y: field
            z: field "Edit me"
        ]
    ]
] [question "Really Close?"]
do-events


REBOL [title: "RebGUI Table Grid Example"]
do load-thru http://re-bol.com/rebgui.r
alert {Default username/password is "user1/pass1"}
unless exists? %snappmx.txt [
    save %snappmx.txt [
        "user1" "pass1" "Bill Jones" "bill@site.com" "Bill LLC" 
        "user2" "pass2" "John Smith" "john@mail.com" "John LLC"
    ]
]
database: load %snappmx.txt
login: request-password
found: false
foreach [userid password name email company] database [
    either (login/1 = userid) and (login/2 = password) [found: true] []
]
if found = false [alert "Incorrect Login." quit]
add-record: does [
    display/dialog "User Info" [
        text 20 "User:" f1: field return
        text 20 "Pass:" f2: field return
        text 20 "Name:" f3: field return
        text 20 "Email:" f4: field return
        text 20 "Company:" f5: field reverse
        button -1 #XY " Clear " [clear-fields]
        button -1 #XY " Add " [add-fields]
    ]
]
edit-record: does [
    display/dialog "User Info" [
        text 20 "User:" f1: field (form pick t/selected 1) return
        text 20 "Pass:" f2: field (form pick t/selected 2) return
        text 20 "Name:" f3: field (form pick t/selected 3) return
        text 20 "Email:" f4: field (form pick t/selected 4) return
        text 20 "Company:" f5: field (form pick t/selected 5) reverse
        button -1 #XY " Delete " [
            t/remove-row t/picked
            save %snappmx.txt t/data
            hide-popup
        ]
        button -1 #XY " Save " [
            t/remove-row t/picked
            add-fields
            save %snappmx.txt t/data
            hide-popup
        ]
    ]
]
add-fields: does [
    t/add-row reduce [
        copy f1/text copy f2/text copy f3/text copy f4/text copy f5/text
    ]
    save %snappmx.txt copy t/data
]
clear-fields: does [
    foreach item [f1 f2 f3 f4 f5] [do rejoin [{set-text } item {""}]]
]
table-size: system/view/screen-face/size/1 / ctx-rebgui/sizes/cell
display/maximize "Users" [
    t: table table-size #LWH options [
        "" left .0  "" left .0   ; don't show the first 2 fields
        "Name" center .33  "Email" center .34  "Company" center .34
    ] data database [edit-record]
    reverse
    button -1 #XY " Add " [add-record]
]
do-events

REBOL [title: "Cyphre Menu and Tab Panel Example"]
do load-thru http://re-bol.com/cyphre_menu_and_tab_panel.r
insert-event-func [ 
    either event/type = 'resize [
        mn/size/1: system/view/screen-face/pane/1/size/1 
        my-tabs/size: system/view/screen-face/pane/1/size - 15x30
        show [mn my-tabs]  none
    ] [event]
]
view/options center-face layout  [
    across space 0x0 origin 0x0
    mn: menu with [ 
        size: 470x20 
        data: compose/deep [
            " File " [
                "Open" # "Ctrl+O" [request-file]
                "Save" # "Ctrl+S" [request-file/save]
                bar
                "Exit" [quit]
            ]
            " Options " [
                "Preferences" sub [
                    "Colors" [alert form request-color]
                    "Settings" [request-text/title "Enter new setting:"]
                ]
                "About" [alert "Menu Widget by Cyphre"]
            ]
        ]
    ]
    below
    at 10x25 my-tabs: tab-panel data [
        "Fields"   [
            h1 "Tab Panel by Cyphre" field field area area btn "Ok"
         ]
        "Data List"  [
            t1: text-list 400x430 data system/locale/months [alert value]
        ]
    ]
] [resize]

REBOL [title: "Listview Example"]
evt-close: func [face event] [
    either event/type = 'close [
        inform layout [
            across
            Button "Save Changes" [
                backup-file: to-file rejoin ["backup_" now/date]
                write backup-file read %database.db
                save %database.db theview/data quit
            ]
            Button "Lose Changes" [quit]
            Button "CANCEL" [hide-popup]
        ] none ] [ 
        event
    ]
]
insert-event-func :evt-close
if not exists? %list-view.r [write %list-view.r read
    http://www.hmkdesign.dk/rebol/list-view/list-view.r
]
do %list-view.r
if not exists? %database.db [write %database.db {[][]}]
database: load %database.db
view center-face gui: layout [
    h3 {To enter data, double-click any row, and type directly 
        into the listview.  Click column headers to sort:}
    theview: list-view 775x200 with [
        data-columns: [
            Student Teacher Day Time Phone Parent Age Payments
            Reschedule Notes
        ]
        data: copy database
        tri-state-sort: false
        editable?: true
    ]
    across
    button "add row" [theview/insert-row]
    button "remove row" [
        if (to-string request-list "Are you sure?" 
                [yes no]) = "yes" [
            theview/remove-row
        ]
    ]
    button "filter data" [
        filter-text: request-text/title trim {
            Filter Text (leave blank to refresh all data):}
        if filter-text <> none [
            theview/filter-string: filter-text
            theview/update
        ]
    ]
    button "save db" [
        backup-file: to-file rejoin ["backup_" now/date]
        write backup-file read %database.db
        save %database.db theview/data
    ]
]

REBOL [title: "Another Menu Module Example"]
if not exists? %menu-system.r [write %menu-system.r (
        read http://www.rebol.org/library/scripts/menu-system.r)]
do %menu-system.r
menu-data: [
    file: item "File" menu [item "Open" item "Save" item "Quit"]
    edit: item "Edit" menu [ 
        item "Item 1"
        item "Item 2" <ctrl-q>
        ---
        item "Submenu..." menu [
            item "Submenu Item 1" 
            item "Submenu Item 2"
            item "Submenu Item 3" menu [
                item "Sub-Submenu Item 1"
                item "Sub-Submenu Item 2"
            ]
        ]
        ---
        item "Item 3"       
    ]
    icons: item "Icons" menu [
        item "Icon Item 1" icons [help.gif stop.gif]
        item "Icon Item 2" icons [info.gif exclamation.gif]
    ]
]
basic-style: [item style action [
    switch item/body/text [
        case "Open" [
            the-file: request-file
            alert rejoin ["You opened: " the-file]
        ] 
        case "Save" [
            the-file: request-file/save
            alert rejoin ["You saved to: " the-file]
        ]
        case "Quit" [
            if (request/confirm "Really Quit?") = true [quit]
        ]   
        case "Item 1" [alert "Item 1 selected"]
        case "Item 2" [alert "Item 2 selected"]
        case "Item 3" [alert "Item 3 selected"]
        case "Submenu Item 1" [alert "Submenu Item 1 selected"]
        case "Submenu Item 2" [alert "Submenu Item 2 selected"]
        case "Submenu Item 3" [alert "Submenu Item 3 selected"]
        case "Sub-Submenu Item 1" [alert "Sub-Submenu Item 1 selected"]
        case "Sub-Submenu Item 2" [alert "Sub-Submenu Item 2 selected"]
        case "Icon Item 1" [alert "Icon Item 1 selected"]
        case "Icon Item 2" [alert "Icon Item 2 selected"]
    ]
]]
evt-close: func [face event] [either event/type = 'close [quit] [event]]
insert-event-func :evt-close
view center-face layout [
    size 400x500
    at 2x2 menu-bar menu menu-data menu-style basic-style
]

REBOL [title: "r3D Example"]
do http://re-bol.com/r3d.r
Transx:   Transy:   Transz:   300.0
Lookatx:  Lookaty:  Lookatz:  100.0 
do update: does [ 
    world: copy [] 
    append world reduce [
        reduce [cube-model (r3d-scale 100.0 150.0 125.0) red]
    ]
    camera: r3d-position-object   
        reduce [Transx Transy Transz]
        reduce [Lookatx Lookaty Lookatz]
        [0.0 0.0 1.0] 
    RenderTriangles: render world camera r3d-perspective 250.0 400x360
    probe RenderTriangles    ; This line can be removed
] 
view layout [
    scrn: box 400x360 black effect [draw RenderTriangles]  ; basic draw
    across return
    slider 60x16 [Transx: (value * 600 - 300.0) update show scrn]
    slider 60x16 [Transy: (value * 600 - 300.0) update show scrn]
    slider 60x16 [Transz: (value * 600) update show scrn]
    slider 60x16 [Lookatx: (value * 400 - 200.0) update show scrn]
    slider 60x16 [Lookaty: (value * 400 - 200.0) update show scrn]
    slider 60x16 [Lookatz: (value * 200 ) update show scrn]
]

REBOL [title: "MYSQL Example"]
; First, start MySQL and create a database named "Contacts"
unless exists? %mysql-protocol.r [
    write %mysql-protocol.r read http://re-bol.com/mysql-protocol.r
]
do %mysql-protocol.r
db: open mysql://root:root@localhost/Contacts
insert db {create table Contacts (
    name            varchar(100),
    address         text,
    phone           varchar(12),
    birthday        date 
)} 
insert db {INSERT into Contacts VALUES 
    ('John Doe', '1 Street Lane', '555-9876', '1967-10-10'),
    ('John Smith', '123 Toleen Lane', '555-1234', '1972-02-01'),
    ('Paul Thompson', '234 Georgetown Pl.', '555-2345', '1972-02-01'),
    ('Jim Persee', '345 Portman Pike', '555-3456', '1929-07-02'),
    ('George Jones', '456 Topforge Court', '', '1989-12-23'),
    ('Tim Paulson', '', '555-5678', '2001-05-16')
}
insert db "DELETE from Contacts WHERE birthday = '1967-10-10'"
insert db "SELECT * from Contacts"
results: copy db
probe results
close db
halt
; see http://softinnov.org/rebol/mysql-usage.html

REBOL [title: "MySQL GUI Example"]
do %mysql-protocol.r
results: read/custom mysql://root:root@localhost/Contacts [
    "SELECT * from Contacts"
]
view layout [
    text-list 100x400 data results [
        string: rejoin [
            "NAME:      " value/1 newline
            "ADDRESS:   " value/2 newline
            "PHONE:     " value/3 newline
            "BIRTHDAY:  " value/4
        ]
        view/new layout [
            area string
        ] 
    ] 
]

REBOL [title: "SQLITE Example"]
unless exists? %sqlite3.dll [
    write/binary %sqlite3.dll read/binary http://re-bol.com/sqlite3.dll
]
unless exists? %sqlite.r [
    write %sqlite.r read http://re-bol.com/sqlite.r
]
do %sqlite.r
db: connect/create %contacts.db
SQL "create table contacts (name, address, phone, birthday)"
SQL {insert into contacts values 
    ('"John Doe"', '"1 Street Lane"', '"555-9876"', '"1967-10-10"')
}
data: [
    "John Smith" "123 Toleen Lane" "555-1234" "1972-02-01"
    "Paul Thompson" "234 Georgetown Pl." "555-2345" "1972-02-01"
    "Jim Persee" "345 Portman Pike" "555-3456" "1929-07-02"
    "George Jones" "456 Topforge Court" "" "1989-12-23"
    "Tim Paulson" "" "555-5678" "2001-05-16"
]
SQL "begin"
foreach [name address phone bd] data [
    SQL reduce [
        "insert into contacts values (?, ?, ?, ?)" name address phone bd
    ]
]
SQL "commit"
SQL ["DELETE from Contacts WHERE birthday = ?" "1967-10-10"]
results: SQL "select * from contacts"
probe results
disconnect db
halt
; see http://www.dobeash.com/sqlite.html

REBOL [title: "SQLITE GUI Example"]
do %sqlite.r
connect %contacts.db
results: SQL "select * from contacts"
view layout [
    text-list 100x400 data results [
        string: rejoin [
            "NAME:      " value/1 newline
            "ADDRESS:   " value/2 newline
            "PHONE:     " value/3 newline
            "BIRTHDAY:  " value/4
        ]
        view/new layout [
            area string
        ] 
    ] 
]
disconnect

REBOL [title: "Captcha Example"]
write/binary %Caliban.caf read/binary http://re-bol.com/Caliban.caf
do http://re-bol.com/captcha.r
captcha/set-fonts-path %./
captcha/level: 4
write/binary %captcha.png captcha/generate
write %captcha.txt captcha/text
view center-face layout [
    image (load %captcha.png)
    text "Enter the captcha text:"
    f1: field [
        either f1/text = (read %captcha.txt) [
            alert "Correct"
        ] [
            alert "Incorrect"
        ]
    ] 
]

REBOL [title: "Windows Screen Capture Example"]
do http://www.rebol.org/download-a-script.r?script-name=capture-screen.r
the-image: ftp://user:pass@site.com/path/current.png
view center-face gui: layout [
    button 150 "Upload Screen Shot" [
        unview gui
        wait .2
        save/png the-image capture-screen
        view center-face gui
    ]
]

REBOL [title: "XML-RPC Example"]
xmlrpc-exec http://betty.userland.com/RPC2 [examples.getStateName 41]
defh: func [orig-call] [do orig-call]
xmlrpc-serve/default [] 'defh
; see http://earl.strain.at/space/rebXR+Users+Guide



PLUGIN:

<HTML><HEAD><TITLE>REBOL Plugin for IE</TITLE></HEAD><BODY><CENTER>
<OBJECT ID="REBOL" CLASSID="CLSID:9DDFB297-9ED8-421d-B2AC-372A0F36E6C5" 
    CODEBASE="http://www.rebol.com/plugin/rebolb7.cab#Version=1,0,0,0"
    WIDTH="500" HEIGHT="400">
    <PARAM NAME="LaunchURL" VALUE="http://yoursite.com/test_plugin.r">
    <PARAM NAME="BgColor" VALUE="#FFFFFF">
    <PARAM NAME="Version" VALUE="#FFFFFF">
    <PARAM NAME="BgColor" VALUE="#FFFFFF">
</OBJECT>
</CENTER></BODY></HTML>

<HTML><HEAD><TITLE>Plugin Mozilla, IE, Chrome</TITLE></HEAD><BODY><CENTER>
<OBJECT ID="REBOL_IE" CLASSID="CLSID:9DDFB297-9ED8-421d-B2AC-372A0F36E6C5"
    CODEBASE="http://re-bol.com/rebolb7.cab#Version=1,0,0,0"
    WIDTH="500" HEIGHT="400" BORDER="1" ALT="REBOL/Plugin">
    <PARAM NAME="bgcolor" value="#ffffff">
    <PARAM NAME="version" value="1.2.0">
    <PARAM NAME="LaunchURL" value="http://re-bol.com/test_plugin.r">
    <embed name="REBOL_Moz" type="application/x-rebol-plugin-v1"
        WIDTH="500" HEIGHT="400" BORDER="1" ALT="REBOL/Plugin"
        bgcolor="#ffffff"
        version="1.2.0"
        LaunchURL="http://re-bol.com/test_plugin.r"
    >
    </embed>
</OBJECT>
<script language="javascript" type="text/javascript">
var plugin_name = "REBOL/Plugin for Mozilla";
function install_rebol_plugin_mozilla() {
    if (navigator.userAgent.toLowerCase().indexOf("msie") == -1) {
        if (InstallTrigger) {
           xpi={'REBOL/Plugin for Mozilla':'http://re-bol.com/mozb2.xpi'};
           InstallTrigger.install(xpi, installation_complete);
        }
    }
}
function installation_complete(url, status) {
    if (status == 0) location.reload();
}
function is_mozilla_plugin_installed() {
    if (window.navigator.plugins) {
        for (var i = 0; i < window.navigator.plugins.length; i++) {
            if (window.navigator.plugins[i].name == plugin_name)
            return true;
        }
    }
    return false;
}
if (!is_mozilla_plugin_installed()) install_rebol_plugin_mozilla();
</script>
</CENTER></BODY></HTML>


MULTITASKING:

print "Obtaining keyboard input without blocking looping program flow:"
p: open/binary/no-wait console://
q: open/binary/no-wait [scheme: 'console]
count: 0
forever [
    count: count + 1
    if not none? wait/all [q :00:00.01] [
        wait q
        qq: to string! copy q
        probe qq
        print ["^/loop count incremented to" count "while waiting^/"]
    ]
]

alert {
GUI multitasking instructions:

    1)  Assign a rate of 0 to a GUI widget.
    2)  Assign a "feel" detection to that widget, and put the actions
        you want performed simultaneously inside the block that gets
        evaluated every time a 'time event occurs.
    3)  Stop and start the evaluation of concurrently active portions
        of code by assigning a rate of "none" or 0, respectively, to
        the associated GUI widget(s).
}
webcam-url: http://209.165.153.2/axis-cgi/jpg/image.cgi
view layout [
    btn "Start Video" [
        webcam/rate: 0 
        webcam/image: load webcam-url 
        show webcam
    ]
    btn "Stop Video" [webcam/rate: none show webcam]
    return 
    webcam: image load webcam-url 320x240 rate 0 feel [
        engage: func [f a e][
            if a = 'time [
                f/image: load webcam-url show f
            ] 
        ] 
    ]
    clock: field to-string now/time/precise rate 0 feel [
        engage: func [f a e][
            if a = 'time [
                f/text: to-string now/time/precise show f
            ] 
        ] 
    ]
    h3 "Notice the delay in the timer as each image loads"
]

alert {
    This examples achieves true multitasking by simply writing the code
    for one process into a separate file and running it in a separate
    REBOL interpreter process using the "launch" function:
}
write %async.r {
    REBOL []
    view layout [
        origin 10x10
        clock: field to-string now/time/precise rate 0 feel [
            engage: func [face action event][
                if action = 'time [
                    face/text: to-string now/time/precise show face
                ] 
            ] 
        ]
    ]
}
launch %async.r
webcam-url: http://209.165.153.2/axis-cgi/jpg/image.cgi
view center-face layout [
    btn "Start Video" [
        webcam/rate: 0 
        webcam/image: load webcam-url 
        show webcam
    ]
    btn "Stop Video" [webcam/rate: none show webcam]
    return 
    webcam: image load webcam-url 320x240 rate 0 feel [
        engage: func [face action event][
            if action = 'time [
                face/image: load webcam-url show face
            ]
        ]
    ]
]



VARIOUS ADDITIONAL APPLICATION EXAMPLES:

REBOL [title: "Ski Game"]
tree:  load to-binary decompress 64#{
eJzt18sNwjAQBFDTBSVw5EQBnLjQE1XRngmBQEj8Wa/3M4oYOZKBKHkaWwTO1/sh
jDkNx3N6HI7LcOzCfnz/9v5cMnEai7lj4mokT9C7XczUsrhvGSku6RkgDIbHAEP0
2EiIMBdMDuaOWZCSL91bQvCsSY4MHE9umXz7ydVi3xgltYvEKboexzVSlpTa614d
NonpUauIv176dX0ZTRgJlVgzNl25A3gkGwld1bkrNFqqedQfEI02AU9PjDeMpac/
ShKeT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9VAZrqVOxsZuTirg8TTS0qAQs5FIPF0BhYXFkgog/zg
7gJlq5SXpaWVF4O9lZKuXl6eVl4AZLIfKS82LzYuB2nlOFxWXl5ubA6ytm1KWU65
cXExkMl09lNNR3q5eTFQPYfHE7YT6cXlJgcYGI7cPMAOMtKhgcH9wE8FBuPycgOG
BoYKtl8ODL4gjccY2HSAfr4BVMvgAwyazwwsXSA7ORgY2BQYeH+Cw+sAKPo5wEHj
kQAO/GZwIIHDgc0AaxQSBAAFOXD7bgIAAA==
}
random/seed now
the-score: 0
board: reduce ['image 300x20 skier-right black]
for i 1 20 1 [
    pos: random 600x540
    pos: pos + 0x300
    append board reduce ['image pos tree black]
]
view center-face layout/tight [
    scrn: box white 600x440 effect [draw board] rate 0 feel [
        engage: func [f a e] [
            if a = 'key [
                if e/key = 'right [
                    board/2: board/2 + 5x0
                    board/3: skier-right
                ]
                if e/key = 'left [
                    board/2: board/2 - 5x0
                    board/3: skier-left
                ]
                show scrn
            ]
            if a = 'time [
                new-board: copy []
                foreach item board [
                    either all [
                        ((type? item) = pair!) 
                        ((length? new-board) > 4)
                    ] [ 
                        append new-board (item - 0x5) 
                    ] [
                        append new-board item
                    ]
                    coord: first back back (tail new-board)
                    if ((type? coord) = pair!) [
                        if ((second coord) < -60) [
                            remove back tail new-board
                            remove back tail new-board
                            remove back tail new-board
                            remove back tail new-board
                        ]
                    ]
                ]
                board: copy new-board
                if (length? new-board) < 84 [
                    column: random 600
                    pos: to-pair rejoin [column "x" 440]
                    append board reduce ['image pos tree black]
                ]
                collision-board: remove/part (copy board) 4
                foreach item collision-board [
                    if (type? item) = pair! [
                        if all [
                          ((item/1 - board/2/1) < 15)
                          ((item/1 - board/2/1) > -40)
                          ((board/2/2 - item/2) < 30)
                          ((board/2/2 - item/2) > 5)
                        ] [
                            alert "Ouch - you hit a tree!"
                            alert rejoin ["Final Score: " the-score]
                            quit
                        ]
                    ]
                ]
                the-score: the-score + 1 
                score/text: to-string the-score
                show scrn
            ]
        ]
    ]
    origin across h2 "Score:" 
    score: h2 bold "000000"
    do [focus scrn]
]


REBOL [title: "Chord Accompaniment Player"]
play: false
insert-event-func [  ; standard method to trap GUI close events:
    either event/type = 'close [
        if play = true [play: false close sound-port]
        really: request "Really close the program?"
        if really = true [quit]
    ][
        event
    ]
]
flash "Downloading chord data (3.5 megabytes)..."
do load-thru http://musiclessonz.com/rebol_tutorial/wave_data.r
unview
view center-face layout [
    across
    h2 "Chords:"
    tab
    chords: area 392x300 trim {
        bm bm bm bm
        gb7 gb7 gb7 gb7
        a a a a 
        e e e e
        g g g g
        d d d d 
        em em em em
        gb7 gb7 gb7 gb7
        g g g g
        d d d d
        gb7 gb7 gb7 gb7
        bm bm bm bm
        g g g g
        d d d d
        em em em em
        gb7 gb7 gb7 gb7
    }
    return
    h2 "Delay:"
    tab
    tempo: field 50 "0.35" text "(seconds)"
    tabs 40 tab
    btn "PLAY" [
        play: true
        the-tempo: to-decimal tempo/text
        sounds: to-block chords/text
        wait 0
        sound-port: open sound://
        forever [
            foreach sound sounds [
                if play = false [break]
                do rejoin ["insert sound-port " reduce [sound]]
                wait sound-port
                wait the-tempo 
            ]
            if play = false [break]
        ]
    ]
    btn "STOP" [
        play: false
        close sound-port
    ]
    btn "Save" [save to-file request-file/save chords/text]
    btn "Load" [chords/text: load read to-file request-file show chords]
    btn "HELP" [
        alert {
            This program plays chord progressions.  Simply type in
            the names of the chords that you'd like played, with a
            space between each chord.  For silence, use the
            underscore ("_") character.  Set the tempo by entering a 
            delay time (in fractions of second) to be paused between
            each chord.  Click the start button to play from the 
            beginning, and the stop button to end.  Pressing start
            again always begins at the first chord in the 
            progression.  The save and load buttons allow you to 
            store to the hard drive any songs you've created.
            Chord types allowed are major triad (no chord symbol - 
            just a root note), minor triad ("m"), dominant 7th 
            ("7"), major 7th ("maj7"), minor 7th ("m7"), diminished
            7th ("dim7"), and half diminished 7th ("m7b5").
            *** ALL ROOT NOTES ARE LABELED WITH FLATS (NO SHARPS)
            F# = Gb, C# = Db, etc...
         }
    ]
]


REBOL [
    title: "Table/Grid/List Widget Example"
    file: %table-grid-list.r
    purpose: {
One of the greatest things about REBOL/View is the built in GUI dialect
    ("VID").  It's great for building simple GUI layouts quickly and
    easily, but the native list widget can be confusing for newcomers.
THIS EXAMPLE IS A FULL FEATURED TABLE/GRID/LIST WIDGET FOR VID GUIs.
    KEYS:  INSERT  DELETE  ARROWS  PAGE UP/DOWN  - +  F1  CTRL R M S O F U
    MOUSE: click header to sort, RIGHT-CLICK/DRAG to RESIZE, click to edit
Columns can be SORTED and *RESIZED* by clicking the headers.  Data can be
    EDITED by clicking cells.  Rows can be added, removed, and moved with
    the INSERT, DELETE, and CTRL+M keys.  Data blocks can be loaded and
    saved to/from files, in both "flattened" and sub-block formats, using
    the CTRL+S CTRL+L CTRL+F and CTRL+U keys.  Column format (color, font,
    etc.) can be easily specified in the column code.  Alternate rows are
    automatically shaded, and mousing-over a row highlights the current
    row.  Up and down arrow keys, and page up/down keys can be used to
    scroll.  The mouse can also be used to scroll (with the scroll bar).
    Data can be reverted to the last saved change (by clicking the "r"
    button in the GUI).  The entire grid can be resized to any percentage,
    with automatic sizing of columns (use the "+" and "-" keys to resize
    this example).  The entire grid size will also automatically adjust to
    fit a resized screen.  Press [F1] for help.
The compressed code adds all necessary functionality to VID's native list
    widget - paste it as-is into your script (uncompress to see how it
    works, or to make changes).
Keep the variables and naming coventions as they are in the GUI code (the
    variables gui, gui-size, t-size, x, y, li, list-size, sl, sl-size,
    s-pos, and my-supply need to be changed in the compressed code if ever
    changed in the GUI layout).
You can add as many columns as needed to your own GUI grids:
    Headers must be labeled h1, h2, h3...  Put DIFFERENT TEXT in each.
    Columns must be labeled col1, col2, col3...  Format each as needed.
"header-block" must be edited to contain each of the header labels (i.e.,
    if your table has headers h1, h2, and h3, the header block should be
    [h1/text h2/text h3/text]).
"x" holds the data displayed in the table - you can save, load, and
    manipulate it directly, then refresh the display (try the CTRL+S and
    CTRL+O keys in the GUI example to save and load the grid data).
Rows of data are each stored in a SEPARATE block within the "x" block.
    To "flatten" the block (i.e., to save the grid data in one large
    block, without sub-blocks), try the CTRL+F keys in this GUI example.
    To load a flattened block, try the CTRL+U keys.
"y" holds a copy of the original data (click the "r" button in the GUI
    example to reload it and refresh the display to its last saved state).
"feel editstyle" is used to make a column EDITABLE.  Click any cell in the
    GUI example to edit.  These changes are made directly to the "x" block
    and then the GUI is refreshed.
"feel slidestyle" is used to make a column RESIZABLE (RIGHT CLICK/drag the
    header to expand or contract any column width).  This function also
    contains the "sort-column" function, which allows the user to sort
    columns of data by clicking the header.
"sort-column" sorts the selected column number.  Each call to this
    function alternates between ascending and descending sort order.
"key-scroll" enables keyboard scrolling (use the up/down cursor keys, and
    page up/down keys in this GUI example).
"add-line" adds a row of data to the grid, at a chosen index (use the
    [INSERT] key in this GUI example).
"remove-line" removes a selected row of data (use the [DELETE] key in this
    GUI example).
"move-line" moves a row of data from one selected index to another (use
    the CTRL+M keys in this GUI example to move rows).
"resize-fit" resizes the table to fit the GUI, with equally sized columns.
    The compressed code contains an insert-event-function which 
    automatically resizes the table to fit the GUI window, when resized.
    Press CTRL+R in this GUI example to execute the function manually.
"resize-grid" resizes the table a given percentage (press the "+" and "-"
    keys in this GUI example to see it work).
Notice that the majority of user-editable code in the GUI consists of
    headers, column names and formatting, and "key" widgets to run the
    desired functions.  In this example GUI, the user presses keystroke
    combinations to activate the desired features, but those functions
    could also be added to the action blocks of buttons, and/or executed
    by any other typical trigger.
    }
]
x: copy []             ; The data shown in the grid is labeled "x"
random/seed now/time   ; Generate 5000 rows of random data:
repeat i 5000 [
    append/only x reduce [
        random "abcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*(),.';" 
        form random 1000 
        form random 1000 
        random "abcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*(),.';"
        form i
    ]                  ; all data is stored in string format
]  y: copy x           ; "y" holds a backup copy of the original grid data
header-block: [h1/text h2/text h3/text h4/text h5/text] ; EDIT - 5 COLUMNS
do decompress list-widget-functions: #{
789CAD574B6F1B3710BEFB570CD443B50D362B1971806EFD407F402EB90A3AD0
DA59890D45AEB95C5B4AE0FFDE21B9A448594214B7060C899C996F1E9C977AA5
4DB95262D8CA1ADA41AE60D17214CD121657407FC8CD0635F4964DE906750D52
99E43CF2D93F7B59ADD4B6631A6137A2317824AC2933C0C02117700FF6F8381E
974E7EF90E9CDB9338E03EFB8D7A01C1AF9657DF705FF62BAD84080EFA53C9B6
6A902628EECB4EF5B5FF800F90F13806DE8E44325FA05C9BCD03EC0A42F382F1
6A9973DFC22CF2CC3CAD1755C30C0BCAAA0C2F337FFCD20BF24363CFBF63B9D6
BC098E74A857280D5B63F0623DF0D2B211F6BE37B8AD9E39BE54E40CA22C5BB6
C2AA6312AB796599E02F28613EDBCD9CA8E0BD71B2D5BC4E0FF0071CF41C715E
D75163754D607FDE380633DAA029780D79978025CE6E9051FE948F42ADBE15C5
18995192516818D730FF9C6A733C83743E2929F65639F85367B8923D583309D3
7A0A82EDD5609C814E072C7C08978760B6DCD4D028ECDF133E2791BC0A4C632C
AC9FA9D7257C9C17A496354D29B8C4A0941952D299513B97CDAE06A34A4E4EAC
A9B4343E0D48280677A632DC08AC1A6CD9200C4CFE6E1A786682E84045A0294B
7EAB27B1845AA5B729927AD6E5EA90C85613DCD9CCD468062D7D5E4A7C293D64
0D2BD5ED61E1EF090C38CCCFBC1C1116ACEB905EFA00E0E52793B118648F54D2
EEC96CC9EE9C0145CA7F2858FB385BF58CFF57A0BE12AE51E041EB09FCB71811
C1E801E1F63E28A5CF7F1497B0987CF52A60021DA774F35EC2E461B2CC31BC29
592452F7DF38EF849468CA5FF2FB8BD5D16AB5FDA5E4B04F72819A11DEC63501
A7E04CA701C1C6AE004A9D6930DDDD1497C7F34B1ECD08F336A236641519E343
1A188BE84D3A0FB6340E86AE13FB3A1F71F88CF281F296FA3DCD405BEB341615
CDBB970D37B6C1A677D79F661FDDFFCD8DB7C0C9D5A3F807DFD9838352497C80
A73A3892EAB021AD43B500EEB88971199F85A276C2A8EB19299F250638A21F2B
AB38B312154EF7934D37DC51147AC11B0AF65E600C835C53838F4B008D594C87
32B73777F0FBD0D1383B2C0D1EF0816630D5BFC666A0C69BB607689DFE65C459
0DBE3DD7174AA6060459B8BF8353BD284F8AD46A264CD9A817CAAADE30673C2D
2F3560A5DAB6C7C43C6B4D49F930DAF823125CE1F6DF6923B0EFDC724D992A71
CD0C1532F53E8F488D3EC12F3261CA3BF71C61C4E667920CE8991445791ADC2E
A2ECA9DB4B102833E7C5E8F3314E4EBB1CED944D2985BE9F44DA9CB5EA1CE59C
4DC7FCC1A2D3F7E7EC711D627C94E305EC08C9EE0951F6357ED3D809CB92E510
FC38BCD46BCCE08B659CBE57C8CF27D3DB16E6A984A364CDAE63B21ED21F3286
46E5D644E2B86153F7C0869BAC7950FFD587D6A18E1AC75401B38B60E868D4EC
5BD7ABEC34182FEBF12A443E28F3265FDC9A324FDAB1F765F32B0C484F8C83E1
AD937E6B29ED5C30A5579D8C0A1A84FB0EAD5ABF0286EDD2EE94AEE393858E8F
26FACFD74A8750C26C7733BB8A8BE361B926D2E7D98EB6EB9F2DC8EFDABCC3AF
13C87EE6B9B10CF175AC4B57FF0285CB5B342E0E0000
}
svv/vid-face/color: white
view/options center-face gui: layout gui-block: [
size gui-size  across  space 0x0
style header button as-pair t-size 20 black white bold
h1: header "Text1" feel slidestyle  ; EDIT THESE FOR YOUR OWN NEEDS.  EACH
h2: header "Num1" feel slidestyle   ; HEADER MUST CONTAIN UNIQUE TEXT.
h3: header "Num2" feel slidestyle   ; YOU CAN HAVE AS MANY OR AS FEW
h4: header "Text2" feel slidestyle  ; COLUMNS AS NEEDED (ALL RESIZEABLE).
h5: header "Key" feel slidestyle    ; THEY MUST BE LABELED:  H1, H2, H3...
h6: button black "r" 17x20 [if true = request "Reset?"[x: copy y show li]]
return
li: list list-size [
    style cell text t-size feel editstyle    ; EVERY CELL IS NOW EDITABLE
    across  space 0x0
    col1: cell blue    ; EDIT THE LOOK AND FEEL OF EACH COLUMN AS NEEDED.
    col2: cell         ; COLUMNS MUST BE LABELED:  COL1, COL2, COL3...
    col3: cell red     ; THEY CONTAIN THE *DATA* LABELED BY HEADERS ABOVE.
    col4: cell blue    ; THEY ARE TYPICALLY TEXT FIELDS, BUT CAN BE ANY
    col5: cell         ; OTHER TYPE OF GUI WIDGET DESIRED.
] supply my-supply
sl: scroller sl-size [s-pos: (length? x) * value  show li]
key keycode [up] [key-scroll -1]         ; EACH OF THESE KEYS DEMONSTRATES
key keycode [down] [key-scroll 1]        ; A FEATURE.  THESE FUNCTIONS
key keycode [page-up] [key-scroll -20]   ; COULD ALSO BE ADDED TO THE
key keycode [page-down] [key-scroll 20]  ; ACTION BLOCKS OF GUI BUTTONS OR
key keycode [insert] [add-line]          ; OTHER WIDGETS, OR OTHERWISE
key #"^~" [remove-line]                  ; ACTIVATED...
key #"^M" [move-line]
key #"^R" [resize-fit]
key #"+" [resize-grid 1.333]
key #"-" [resize-grid .75]
key #"^S" [save to-file request-file/save x]
key #"^O" [attempt [y: copy x: copy load request-file/only  show li]]
key #"^F" [fx: copy [] foreach row x [append fx reduce row]save %f.txt fx]
key #"^U" [attempt [  ; load a 'flattened' block
    fx: load request-file/only/file %f.txt
    x: copy [] foreach [a b c d e] fx [append/only x reduce [a b c d e]] 
    show li
]]
key keycode [f1] [editor system/script/header/purpose]
] [resize]


REBOL [title: "Table/Grid/List Widget Example"]
x: copy []
random/seed now/time
repeat i 5000 [
    append/only x reduce [random "abcdef" form random 1000 form i]=
]
y: copy x
header-block: [h1/text h2/text h3/text] 
do decompress list-widget-functions: #{
789CAD574B6F1B3710BEFB570CD443B50D362B1971806EFD407F402EB90A3AD0
DA59890D45AEB95C5B4AE0FFDE21B9A448594214B7060C899C996F1E9C977AA5
4DB95262D8CA1ADA41AE60D17214CD121657407FC8CD0635F4964DE906750D52
99E43CF2D93F7B59ADD4B6631A6137A2317824AC2933C0C02117700FF6F8381E
974E7EF90E9CDB9338E03EFB8D7A01C1AF9657DF705FF62BAD84080EFA53C9B6
6A902628EECB4EF5B5FF800F90F13806DE8E44325FA05C9BCD03EC0A42F382F1
6A9973DFC22CF2CC3CAD1755C30C0BCAAA0C2F337FFCD20BF24363CFBF63B9D6
BC098E74A857280D5B63F0623DF0D2B211F6BE37B8AD9E39BE54E40CA22C5BB6
C2AA6312AB796599E02F28613EDBCD9CA8E0BD71B2D5BC4E0FF0071CF41C715E
D75163754D607FDE380633DAA029780D79978025CE6E9051FE948F42ADBE15C5
18995192516818D730FF9C6A733C83743E2929F65639F85367B8923D583309D3
7A0A82EDD5609C814E072C7C08978760B6DCD4D028ECDF133E2791BC0A4C632C
AC9FA9D7257C9C17A496354D29B8C4A0941952D299513B97CDAE06A34A4E4EAC
A9B4343E0D48280677A632DC08AC1A6CD9200C4CFE6E1A786682E84045A0294B
7EAB27B1845AA5B729927AD6E5EA90C85613DCD9CCD468062D7D5E4A7C293D64
0D2BD5ED61E1EF090C38CCCFBC1C1116ACEB905EFA00E0E52793B118648F54D2
EEC96CC9EE9C0145CA7F2858FB385BF58CFF57A0BE12AE51E041EB09FCB71811
C1E801E1F63E28A5CF7F1497B0987CF52A60021DA774F35EC2E461B2CC31BC29
592452F7DF38EF849468CA5FF2FB8BD5D16AB5FDA5E4B04F72819A11DEC63501
A7E04CA701C1C6AE004A9D6930DDDD1497C7F34B1ECD08F336A236641519E343
1A188BE84D3A0FB6340E86AE13FB3A1F71F88CF281F296FA3DCD405BEB341615
CDBB970D37B6C1A677D79F661FDDFFCD8DB7C0C9D5A3F807DFD9838352497C80
A73A3892EAB021AD43B500EEB88971199F85A276C2A8EB19299F250638A21F2B
AB38B312154EF7934D37DC51147AC11B0AF65E600C835C53838F4B008D594C87
32B73777F0FBD0D1383B2C0D1EF0816630D5BFC666A0C69BB607689DFE65C459
0DBE3DD7174AA6060459B8BF8353BD284F8AD46A264CD9A817CAAADE30673C2D
2F3560A5DAB6C7C43C6B4D49F930DAF823125CE1F6DF6923B0EFDC724D992A71
CD0C1532F53E8F488D3EC12F3261CA3BF71C61C4E667920CE8991445791ADC2E
A2ECA9DB4B102833E7C5E8F3314E4EBB1CED944D2985BE9F44DA9CB5EA1CE59C
4DC7FCC1A2D3F7E7EC711D627C94E305EC08C9EE0951F6357ED3D809CB92E510
FC38BCD46BCCE08B659CBE57C8CF27D3DB16E6A984A364CDAE63B21ED21F3286
46E5D644E2B86153F7C0869BAC7950FFD587D6A18E1AC75401B38B60E868D4EC
5BD7ABEC34182FEBF12A443E28F3265FDC9A324FDAB1F765F32B0C484F8C83E1
AD937E6B29ED5C30A5579D8C0A1A84FB0EAD5ABF0286EDD2EE94AEE393858E8F
26FACFD74A8750C26C7733BB8A8BE361B926D2E7D98EB6EB9F2DC8EFDABCC3AF
13C87EE6B9B10CF175AC4B57FF0285CB5B342E0E0000
}
svv/vid-face/color: white
view/options center-face gui: layout gui-block: [
    size gui-size  across  space 0x0
    style header button as-pair t-size 20 black white bold
    h1: header "Text" feel slidestyle
    h2: header "Num" feel slidestyle
    h3: header "Key" feel slidestyle
    h6: button black "r" 17x20 [
        if true = request "Reset?" [x: copy y show li]
    ]
    return
    li: list list-size [
        style cell text t-size feel editstyle  across  space 0x0
        col1: cell blue
        col2: cell
        col3: cell red
    ] supply my-supply
    sl: scroller sl-size [s-pos: (length? x) * value  show li]
    key keycode [up] [key-scroll -1]
    key keycode [down] [key-scroll 1]
    key keycode [page-up] [key-scroll -20]
    key keycode [page-down] [key-scroll 20]
    key keycode [insert] [add-line]
    key #"^~" [remove-line]
    key #"^M" [move-line]
    key #"^R" [resize-fit]
    key #"^S" [save to-file request-file/save x]
    key #"^O" [attempt [y: copy x: copy load request-file/only  show li]]
    key #"^F" [
        fx: copy [] foreach row x [append fx reduce row]save %f.txt fx
    ]
    key #"^U" [attempt [  ; load a 'flattened' block
        fx: load request-file/only/file %f.txt
        x: copy [] foreach [a b c] fx [append/only x reduce [a b c]] 
        show li
    ]]
] [resize]


REBOL [title: "List Widget Example"]
x: copy []   random/seed now/time   ; generate 5000 rows of random data:
repeat i 5000 [
    append/only x reduce [random "asdfqwertyiop" form random 1000 form i]
]  y: copy x
Alert help-txt: {Be sure to try the following features:  1) Resize the GUI
    window to see the list automatically adjust to fit  2) Click column
    headers to sort by field  3) Use the arrow keys and page-up/page-down
    keys to scroll  4) Use the Insert, Delete and "M" keys to add, remove
    and move rows (by default, at the currently highlighted row)  5) Click
    the small "r" header button in the top right corner to reset the list
    back to its original values  6) Click any individual data cell to edit
    the selected value.}
sort-column: func [field] [
    either sort-order: not sort-order [
        sort/compare x func [a b] [(at a field) > (at b field)]
    ] [
        sort/compare x func [a b] [(at a field) < (at b field)]
    ]  
    show li
]
key-scroll: func [scroll-amount] [
    s-pos: s-pos + scroll-amount
    if s-pos > (length? x) [s-pos: length? x]
    if s-pos < 0 [s-pos: 0]
    sl/data: s-pos / (length? x)  
    show li  show sl
]
resize-grid: func [percentage] [
    gui-size: system/view/screen-face/pane/1/size ; - 10x0
    list-size/1: list-size/1 * percentage
    list-size/2: gui-size/2 - 95
    t-size: round (list-size/1 / 3)
    sl-size: as-pair 16 list-size/2
    unview/only gui view/options center-face layout gui-block [resize]
]
resize-fit: does [
    gui-size: system/view/screen-face/pane/1/size
    resize-grid (gui-size/1 / list-size/1 - .1)
]
insert-event-func [either event/type = 'resize [resize-fit none] [event]]
gui-size: system/view/screen-face/size - 0x50
list-size: gui-size - 60x95
sl-size: as-pair 16 list-size/2
t-size: round (list-size/1 / 3)
s-pos: 0  sort-order: true  ovr-cnt: none  svv/vid-face/color: white
view/options center-face gui: layout gui-block: [
    size gui-size  across
    btn "Smaller" [resize-grid .75]
    btn "Bigger" [resize-grid 1.3333]
    btn "Fit" [resize-fit]
    btn #"^~" "Remove" [attempt [
        indx: to-integer request-text/title/default "Row to remove:" 
            form to-integer ovr-cnt
        if indx = 0 [return]
        if true <> request rejoin ["Remove: " pick x indx "?"] [return]
        remove (at x indx)  show li
    ]]
    insert-btn: btn "Add" [attempt [
        indx: to-integer request-text/title/default "Add values at row #:"
            form to-integer ovr-cnt
        if indx = 0 [return]
        new-values: reduce [
            request-text request-text (form ((length? x) + 1))
        ]
        insert/only (at x indx) new-values  show li
    ]]
    btn #"m" "Move" [
        old-indx: to-integer request-text/title/default "Move from row #:"
            form to-integer ovr-cnt
        new-indx: to-integer request-text/title "Move to row #:"
        if ((new-indx = 0) or (old-indx = 0)) [return]
        if true <> request rejoin ["Move: " pick x old-indx "?"] [return]
        move/to (at x old-indx) new-indx  show li
    ]
    btn "Save" [save to-file request-file/save x]
    btn "Load" [y: copy x: copy load request-file/only  show li]
    btn "Read Me" [alert help-txt]
    btn "View Data" [editor x]
    return  space 0x0
    style header button as-pair t-size 20 black white bold
    header "Random Text" [sort-column 1]
    header "Random Number" [sort-column 2] 
    header "Unique Key" [sort-column 3]
    button black "r" 17x20 [if true = request "Reset?"[x: copy y show li]]
    return
    li: list list-size [
        style cell text t-size feel [
            over: func [f o] [
                if (o and (ovr-cnt <> f/data)) [ovr-cnt: f/data show li]
            ]
            engage: func [f a e] [
                if a = 'up [
                    f/text: request-text/default f/text show li
                ]
            ]
        ]             
        across  space 0x0
        col1: cell blue
        col2: cell
        col3: cell red
    ] supply [
        either even? count [face/color: white] [face/color: 240.240.255]
        count: count + s-pos
        if none? q: pick x count [face/text: copy "" exit]
        if ovr-cnt = count [face/color: 200.200.255]
        face/data: count
        face/text: pick q index
    ]
    sl: scroller sl-size [s-pos: (length? x) * value  show li]
    key keycode [up] [key-scroll -1]
    key keycode [down] [key-scroll 1]
    key keycode [page-up] [key-scroll -20]
    key keycode [page-down] [key-scroll 20]
    key keycode [insert] [do-face insert-btn 1]
] [resize]


REBOL [title: "File-Explorer"]
closer: insert-event-func [either event/type = 'close [quit] [event]]
sort-column: func [field] [
    either sort-order: not sort-order [
        sort/compare x func [a b] [(at a field) > (at b field)]
    ] [
        sort/compare x func [a b] [(at a field) < (at b field)]
    ]  
    show li
]
do-no-closer: func [the-code] [
    remove-event-func :closer
    do the-code
    closer: insert-event-func [either event/type = 'close [quit] [event]]
]
do file-request: [
    y: copy [] append y copy read %. insert head y "../"
    x: copy []  my-file: %none  sort-order: false
    foreach i y [
        append/only x reduce [
            i (size? to-file i) (modified? to-file i) (suffix? to-file i)
        ]
    ]
    slider-pos: 0
    view center-face layout [
        across  space 0x0  backdrop white
        h2 390 coal rejoin ["File: (" (length? y) - 1 ")"] [sort-column 1]
        h2 90 coal "Size:" [sort-column 2]
        h2 180 coal "Modified:" [sort-column 3]
        h2 right 50 coal "Type:" [sort-column 4] return
        li: list 750x360 [
            across  space 0x0
            text 390 bold [
                if face/text [
                    either #"/" = last (new-dir: copy face/text) [
                        unless %/ = clean-path to-file new-dir [
                            change-dir to-file new-dir 
                            unview do file-request
                        ]
                    ] [
                        my-file: join what-dir to-file face/text unview
                    ]
                ]
            ]
            text 90 purple 
            text 180 red italic
            text 50
            return box 0.0.240 750x1
        ] supply [
            count: count + slider-pos
            if none? q: pick x count [face/text: none exit]
            face/text: pick q index
        ]
        scroller 16x360 [
            lst-cnt: to-integer li/size/y / li/subface/size/y
            value: to-integer value * max 0 (length? y) - lst-cnt
            if slider-pos <> value [slider-pos: value show li]
        ]
        return
        h3 700 0.0.120 form what-dir  ; right
    ]
    ; probe my-file halt
    case [
        #"/" = (last my-file) []
        %.wav = (suffix? my-file) [
            if error? try [
                insert s: open sound:// load my-file wait s close s
            ] [close s alert "Incompatible wave file"]
        ]
        %.r = (suffix? my-file) [
            launch my-file
        ]
        find [%.html %.html] (suffix? my-file) [
            browse my-file
        ]
        find [%.jpg %.png %.gif %.bmp] (suffix? my-file) [
            do-no-closer [view center-face layout [image load my-file]]
        ]
        find [
            %.pdf %.exe %.com %.zip %.mp3 %.mid %.avi %.mov %.mpg %.mp4
            %.swf %.doc %.rtf %.xls %.ttf %.bat %.msi
        ] (suffix? my-file) [call my-file]
        find [%.dll %.bin %.sys] (suffix? my-file) [
            alert "This type of file should not be opened directly."
        ]
        true [do-no-closer [editor my-file]]
    ]
    do file-request
]


REBOL [title: "RebGUI Data Card File"]
do load-thru http://re-bol.com/rebgui.r
write/append %data.txt ""
database: load %data.txt
display "RebGUI Card File" [
    text 20 "Select:"
    names: drop-list #LW data (sort extract copy database 4) [
        marker: find database pick names/data names/picked
        set-text n copy first marker
        set-text a copy second marker
        set-text p copy third marker
        set-text o copy fourth marker
    ]
    after 2
    text 20 "Name:"        n: field #LW ""
    text 20 "Address:"     a: field #LW ""
    text 20 "Phone:"       p: field #LW ""
    after 1 text "Notes:"  o: area #LW ""
    after 3
    button -1 "Save" [
        if (n/text = "") [alert "You must enter a name." return]
        if find (sort extract copy database 4) copy n/text [
            either true = question "Overwrite existing record?" [
               remove/part (find database n/text) 4
            ] [return]
        ]
        database: repend database [
            copy n/text copy a/text copy p/text copy o/text
        ]
        save %data.txt database
        set-data names (sort extract copy database 4)
        set-text names copy n/text
    ]
    button -1 "Delete" [
        if true = question rejoin ["Delete " copy  n/text "?"] [
            remove/part (find database n/text) 4
            save %data.txt database
            set-data names (sort extract copy database 4)
            set-values face/parent-face ["" "" "" "" ""]
        ]
    ]
    button -1 "New" [
            set-values face/parent-face ["" "" "" "" ""]
    ]
]
do-events


REBOL [title: "RebGUI Text Editor"]
unless exists? %ui.dat [
    write %ui.dat read http://re-bol.com/ui-editor.dat
]
do load-thru http://re-bol.com/rebgui.r    ; Build#117
; do %rebgui.r
filename: %temp.txt
make-dir %./edit_history/
backup: does [
    if ((length? x/text) > 0) [
        write rejoin [
            %./edit_history/ 
             last split-path filename 
             "_" now/date "_"
             replace/all form now/time ":" "-"
        ] x/text
    ]
]
ctx-rebgui/on-fkey/f5: does [
    backup
    write filename x/text
    launch filename
]
display/maximize/close "RebGUI Editor" [
    tight
    menu #LW data [
        "File" [
            "  New  " [
                if true = question "Erase Current Text?" [
                    backup
                    filename: %temp.txt set-text x copy ""
                ]
            ]
            "  Open  " [
                filetemp: to-file request-file/file filename
                if filetemp = %none [return]
                backup
                set-text x read filename: filetemp
            ]
            "  Save  " [
                backup
                write filename x/text
            ]
            "  Save As  " [
                filetemp: to-file request-file/save/file filename
                if filetemp = %none [return]
                backup
                write filename: filetemp x/text
            ]
            "  Save and Run  " [
                backup
                write filename x/text 
                launch filename
            ]
            "  Print  "  [
                write %./edit_history/print-file.html rejoin [
                    {<}{pre}{>} x/text {<}{pre}{>}
                ]
                browse %./edit_history/print-file.html
            ]
            "  Quit  " [
                if true = question "Really Close?" [backup quit]
            ]
        ]
        "Options" [
            "  Appearance  " [request-ui]
        ]
        "Help" [
            "  Shortcut Keys  " [
                alert trim {
                    F5:       Save and Run
                    Ctrl+Z:   Undo
                    Ctrl+Y:   Redo
                    Esc:      Undo All
                    Ctrl+S:   Spellcheck
                }
            ]
        ] 
    ] return
    x: area #LHW
] [
    if true = question "Really Close?" [backup quit]
]
do-events


REBOL [title: "Voice Alarms"]
lib: load/library %winmm.dll
mci: make routine! [c [string!] return: [logic!]] lib "mciExecute"
write %play-alarm.r {
    REBOL []
    wait 0
    the-sound: load %tmp.wav
    evnt: load %event.tmp
    if (evnt = []) [evnt: "Test"]
    forever [
        if error? try [
             insert s: open sound:// the-sound wait s close s
        ] [
             alert "Error playing sound!"
        ]
        delay: :00:07
        s: request/timeout [
            join uppercase evnt " alarm - repeats until you click 'stop':"
            "Continue"
            "STOP"
        ] delay
        if s = false [break]
    ]
}
current: rejoin [form now/date newline form now/time]
view center-face layout [
    c: box black 400x200 font-size 50 current rate :00:01 feel [
        engage: func [f a e] [
            if a = 'time [
                c/text: rejoin [form now/date newline form now/time]
                show c
                if error? try [
                    foreach evnt (to-block events/text) [
                        if any [
                             evnt/1 = form rejoin [
                                 now/date {/} now/time
                             ]
                             evnt/1 = form now/time  
                        ] [
                            if error? try [
                                 save %event.tmp form evnt/3
                                 write/binary %tmp.wav 
                                 read/binary to-file evnt/2
                                 launch %play-alarm.r
                            ] [
                                 alert "Error playing sound!"
                            ]
                            ; request/timeout [(form evnt/3) "Ok"] :00:05
                        ]
                    ]
                ] []  ; do nothing if user is manually editing events
            ] 
        ] 
    ]
    h3 "Alarm Events (these CAN be edited manually):"
    events: area  ; {[8:00:00am %alarm1.wav "Test Alarm - DELETE ME"]}
    across
    btn "Record Alarm Sound" [
        mci "open new type waveaudio alias wav"
        mci "record wav"
        request ["*** NOW RECORDING *** Click 'stop' to end:" "STOP"]
        mci "stop wav"
        if error? try [x: first request-file/file/save %alarm1.wav] [
            mci "close wav"
            return
        ]
        mci rejoin ["save wav " to-local-file x]
        mci "close wav"
        request [rejoin ["Here's how " form x " sounds..."] "Listen"]
        if error? try [
            save %event.tmp "test"
            write/binary %tmp.wav 
            read/binary to-file x
            launch %play-alarm.r
        ] [
            alert "Error playing sound!"
        ]
    ]
    btn "Add Event" [
        event-name: request-text/title/default "Event Title:" "Event 1"
        the-time: request-text/title/default "Enter a date/time:" rejoin [
            now/date {/} now/time
        ]
        if error? try [set-time: to-date the-time] [
            if error? try [set-time: to-time the-time] [
                alert "Not a valid time!"
                break
            ]
        ]
        my-sound: request-file/title/file ".WAV file:""" %alarm1.wav
        if my-sound = none [break]
        event-block: copy []
        append event-block form the-time
        append event-block my-sound
        append event-block event-name
        either events/text = "" [spacer: ""][spacer: newline]
        events/text: rejoin [events/text spacer (mold event-block)]
        show events
    ]
    btn "Save Events" [
        write to-file request-file/file/save %alarm_events.txt events/text
    ]
    btn "Load Events" [
        if error? try [
            events/text: read to-file request-file/file %alarm_events.txt
        ] [return]
        show events
    ]
]


REBOL [title: "Little 3D Game"]
beep-sound: load to-binary decompress 64#{
eJwBUQKu/VJJRkZJAgAAV0FWRWZtdCAQAAAAAQABABErAAARKwAAAQAIAGRhdGEl
AgAA0d3f1cGadFQ+T2Z9jn1lSjM8T2uNsM/j7Midc05PWGh4eXVrXE5DQEZumsTn
4M2yk3hiVU9fcX+GcFU8KkNmj7rR3+HYroJbPUpfdoqAbldBP0ZWbpW62OvRrohk
WlleaHB2dW9bRzo1WYWy3OHbyrKObVNCVGp/jXpgRC48Vnievtfm6MCUaUVLWW1/
fXNkUkdCRlN7ps3r3cSkgm1fWFhmdH2AaVA6LElwnMja4dzNpHtXPUxje45/aVA5
PUtif6TG3uvMpHtXU1lkcnd2cGVURT0+ZJC84+HUvaGCZ1NIWm6AinVaQCtAX4Wu
yt3k37aJYEBKXXOHf3FdSEJET2KJsdPr1reUcGJbW2FsdXl2YUs5MFF7qdPe3tO+
mHNUP1Bnfo59ZEkyPFFukbTR5OvGm3BMTVlpent1aVpMQ0FJcZ3I6uHMsJB2YlZR
YXJ/hW5UOypEaJK90+Dg1qyBWjxKYHeLgG1WPz9HWXKYvNnr0KyFYVhZX2pydnVu
Wkc7N1yHtN3h2sivjGxTRFZrgI15X0MtPVh7osHZ5ua+kmdES1tvgn5zY1BGQ0hW
fqjO69vBoX9rXllaaHV9fmhPOi1Lcp/K2+DayaF4Vj1NY3uNfmhONjxLZIKnyODr
yqJ4VFFYZHN3dm5iUUM9QGaTv+Th0rqdf2VTSltvgIl0WT4rQGCIssze5N60iF8/
Sl10h39vW0ZBRFFljLPU69W1kG1gWlxiYHkWb1ECAAA=
}
alert {
   Try to click the bouncing REBOLs as many times as possible in
   30 seconds.  The speed increases with each click!
}
do game: [
   speaker: open sound://
   g: 12 i: 5 h: i * g j: negate h  x: y: z: w: sc: 0  v2: v1: 1  o: now
   img1: to-image layout [backcolor brown box red center logo.gif]
   img2: to-image layout [backcolor aqua box yellow center logo.gif]
   img3: to-image layout [backcolor green box tan center logo.gif]
   cube: [[h h j][h h h][h j j][h j h][j h j][j h h][j j j][j j h]]
   view center-face layout/tight [
      f: box white 550x550 rate 15 feel [engage: func [f a e] [
         if a = 'time [
            b: copy []  x: x + 3  y: y + 3  ; z: z + 3
            repeat n 8 [
               if w > 500 [v1: 0]   if w < 50 [v1: 1]
               either v1 = 1 [w: w + 1] [w: w - 1]
               if j > (g * i * 1.4) [v2: 0]   if j < 1 [v2: 1]
               either v2 = 1 [h: h - 1] [h: h + 1]  j: negate h
               p: reduce pick cube n 
               zx: p/1 * cosine z - (p/2 * sine z) - p/1
               zy: p/1 * sine z + (p/2 * cosine z) - p/2
               yx: (p/1 + zx * cosine y) - (p/3 * sine y) - p/1 - zx
               yz: (p/1 + zx * sine y) + (p/3 * cosine y) - p/3
               xy: (p/2 + zy * cosine x) - (p/3 + yz * sine x) - p/2 - zy
               append b as-pair (p/1 + yx + zx + w) (p/2 + zy + xy + w)
            ]
            f/effect: [draw [
               image img1 b/6 b/2 b/4 b/8
               image img2 b/6 b/5 b/1 b/2
               image img3 b/1 b/5 b/7 b/3 
            ]]
            show f
            if now/time - o/time > :00:20 [
               close speaker
               either true = request [
                  join "Time's Up! Final Score: " sc "Again" "Quit"
               ] [do game] [quit]
            ]
         ]
         if a = 'down [
            xblock: copy [] yblock: copy []
            repeat n 8 [
                append xblock first pick b n
                append yblock second pick b n
            ]
            if all [
                e/offset/1 >= first minimum-of xblock
                e/offset/1 <= first maximum-of xblock
                e/offset/2 >= first minimum-of yblock
                e/offset/2 <= first maximum-of yblock
            ][
               insert speaker beep-sound wait speaker
               sc: sc + 1
               t1/text: join "Score: " sc 
               show t1
               if (modulo sc 3) = 0 [f/rate: f/rate + 1]
               show f
            ]
         ]
      ]]
      at 200x0 t1: text brown "Click the bouncing REBOLs!"
   ]
]


Rebol [title: "Playing Card Framework - Freecell"]
flash "Downloading card images..."
do load-thru http://www.re-bol.com/playing-cards.r
unview
random/seed now
loop 156 [
    pos1: pick cards rnd1: (random 52) * 5
    pos2: pick cards rnd2: (random 52) * 5
    poke cards rnd1 pos2
    poke cards rnd2 pos1
]
movestyle: [
    engage: func [face action event] [
        if action = 'down [
            start-coord: face/offset
            face/data: event/offset
            remove find face/parent-face/pane face
            append face/parent-face/pane face
        ]
        if find [over away] action [
            unrounded-pos: (face/offset + event/offset - face/data)
            snap-to-x: (round/to first unrounded-pos 80) + 20
            snap-to-y: (round/to second unrounded-pos 20) + 20
            face/offset: (as-pair snap-to-x snap-to-y)
        ]
        if action = 'up [
            if any [
                (find cards face/offset)
                (face/offset/2 < 20)
            ] [
                if (face/offset/2 < 398) [face/offset: start-coord]
            ]
            replace cards start-coord face/offset
            arrange-cards
        ]
        show face
    ]
]
positions: does [
    temp: copy []
    foreach item cards [if ((type? item) = pair!) [append temp item]]
    return sort temp
]
arrange-cards: does [
    foreach position positions [
        foreach card system/view/screen-face/pane/1/pane [
            if (card/offset = position) and (position/2 < 398) [
                remove find system/view/screen-face/pane/1/pane card
                append system/view/screen-face/pane/1/pane card
            ]
        ]
    ]
    show system/view/screen-face/pane/1/pane
]
gui: [size 670x510 backdrop 0.150.0 across ]
foreach [card label num color pos] cards [
    append gui compose [
        at (pos) image load to-binary decompress (card) feel movestyle
    ]
]
box-pos: 18x398
loop 4 [
    append gui compose [
        at (box-pos) box green 72x2
        at (box-pos) box green 2x97
        at (box-pos + 320x0) box white 72x2
        at (box-pos + 320x0) box white 2x97
    ]
    box-pos: box-pos + 80x0
]
view/new center-face layout gui
arrange-cards
do-events


REBOL [title: "Number Verbalizer"] 
verbalize: func [a-number] [
    if error? try [a-number: to-decimal a-number] [
        return "** Error **  Input must be a decimal value"
    ]
    if a-number = 0 [return "Zero"]
    the-original-number: round/down a-number
    pennies: a-number - the-original-number
    the-number: the-original-number
    if a-number < 1 [
        return join to-integer ((round/to pennies .01) * 100) "/100"
    ] 
    small-numbers: [
        "One" "Two" "Three" "Four" "Five" "Six" "Seven" "Eight"
        "Nine" "Ten" "Eleven" "Twelve" "Thirteen" "Fourteen" "Fifteen"
        "Sixteen" "Seventeen" "Eighteen" "Nineteen"
    ]
    tens-block: [
        { } "Twenty" "Thirty" "Forty" "Fifty" "Sixty" "Seventy" "Eighty"
        "Ninety"
    ]
    big-numbers-block: ["Thousand" "Million" "Billion"]    
    digit-groups: copy []
    for i 0 4 1 [
        append digit-groups (round/floor (mod the-number 1000))
        the-number: the-number / 1000
    ]    
    spoken: copy ""
    for i 5 1 -1 [
        flag: false
        hundreds: (pick digit-groups i) / 100
        tens-units: mod (pick digit-groups i) 100
        if hundreds <> 0 [
            if none <> hundreds-portion: (pick small-numbers hundreds) [
                append spoken join hundreds-portion " Hundred "
            ]
            flag: true
        ]
        tens: tens-units / 10
        units: mod tens-units 10
        if tens >= 2 [
            append spoken (pick tens-block tens)
            if units <> 0 [
                if none <> last-portion: (pick small-numbers units) [
                    append spoken rejoin [" " last-portion " "]
                ]
                flag: true
            ]
        ]
        if tens-units <> 0 [
            if none <> tens-portion: (pick small-numbers tens-units) [
                append spoken join tens-portion " "
            ]
            flag: true
        ]
        if flag = true [
            commas: copy {}    
            case [
                ((i = 4) and (the-original-number > 999999999)) [
                    commas: {billion, }
                ]
                ((i = 3) and (the-original-number > 999999)) [
                    commas: {million, }
                ]
                ((i = 2) and (the-original-number > 999)) [
                    commas: {thousand, }
                ]
            ]
            append spoken commas
        ]
    ]
    append spoken rejoin [
        "and " to-integer ((round/to pennies .01) * 100) "/100"
     ]
    return spoken
]
; HERE'S AN EXAMPLE OF HOW TO USE IT:
print verbalize ask "Enter a number to verbalize: "
halt


REBOL [Title: "Console Email"]
accounts: [
    ["pop.server" "smtp.server" "username" "password" you@site.com]
    ["pop.server2" "smtp.server2" "username" "password" you@site2.com]
    ["pop.server3" "smtp.server3" "username" "password" you@site3.com]
]
empty-lines: "^/"
loop 400 [append empty-lines "^/"]  ; # of lines it takes to clear screen
cls: does [prin {^(1B)[J}]
a-line:{-----------------------------------------------------------------}
select-account: does [
    cls
    print a-line
    forall accounts [
        print rejoin ["^/" index? accounts ":  " last first accounts]
    ]
    print join "^/" a-line
    selected: ask "^/Select an account #:  "
    if selected = "" [selected: 1]
    t: pick accounts (to-integer selected)
    system/schemes/pop/host:  t/1
    system/schemes/default/host: t/2
    system/schemes/default/user: t/3 
    system/schemes/default/pass: t/4 
    system/user/email: t/5
]
send-email: func [/reply] [
    cls
    print rejoin [a-line "^/^/Send Email:^/^/" a-line] 
    either reply [
        print join "^/^/Reply-to:  " addr: form pretty/from
    ] [
        addr: ask "^/^/Recipient Email Address:  "
    ]
    either reply [
        print join "^/Subject:  " subject: join "re: " form pretty/subject
    ] [
        subject: ask "^/Email Subject:  "
    ]
    print {^/Body (when finished, type "end" on a seperate line):^/}
    print join a-line "^/"
    body: copy ""
    get-body: does [
        body-line: ask ""
        if body-line = "end" [return]
        body: rejoin [body "^/" body-line]
        get-body
    ]
    get-body
    if reply [
        rc: ask "^/Quote original email in your reply (Y/n)?  "
        if ((rc = "yes") or (rc = "y") or (rc = "")) [
            body: rejoin [
                body 
                "^/^/^/--- Quoting " form pretty/from ":^/"
                form pretty/content
            ]
        ]
    ]
    print rejoin ["^/" a-line "^/^/Sending..."]
    send/subject to-email addr body subject 
    cls 
    print "Sent^/" 
    wait 1
]
read-email: does [
    pretty: none
    cls
    print "One moment..."
    mail: open to-url join "pop://" system/user/email
    cls
    while [not tail? mail] [
        print "Reading...^/"
        pretty: import-email (copy first mail)
        either find pretty/subject "***SPAM***" [
            print join "Spam found in message #" length? mail
            mail: next mail
        ][
            print empty-lines
            cls
            prin rejoin [
                a-line
                {^/The following message is #} length? mail { from:  } 
                system/user/email {^/} a-line {^/^/}
                {FROM:     } pretty/from {^/}
                {DATE:     } pretty/date {^/}
                {SUBJECT:  } pretty/subject {^/^/} a-line
            ]
            confirm: ask "^/^/Read Entire Message (Y/n):  "
            if ((confirm = "y") or (confirm = "yes") or (confirm = "")) [
                print join {^/^/} pretty/content
            ]
            print rejoin [
                {^/} a-line {^/}
                {^/[ENTER]:  Go Forward  (next email)^/}
                {^/    "b":  Go Backward (previous email)^/}
                {^/    "r":  Reply to current email^/}
                {^/    "d":  Delete current email^/}
                {^/    "q":  Quit this mail box^/}
                {^/  Any #:  Skip forward or backward this # of messages}
                {^/^/} a-line {^/}
            ]
            switch/default mail-command: ask "Enter Command:  " [
                ""  [mail: next mail]
                "b" [mail: back mail]
                "r" [send-email/reply]
                "d" [
                    remove mail
                    cls 
                    print "Email deleted!^/" 
                    wait 1
                ]
                "q" [
                    close mail
                    cls
                    print"Mail box closed^/"
                    wait 1 
                    break
                ]
            ] [mail: skip mail to-integer mail-command]
            if (tail? mail) [mail: back mail]
        ]
    ]
]
select-account
forever [
    cls
    print a-line
    print rejoin [
        {^/"r":  Read Email^/}
        {^/"s":  Send Email^/}
        {^/"c":  Choose a different mail account^/}
        {^/"q":  Quit^/}
    ]
    print a-line
    response: ask "^/Select a menu choice:  "
    switch/default response [
        "r" [read-email]
        "s" [send-email]
        "c" [select-account]
        "q" [
            cls
            print "DONE!"
            wait .5 
            quit
        ]
    ] [read-email]
]


REBOL [Title: "MP3 Jukebox"]
if not exists? %libwmp3.dll [
    write/binary %libwmp3.dll
    read/binary http://musiclessonz.com/rebol_tutorial/libwmp3.dll
]
lib: load/library %libwmp3.dll
Mp3_Initialize: make routine! [
    return: [integer!]
] lib "Mp3_Initialize"
Mp3_OpenFile: make routine! [
    return: [integer!] 
    class [integer!] 
    filename [string!]
    nWaveBufferLengthMs [integer!]
    nSeekFromStart [integer!] 
    nFileSize [integer!]
] lib "Mp3_OpenFile"
Mp3_Play: make routine! [
    return: [integer!] 
    initialized [integer!]
] lib "Mp3_Play"
Mp3_Stop: make routine! [
    return: [integer!] 
    initialized [integer!]
] lib "Mp3_Stop"
Mp3_Destroy: make routine! [
    return: [integer!] 
    initialized [integer!]
] lib "Mp3_Destroy"
Mp3_GetStatus: make routine! [
    return: [integer!] 
    initialized [integer!] 
    status [struct! []]
] lib "Mp3_GetStatus"
status: make struct! [
    fPlay [integer!] 
    fPause [integer!] 
    fStop [integer!] 
    fEcho [integer!] 
    nSfxMode [integer!] 
    fExternalEQ [integer!] 
    fInternalEQ [integer!] 
    fVocalCut [integer!] 
    fChannelMix [integer!] 
    fFadeIn [integer!] 
    fFadeOut [integer!] 
    fInternalVolume [integer!] 
    fLoop [integer!] 
    fReverse [integer!] 
] none
Mp3_Time: make struct! [
    ms [integer!] 
    sec [integer!]
    bytes [integer!] 
    frames [integer!] 
    hms_hour [integer!] 
    hms_minute [integer!] 
    hms_second [integer!] 
    hms_millisecond [integer!] 
] none
TIME_FORMAT_SEC: 2
SONG_BEGIN: 1
SONG_CURRENT_FORWARD: 4
Mp3_Seek: make routine! [
    return: [integer!] 
    initialized [integer!]
    fFormat [integer!]
    pTime [struct! []]
    nMoveMethod [integer!]
] lib "Mp3_Seek"
Mp3_PlayLoop: make routine! [
    return: [integer!] 
    initialized [integer!]
    fFormatStartTime [integer!]
    pStartTime [struct! []]
    fFormatEndTime [integer!] 
    pEndTime [struct! []]
    nNumOfRepeat [integer!] 
] lib "Mp3_PlayLoop"
Mp3_GetSongLength: make routine! [
    return: [integer!]
    initialized [integer!]
    pLength [struct! []]
] lib "Mp3_GetSongLength"
Mp3_GetPosition: make routine! [
    return: [integer!] 
    initialized [integer!]
    pTime [struct! []]
] lib "Mp3_GetPosition"
Mp3_SetVolume: make routine! [
    return: [integer!] 
    initialized [integer!]
    nLeftVolume [integer!]
    nRightVolume [integer!]
] lib "Mp3_SetVolume"
Mp3_GetVolume: [
    initialized [integer!]
    pnLeftVolume [integer!]
    pnRightVolume [integer!]
    return: [integer!]
] lib "Mp3_GetVolume"
Mp3_VocalCut: make routine! [
    return: [integer!] 
    initialized [integer!]
    fEnable [integer!]
] lib "Mp3_VocalCut"
Mp3_ReverseMode: make routine! [
    return: [integer!] 
    initialized [integer!]
    fEnable [integer!]
] lib "Mp3_ReverseMode"
Mp3_Close: make routine! [
    return: [integer!] 
    initialized [integer!]
] lib "Mp3_Close"
waves: []
foreach file read %. [
    if (%.mp3 = suffix? file) [append waves file]
]
append waves "(CHANGE FOLDER...)"
initialized: Mp3_Initialize
view center-face layout [
    vh2 "Click a File to Play:"
    file-list: text-list data waves [
        if value = "(CHANGE FOLDER...)" [
            new-dir: request-dir
            if new-dir = none [break]
            change-dir new-dir
            waves: copy []
            foreach file read %. [
                if (%.mp3 = suffix? file) [append waves file]
            ]
            append waves "(CHANGE FOLDER...)"
            file-list/data: waves
            show file-list
            break
        ]
        Mp3_GetStatus initialized status
        if (status/fPlay = 0) [
            file: rejoin [to-local-file what-dir "\" value]
            Mp3_OpenFile initialized file 1000 0 0
            Mp3_Play initialized
        ]
    ]
    across
    tabs 40
    text "Seek:   " 
    tab slider 140x15 [
        plength: make struct! Mp3_Time compose [0 0 0 0 0 0 0 0]
        Mp3_GetSongLength initialized plength
        location: to-integer (value * plength/sec)
        ptime: make struct! Mp3_Time compose [0 (location) 0 0 0 0 0 0]
        Mp3_Seek initialized TIME_FORMAT_SEC ptime SONG_BEGIN
        Mp3_Play initialized
    ]
    return
    text "Volume: " 
    tab slider 140x15 [
        volume: to-integer value * 100
        Mp3_SetVolume initialized volume volume
    ]
    return
    btn "Reverse" [
        Mp3_GetStatus initialized status
        either (status/fReverse > 0) [
            Mp3_ReverseMode initialized 0
        ] [
            Mp3_ReverseMode initialized 1
        ]
    ]
    btn "Vocal-Cut" [
        Mp3_GetStatus initialized status
        either (status/fVocalCut > 0) [
            Mp3_VocalCut initialized 0
        ] [
            Mp3_VocalCut initialized 1
        ]
    ]
    return
    tabs 50
    text "Loop Start:" 
    tab start-slider: slider 120x15 []
    return
    text "Loop End:  " 
    tab end-slider: slider 120x15 []
    return
    btn "Play Loop" [
        plength: make struct! Mp3_Time compose [0 0 0 0 0 0 0 0]
        Mp3_GetSongLength initialized plength
        s-loc: to-integer (start-slider/data * plength/sec)
        pStartTime: make struct! Mp3_Time compose [0 (s-loc) 0 0 0 0 0 0]
        end-loc: to-integer (end-slider/data * plength/sec)
        pEndTime: make struct! Mp3_Time compose [0 (end-loc) 0 0 0 0 0 0]
        ; TIME_FORMAT_SEC: 2
        Mp3_PlayLoop initialized 2 pStartTime 2 pEndTime 1000  ; 1000x
    ]
    btn 58 "Stop" [
        Mp3_GetStatus initialized status
        if (status/fPlay > 0) [Mp3_Stop initialized]
    ]
]
Mp3_Destroy initialized
free lib


REBOL [Title: "Textris"]
tui: func [commands [block!]] [
    string: copy ""
    cmd: func [s][join "^(1B)[" s]
    arg: parse commands [
        any [
            'clear (append string cmd "J") |
            'up    set arg integer! (append string cmd [
                arg "A"]) |
            'down  set arg integer! (append string cmd [
                arg "B"]) |
            'right set arg integer! (append string cmd [
                arg "C"]) |
            'left  set arg integer! (append string cmd [
                arg "D"]) |
            'at   set arg pair! (append string cmd [
                arg/x ";" arg/y "H" ]) |
            set arg string! (append string arg)
        ]
        end
    ]
    string
]
shape: [
    ["####"]
    ["#" down 1 left 1 "#" down 1 left 1 "#" down 1 left 1 "#"]
    ["###" down 1 left 2 "#"]
    [right 1 "#" down 1 left 2 "##" down 1 left 1 "#"]
    [right 1 "#" down 1 left 2 "###"]
    ["#" down 1 left 1 "##" down 1 left 2 "#"]
    ["###" down 1 left 3 "#"]
    ["##" down 1 left 1 "#" down 1 left 1 "#"]
    [right 2 "#" down 1 left 3 "###"]
    ["#" down 1 left 1 "#" down 1 left 1 "##"]
    ["###" down 1 left 1 "#"]
    [right 1 "#" down 1 left 1 "#" down 1 left 2 "##"]
    ["#" down 1 left 1 "###"]
    ["##" down 1 left 2 "#" down 1 left 1 "#"]
    ["##" down 1 left 1 "##"]
    [right 1 "#" down 1 left 2 "##" down 1 left 2 "#"]
    [right 1 "##" down 1 left 3 "##"]
    ["#" down 1 left 1 "##" down 1 left 1 "#"]
    ["##" down 1 left 2 "##"]
    ;
    ["    "]
    [" " down 1 left 1 " " down 1 left 1 " " down 1 left 1 " "]
    ["   " down 1 left 2 " "]
    [right 1 " " down 1 left 2 "  " down 1 left 1 " "]
    [right 1 " " down 1 left 2 "   "]
    [" " down 1 left 1 "  " down 1 left 2 " "]
    ["   " down 1 left 3 " "]
    ["  " down 1 left 1 " " down 1 left 1 " "]
    [right 2 " " down 1 left 3 "   "]
    [" " down 1 left 1 " " down 1 left 1 "  "]
    ["   " down 1 left 1 " "]
    [right 1 " " down 1 left 1 " " down 1 left 2 "  "]
    [" " down 1 left 1 "   "]
    ["  " down 1 left 2 " " down 1 left 1 " "]
    ["  " down 1 left 1 "  "]
    [right 1 " " down 1 left 2 "  " down 1 left 2 " "]
    [right 1 "  " down 1 left 3 "  "]
    [" " down 1 left 1 "  " down 1 left 1 " "]
    ["  " down 1 left 2 "  "]
]
floor:  [
    21x5 21x6 21x7 21x8 21x9 21x10 21x11 21x12 21x13 21x14 21x15
]
oc:  [ 
    [0x0 0x1 0x2 0x3] [0x0 1x0 2x0 3x0] [0x0 0x1 0x2 1x1]
    [0x1 1x0 1x1 2x1] [0x1 1x0 1x1 1x2] [0x0 1x0 1x1 2x0]
    [0x0 0x1 0x2 1x0] [0x0 0x1 1x1 2x1] [0x2 1x0 1x1 1x2]
    [0x0 1x0 2x0 2x1] [0x0 0x1 0x2 1x2] [0x1 1x1 2x0 2x1]
    [0x0 1x0 1x1 1x2] [0x0 0x1 1x0 2x0] [0x0 0x1 1x1 1x2]
    [0x1 1x0 1x1 2x0] [0x1 0x2 1x0 1x1] [0x0 1x0 1x1 2x1]
    [0x0 0x1 1x0 1x1] 
]
width: [4 1 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 2]
score: 0
prin tui [clear]
a-line: copy [] loop 11 [append a-line " "] 
a-line: rejoin ["   |"  to-string a-line "|"]
loop 20 [print a-line] prin "   " loop 13 [prin "+"] print ""
print tui compose [
    at 4x21 "TEXTRIS" at 5x21 "-------" 
    at 7x20 "Use arrow keys" at 8x20 "to move/spin."
    at 10x20 "'P' = pause"
    at 13x20 "SCORE:  " (to-string score)
]
keys: open/binary/no-wait [scheme: 'console]
forever [
    random/seed now
    r: random 19
    xpos: 9
    for i 1 20 1 [
        pos: to-pair rejoin [i "x" xpos]
        do compose/deep [prin tui [at (pos)] print tui shape/(r)]
        old-r: r
        old-xpos: xpos 
        if not none? wait/all [keys :00:00.30] [
            switch/default to-string copy keys [
                "p" [
                    print tui [
                        at 23x0 "Press [Enter] to continue"
                    ]
                    ask ""
                    print tui [
                        at 24x0 "                              "
                        at 23x0 "                              "
                    ]
                ]
                "^[[D" [if (xpos > 5) [
                        xpos: xpos - 1
                ]]
                "^[[C" [if (xpos < (16 - compose width/(r))) [
                        xpos: xpos + 1
                ]]
                "^[[A" [if (xpos < (16 - compose width/(r)))  [
                        switch to-string r [
                            "1" [r: 2]
                            "2" [r: 1]
                            "3" [r: 6]
                            "4" [r: 3]
                            "5" [r: 4]
                            "6" [r: 5]
                            "7" [r: 10]
                            "8" [r: 7]
                            "9" [r: 8]
                            "10" [r: 9]
                            "11" [r: 14]
                            "12" [r: 11]
                            "13" [r: 12]
                            "14" [r: 13]
                            "15" [r: 16]
                            "16" [r: 15]
                            "17" [r: 18]
                            "18" [r: 17]
                            "19" [r: 19]
                        ]
                    ]
                ]           
            ] []
        ]
        do compose/deep [
            prin tui [at (pos)] print tui shape/(old-r + 19)
        ]
        stop: false
        foreach po compose oc/(r) [
            foreach coord floor [
                floor-y: to-integer first coord
                floor-x: to-integer second coord
                oc-y:  i + to-integer first po
                oc-x:  xpos + to-integer second po
                if (oc-y = (floor-y - 1)) and (floor-x = oc-x) [
                    stop-shape-num: r
                    stop: true
                    break
                ]
            ]
        ]
        foreach po compose oc/(old-r) [
            foreach coord floor [
                floor-y: to-integer first coord
                floor-x: to-integer second coord
                oc-y:  i + to-integer first po
                oc-x:  old-xpos + to-integer second po
                if (oc-y = (floor-y - 1)) and (floor-x = oc-x) [
                    stop-shape-num: old-r
                    stop: true
                    break
                ]
            ]
        ]
        if stop = true [
            left-col: second pos 
            width-of-shape: length? compose oc/(stop-shape-num)
            right-col: left-col + width-of-shape - 1
            counter: 1
            for current-column left-col right-col 1 [
                add-coord: compose oc/(stop-shape-num)/(counter)
                new-floor-coord: (pos + add-coord)
                append floor new-floor-coord
                counter: counter + 1
            ]
            break
        ]
    ]
    do compose/deep [prin tui [at (pos)] print tui shape/(old-r)]
    if (first pos) < 2 [
        prin tui [at 23x0]
        print "   GAME OVER!!!^/^/"
        halt
    ]
    score: score + 10
    print tui compose [at 13x28 (to-string score)]
    for row 1 20 1 [
        line-is-full: true
        for colmn 5 15 1 [
            each-coord: to-pair rejoin [row "x" colmn]
            if not find floor each-coord [
                line-is-full: false
                break
            ]
        ]
        if line-is-full = true [
            remove-each cor floor [(first cor) = row]
            new-floor: copy [
                21x5 21x6 21x7 21x8 21x9 21x10 21x11 21x12 21x13
                21x14 21x15
            ]
            foreach cords floor [
                either ((first cords) < row) [
                    append new-floor (cords + 1x0)
                ][
                    append new-floor cords
                ]
            ]
            floor: copy unique new-floor
            score: score + 1000
            prin tui [clear]
            loop 20 [print a-line] 
            prin "   " loop 13 [prin "+"] print ""
            print tui compose [
                at 4x21 "TEXTRIS" at 5x21 "-------" 
                at 7x20 "Use arrow keys" at 8x20 "to move/spin."
                at 10x20 "'P' = pause"
                at 13x20 "SCORE:  " (to-string score)
            ]
            foreach was-here floor [
                if not ((first was-here) = 21) [
                    prin tui compose [at (was-here)]
                    prin "#"
                ]
            ]
        ]
    ]
]


#! ./rebol -cs
REBOL [title: "CGI Bulletin Board"  filename: %bb.cgi]
print {content-type: text/html^/}
print read %template_header.html
bbs: load %bb.db
print {
    <center><table border=1 cellpadding=10 width=600><tr><td>
    <center><strong><font size=4>
    Please REFRESH this page to see new messages.
    </font></strong></center>
}
print-all: does [
    print {<br><hr><font size=5> Posted Messages: </font> <br><hr>}
    foreach bb (reverse bbs) [
        print rejoin [
            {<BR>Date/Time: } bb/2 {         }
            {"Name: } bb/1 {<BR><BR>} bb/3 {<BR><BR><HR>}
        ]
    ]
]
submitted: decode-cgi system/options/cgi/query-string
if submitted/2 <> none [
    entry: copy []
    append entry submitted/2
    append entry to-string (now + 3:00)
    append entry submitted/4
    append/only bbs entry
    save %bb.db bbs
    print {<BR><strong>Your message has been added: </strong><BR>}
]
print-all
print {
    <font size=5> Post A New Public Message:</font><hr>
    <FORM ACTION="./bb.cgi">
    <br> Your Name:  <br>
    <input type=text size="50" name="student"><BR><BR>
    Your Message: <br>
    <textarea name=message rows=5 cols=50></textarea><BR><BR>
    <INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Post Message">
    </FORM>
    </td></tr></table></center>
}
print read %template_footer.html


#! ./rebol -cs
REBOL [title: "CGI Simple Search"  filename: %search.cgi]
print "content-type: text/html^/"
print [<HTML><HEAD><TITLE>"Search"</TITLE></HEAD><BODY>]
; print read %template_header.html
submitted: decode-cgi system/options/cgi/query-string
if not empty? submitted [
    phrase: submitted/2
    start-folder: to-file submitted/4
    change-dir start-folder
    found-list: ""
    recurse: func [current-folder] [ 
        foreach item (read current-folder) [ 
            if not dir? item [  if error? try [
                if find (read to-file item) phrase [
                    print rejoin [{"} phrase {" found in:  }
                        what-dir item {<BR>}]
                    found-list: rejoin [found-list newline 
                        what-dir item]
                ]] [print rejoin ["error reading " item]]
            ]
        ]
        foreach item (read current-folder) [ 
            if dir? item [
                change-dir item 
                recurse %.\
                change-dir %..\
            ] 
        ] 
    ]
    print rejoin [{SEARCHING for "} phrase {" in } 
        start-folder {<BR><BR>}]
    recurse %.\
    print "<BR>DONE <BR>"
    ; save %found.txt found-list
    ; print read %template_footer.html
    quit
]
print [<CENTER><TABLE><TR><TD>]
print [<FORM ACTION="./search.cgi">]
print ["Text to search for:" <BR> 
    <INPUT TYPE="TEXT" NAME="phrase"><BR><BR>]
print ["Folder to search in:" <BR> 
    <INPUT TYPE="TEXT" NAME="folder" VALUE="../yourfolder/" ><BR><BR>]
print [<INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit">]
print [</FORM>]
print [</TD></TR></TABLE></CENTER>]
; print read %template_footer.html
quit


#! ./rebol -cs
REBOL [title: "CGI Event Calendar"]
print "content-type: text/html^/"
print {<HTML><HEAD><TITLE>Event Calendar</TITLE></HEAD><BODY>}
bbs: load %bb.db
date: now/date
html: copy rejoin [
    {<CENTER><TABLE border=1 valign=middle width=99% height=99%>
        <TR><TD colspan=7 align=center height=8%><FONT size=5>}
    pick system/locale/months date/month {  } date/year
    {</FONT></TD></TR><TR>}
]
days: ["Sun" "Mon" "Tue" "Wed" "Thu" "Fri" "Sat"]
foreach day days [
    append html rejoin [
        {<TD bgcolor="#206080" align=center width=10% height=5%>
        <FONT face="courier new,courier" color="FFFFFF" size="+1">}
        day 
        {</FONT></TD>}
    ]
]
append html {</TR><TR>}
sdate: date  sdate/day: 0  
loop sdate/weekday // 7 + 1 [append html {<TD bgcolor=gray></TD>}]
while [sdate/day: sdate/day + 1 sdate/month = date/month][
    event-labels: {}
    foreach entry bbs [
        date-in-entry: 1-Jan-1001
        attempt [date-in-entry: (to-date entry/2)]
        if (date-in-entry = sdate) [
            event-labels: rejoin [
                {<font size=1>}
                event-labels 
                "<strong><br><br>"
                {<a href="} to-string entry/3 {" target=_blank>}
                entry/1 
                {</a>}
                "</strong>"
                {</font>}
            ]
        ]
    ]
    append html rejoin [
        {<TD bgcolor="#}
        either date/day = sdate/day ["AA9060"]["FFFFFF"]
        ; HERE, THE EVENTS ARE PRINTED IN THE APPROPRIATE DAY:
        {" height=14% valign=top>} sdate/day event-labels
        {</TD>}
    ]
    if sdate/weekday = 6 [append html {</TR><TR>}]
]
loop 7 - sdate/weekday [append html rejoin [{<TD bgcolor=gray></TD>}]]
append html {</TR></TABLE></CENTER></BODY></HTML>}
print html
quit
{ 
    Events are stored in the file %bb.db, in the format:
    ["event 1" 18-Apr-2010 http://website.com/event1.html]
    ["event 2" 20-Apr-2010 http://website.com/event2.html]
    ["event 3" 20-Apr-2010 http://website.com/event3.html]
}


#! /home/path/public_html/rebol/rebol276 -cs
REBOL [Title: "CGI Console"  filename: %edit.cgi]
print "content-type: text/html^/"
print {<HTML><HEAD><TITLE>Console</TITLE></HEAD><BODY>}
selection: decode-cgi system/options/cgi/query-string
if ((selection/2 = none) or (selection/4 = none)) [
    print {
        <STRONG>W A R N I N G  -  Private Server, Login Required:</STRONG>
        <BR><BR>
        <FORM ACTION="./console.cgi">
        Username: <INPUT TYPE=text SIZE="50" NAME="name"><BR><BR>
        Password: <INPUT TYPE=text SIZE="50" NAME="pass"><BR><BR>
        <INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit">
        </FORM>
    }
    quit
]
qq: [
    print {
        <CENTER><FORM METHOD="get" ACTION="./console.cgi">
        <INPUT TYPE=hidden NAME=submit_confirm VALUE="command-submitted">
        <TEXTAREA COLS="100" ROWS="18" NAME="contents"></TEXTAREA><BR><BR>
        <INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit">
        </FORM></CENTER></BODY></HTML>
    }
]
if selection/2 = "command-submitted" [
    write %commands.txt join "REBOL[]^/" selection/4
    ; The "call" function requires REBOL version 2.76:
    call/output/error 
        "/home/path/public_html/rebol/rebol276 -qs commands.txt"
        %conso.txt %conse.txt
    print rejoin [
        {<CENTER>Output: <BR><BR>}
        {<TABLE WIDTH=80% BORDER="1" CELLPADDING="10"><TR><TD><PRE>}
        read %conso.txt
        {</PRE></TD></TR></TABLE><BR><BR>}
        {Errors: <BR><BR>}
        read %conse.txt
        {</CENTER>}
    ]
    do qq
    quit
]
username: selection/2 password: selection/4 
either (username = "user") and (password = "pass") [] [
    print "Incorrect Username/Password." quit
]
do qq


#!./rebol -cs
REBOL [title: "CGI Text Editor"]
print {content-type: text/html^/}
print {<HTML><HEAD><TITLE>Edit Text Document</TITLE></HEAD><BODY>}
read-cgi: func [/local data buffer][
    switch system/options/cgi/request-method [
        "POST" [
            data: make string! 1020
            buffer: make string! 16380
            while [positive? read-io system/ports/input buffer 16380][
                append data buffer
                clear buffer
            ]
        ]
        "GET" [data: system/options/cgi/query-string]
    ]
    data
]
submitted: decode-cgi read-cgi
if submitted/2 = "save" [ 
    ; save newly edited document:
    write to-file rejoin ["./" submitted/6 "/document.txt"] submitted/4
    print ["Document Saved."]
    print rejoin [
        {<META HTTP-EQUIV="REFRESH" CONTENT="0; 
            URL=http://website.com/folder/}
        submitted/6 {">}
    ]
    quit
]
if ((submitted/2 = none) or (submitted/4 = none)) [
    print {
        <strong>W A R N I N G  -  Private Server, Login Required:
        </strong><BR><BR>
        <FORM ACTION="./edit.cgi">
        Username: <input type=text size="50" name="name"><BR><BR>
        Password: <input type=text size="50" name="pass"><BR><BR>
        <INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit">
        </FORM>
    }
    quit
]
userlist: load %userlist.txt
folder: submitted/2 
password: submitted/4
response: false
foreach user userlist [
    if ((first user) = folder) and (password = (second user)) [
        response: true
    ]
]
if response = false [print {Incorrect Username/Password.} quit]
cur-time: to-string replace/all to-string now/time {:} {-}       ; backup
document_text: read to-file rejoin [{./} folder {/document.txt}]
write to-file rejoin [
    {./} folder {/} now/date {_} cur-time {.txt}] document_text
prin {
    <strong>Be sure to SUBMIT when done:</strong><BR><BR>
    <FORM method="post" ACTION="./edit.cgi">
    <INPUT TYPE=hidden NAME=submit_confirm VALUE="save">
    <textarea cols="100" rows="15" name="contents">
}
prin replace/all document_text {</textarea>} {&lt\/textarea&gt;}
print {</textarea><BR><BR>}
print rejoin [{<INPUT TYPE=hidden NAME=folder VALUE="} folder {">}]
print {<INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit">}
print {</FORM>}
print {</BODY></HTML>}


#! ./rebol -cs
REBOL [title: "CGI Event Signup"  filename: %event.cgi]
print {content-type: text/html^/}
print {<HTML><HEAD><TITLE>Event Sign-Up</TITLE></HEAD><BODY>}
events: load %event.db
a-line: [] loop 65 [append a-line "-"]
a-line: trim to-string a-line
print {
    <hr> <font size=5>" Sign up for an event:"</font> <hr><BR>
    <FORM ACTION="http://yourwebsite.com/cgi-bin/event.cgi">
    Student Name:
    <input type=text size="50" name="student"><BR><BR>
    ADD yourself to this event:             "
    <select NAME="add"><option>""<option>"all"
}
foreach event events [prin rejoin [{<option>} event/1]]
print {
    </option> </select> <BR> <BR>
    REMOVE yourself from this event:
    <select NAME="remove"><option>""<option>"all"
}
foreach event events [prin rejoin [{<option>} event/1]]
print {
    </option> </select> <BR> <BR>
    <INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit">
    </FORM>
}
print-all: does [
    print [<br><hr><font size=5>]
    print " Currently scheduled events, and current attendance:"
    print [</font><br>]
    foreach event events [
        print rejoin [a-line {<BR>} event/1 {BR} a-line {<BR>}]
        for person 2 (length? event) 1 [
            print event/:person
            print {<BR>}
        ]
        print {<BR>}
    ]
    print {</BODY></HTML>}
]
submitted: decode-cgi system/options/cgi/query-string
if submitted/2 <> none [
    if ((submitted/4 = "") and (submitted/6 = "")) [
        print {
            <strong> Please try again. You must choose an event.</strong>
        }
        print-all
        quit
    ]
    if ((submitted/4 <> "") and (submitted/6 <> "")) [
        print {
            <strong> Please try again. Choose add OR remove.</strong>
        }
        print-all
        quit
    ]
    if submitted/4 = "all" [
        foreach event events [append event submitted/2]
        save %event.db events
        print {
            <strong> Your name has been added to every event:</strong>
        }
        print-all
        quit
    ]
    if submitted/6 = "all" [
        foreach event events [
            if find event submitted/2 [
                remove-each name event [name = submitted/2]
                save %event.db events
            ]
        ]
        print {
            <strong> Your name has been removed from all events:</strong>
        }
        print-all
        quit
    ]
    foreach event events [
        if (find event submitted/4) [
            append event submitted/2
            save %event.db events
            print {
                <strong> Your name has been added to the selected event:
                </strong>
            }
            print-all
            quit    
        ]
    ]
    found: false
    foreach event events [
        if (find event submitted/6) [
            if (find event submitted/2) [
                remove-each name event [name = submitted/2]
                save %event.db events
                print {
                    <strong>
                    Your name has been removed from the selected event:
                    </strong>
                }
                print-all
                quit
                found: true
            ]
        ]
    ]
    if found <> true [
        print {
            <strong> That name is not found in the specified event!"
            </strong>
        }
        print-all
        quit
    ]
]
print-all


#! ./rebol -cs
REBOL [title: "CGI File Downloader"]
submitted: decode-cgi system/options/cgi/query-string
root-path: "/home/path"
if ((submitted/2 = none) or (submitted/4 = none)) [
    print "content-type: text/html^/"
    print [<STRONG>"W A R N I N G  -  "]
    print ["Private Server, Login Required:"</STRONG><BR><BR>]
    print [<FORM ACTION="./download.cgi">]
    print [" Username: " <INPUT TYPE=text SIZE="50" NAME="name"><BR><BR>]
    print [" Password: " <INPUT TYPE=text SIZE="50" NAME="pass"><BR><BR>]
    print [" File: "<BR><BR>]
    print [<INPUT TYPE=text SIZE="50" NAME="file" VALUE="/public_html/">]
    print [<BR><BR>]
    print [<INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit">]
    print [</FORM>]
    quit
]
username: submitted/2 password: submitted/4 
either (username = "user") and (password = "pass") [
    ; if user/pass is ok, go on
][
    print "content-type: text/html^/"
    print "Incorrect Username/Password." quit
]
print rejoin [
    "Content-Type: application/x-unknown"
    newline
    "Content-Length: "
    (size? to-file join root-path submitted/6) 
    newline
    "Content-Disposition: attachment; filename=" 
    (second split-path to-file submitted/6)
    newline
]
data: read/binary to-file join root-path submitted/6
data-length: size? to-file join root-path submitted/6
write-io system/ports/output data data-length


#!../rebol276 -cs
REBOL [Title: "Kindle Email"]
print {content-type: text/html^/^/}
print {<HTML><HEAD><TITLE>Kindle Email</TITLE></HEAD><BODY>}
read-cgi: func [/local data buffer][
    switch system/options/cgi/request-method [
        "POST" [
            data: make string! 1020
            buffer: make string! 16380
            while [positive? read-io system/ports/input buffer 16380][
                append data buffer
                clear buffer
            ]
        ]
        "GET" [data: system/options/cgi/query-string]
    ]
    data
]
submitted: decode-cgi submitted-bin: read-cgi
if ((submitted/2 = none) or (submitted/4 = none)) [
    print {
        <STRONG>W A R N I N G  -  Private Server:</STRONG><BR><BR>
        <FORM METHOD="post" ACTION="./kindle_email.cgi">
            Username: <input type=text size="50" name="name"><BR><BR>
            Password: <input type=text size="50" name="pass"><BR><BR>
            <INPUT TYPE="SUBMIT" NAME="Submit" VALUE="submit">
        </FORM>
        </BODY></HTML>
    } 
    quit
]
accounts: [
    ["pop.server1" "smtp.server1" "username1" "password1" you@site1.com]
    ["pop.server2" "smtp.server2" "username2" "password2" you@site2.com]
    ["pop.server3" "smtp.server3" "username3" "password3" you@site3.com]
]
myusername: "username"  mypassword: "password"
username: submitted/2   password: submitted/4 
either ((username = myusername) and (password = mypassword)) [][
    print "Incorrect Username/Password." 
    print {</BODY></HTML>} quit
]
if submitted/6 = "read" [
    account: pick accounts (to-integer submitted/8)
    mail-content: read [
        scheme: 'POP
        host: account/1
        port-id: 110
        user: account/3
        pass: account/4
    ]
    mail-count: length? mail-content
    for i 1 mail-count 1 [
        single-message: import-email (pick mail-content i)
        print rejoin [
            i {) &nbsp; <a href="./kindle_email.cgi?} 
            {u=} myusername {&p=} mypassword 
            {&subroutine=displaymessage&themessage=} 
            ; copy/part for URI length, at 3 is a serialization trick:
            at (mold compress (copy/part single-message/content 5000)) 3
            {">} single-message/subject
            {</a> &nbsp; <a href="./kindle_email.cgi?} 
            {u=} myusername {&p=} mypassword 
            {&subroutine=delete&theaccount=} submitted/8
            {&thesubject=} single-message/subject 
            {&thedate=} single-message/date
            {&thefrom=} single-message/from {">delete</a>
            <br> &nbsp; &nbsp; &nbsp; &nbsp; } single-message/from {<br>}
        ]
    ]
    quit
]
if submitted/6 = "displaymessage" [
    compressed-message: copy join "#{" submitted/8
    print "<pre>"  print decompress load compressed-message  print "<pre>"
    quit
]
if ((submitted/6 = "send") or (submitted/6 = "delete")) [
    my-account: pick accounts (to-integer submitted/8)
    system/schemes/pop/host:  my-account/1
    system/schemes/default/host: my-account/2
    system/schemes/default/user: my-account/3 
    system/schemes/default/pass: my-account/4 
    system/user/email: my-account/5
] 
if submitted/6 = "send" [
    print "Sending..."
    header: make system/standard/email [
        To: to-email submitted/10
        From: to-email my-account/5
        Subject: submitted/12
    ]
    send/header (to-email submitted/10) (trim submitted/14) header
    print "<strong>Sent</strong>"
]
if submitted/6 = "delete" [
    mail: open to-url join "pop://" system/user/email
    while [not tail? mail] [
        pretty: import-email (copy first mail)
        either all [
            pretty/subject = submitted/10
            form pretty/date = submitted/12
            form pretty/from = submitted/14
        ][
            remove mail  print "<strong>Deleted</strong>"  wait 1
        ][
            mail: next mail
        ]
    ]
]
print {<hr><h2>Read:</h2>}
for i 1 (length? accounts) 1 [
    print rejoin [
        i {) &nbsp; <a href="./kindle_email.cgi?}
        {u=} myusername {&p=} mypassword {&subroutine=read&accountname=}
        i {">} (first pick accounts i) {</a><br>}
    ]
]
print rejoin [
    {<BR><HR>
    <h2>Send:</h2>
    <FORM METHOD="post" ACTION="./kindle_email.cgi">
        <INPUT TYPE=hidden NAME="username" VALUE="} myusername {">
        <INPUT TYPE=hidden NAME="password" VALUE="} mypassword {">
        <INPUT TYPE=hidden NAME="subroutine" VALUE="send">
        From Account #: <select NAME="account">}
]
for i 1 (length? accounts) 1 [prin rejoin [{<option>} i]]
print {
        </option> </select><br><br>
        To: <BR><input type=text size="35" name="to"><BR><BR>
        Subject: <BR><input type=text size="35" name="subject"><BR><BR>
        <TEXTAREA COLS="50" ROWS="18" NAME="contents"></TEXTAREA><BR><BR>
        <INPUT TYPE="SUBMIT" NAME="Submit" VALUE="submit">
    </FORM>
    </BODY></HTML>
}
quit


#! ./rebol -cs
REBOL [Title: "CGI HTTP File Uploader"]
print {content-type: text/html^/}
print {<HTML><HEAD><TITLE>File Upload</TITLE></HEAD>}
print {<BODY><br><br><center><table width=95% border=1>}
print {<tr><td width=100%><br><center>}
read-cgi: func [/local data buffer][
    switch system/options/cgi/request-method [
        "POST" [
            data: make string! 1020
            buffer: make string! 16380
            while [positive? read-io system/ports/input buffer 16380][
                append data buffer
                clear buffer
            ]
        ]
        "GET" [data: system/options/cgi/query-string]
    ]
    data
]
submitted: read-cgi
if submitted/2 = none [
    print {
        <FORM ACTION="./upload.cgi" 
        METHOD="post" ENCTYPE="multipart/form-data">
            <strong>Upload File:</strong><br><br> 
            <INPUT TYPE="file" NAME="photo"> <br><br>
            <INPUT TYPE="submit" NAME="Submit" VALUE="Upload">  
        </FORM>
        <br></center></td></tr></table></BODY></HTML>
    }
    quit
]
decode-multipart-form-data: func [
    p-content-type
    p-post-data
    /local list ct bd delim-beg delim-end non-cr non-lf non-crlf mime-part
] [
    list: copy []
    if not found? find p-content-type "multipart/form-data" [return list]
    ct: copy p-content-type
    bd: join "--" copy find/tail ct "boundary="
    delim-beg: join bd crlf
    delim-end: join crlf bd
    non-cr:     complement charset reduce [ cr ]
    non-lf:     complement charset reduce [ newline ]
    non-crlf:   [ non-cr | cr non-lf ]
    mime-part:  [
        ( ct-dispo: content: none ct-type: "text/plain" )
        delim-beg ; mime-part start delimiter
        "content-disposition: " copy ct-dispo any non-crlf crlf
        opt [ "content-type: " copy ct-type any non-crlf crlf ]
        crlf ; content delimiter
        copy content
        to delim-end crlf ; mime-part end delimiter
        ( handle-mime-part ct-dispo ct-type content )
    ]
    handle-mime-part: func [
        p-ct-dispo
        p-ct-type
        p-content
        /local tmp name value val-p
    ] [
        p-ct-dispo: parse p-ct-dispo {;="}
        name: to-set-word (select p-ct-dispo "name")
        either (none? tmp: select p-ct-dispo "filename")
               and (found? find p-ct-type "text/plain") [
            value: content
        ] [
            value: make object! [
                filename: copy tmp
                type: copy p-ct-type
                content: either none? p-content [none][copy p-content]
            ]
        ]
        either val-p: find list name
            [change/only next val-p compose [(first next val-p) (value)]]
            [append list compose [(to-set-word name) (value)]]
    ]
    use [ct-dispo ct-type content] [
        parse/all p-post-data [some mime-part "--" crlf]
    ]
    list
]
cgi-object: construct decode-multipart-form-data 
    system/options/cgi/content-type copy submitted
the-file: last split-path to-file copy cgi-object/photo/filename
write/binary the-file cgi-object/photo/content
print {
    <strong>UPLOAD COMPLETE</strong><br><br>
    <strong>Files currently in this folder:</strong><br><br>
}
folder: sort read %.
foreach file folder [
    print [rejoin [{<a href="./} file {">} file {</a><br>}]]
]
print {<br></td></tr></table></BODY></HTML>}


#! ./rebol276 -cs
REBOL [title: "CGI WAP File Viewer"]
submitted: decode-cgi system/options/cgi/query-string
prin {Content-type: text/vnd.wap.wml^/^/}
prin {<?xml version="1.0" encoding="iso-8859-1"?>^/}
prin {<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">^/}
if submitted/2 = none [   
    print {<wml><card id="1" title="Select Teacher"><p>}
    ; print {Name: <input name="name" size="12"/>}
    folders: copy []
    foreach folder read %./Teachers/ [
        if find to-string folder {/} [append folders to-string folder]
    ]
    print {Teacher: <select name="teacher">}
    foreach folder folders [
        folder: replace/all folder {/} {}
        print rejoin [
            {<option value="} folder {">} folder {</option>}
        ]
    ]
    print {</select>
    <anchor>
       <go method="get" href="wap.cgi">
           <postfield name="teacher" value="$(teacher)"/>
       </go>
       Submit
    </anchor>}
    print {</p></card></wml>}
    quit
]
count: 0
parse read join http://site.com/folder/ submitted/2 [
    thru submitted/2 copy p to "past students"
]
print {<wml>}
forskip p 130 [
    count: count + 1
    print rejoin [
        {<card id="} count {" title="} submitted/2 "-" count {"><p>}
    ]
    print rejoin [
        {<anchor>Next<go href="#} (count + 1) {"/></anchor>}
    ]
    print rejoin [{<anchor>Back<prev/></anchor>}]
    print copy/part p 130
    print {</p></card>}
]
print {</wml>}
quit


#!./rebol276 -cs
REBOL [title: "CGI WAP File Insert"]
submitted: decode-cgi system/options/cgi/query-string
prin {Content-type: text/vnd.wap.wml^/^/}
prin {<?xml version="1.0" encoding="iso-8859-1"?>^/}
prin {<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">^/}
if submitted/2 = none [   
    print {<wml><card id="1" title="Select Teacher"><p>}
    print {Insert Text: <input name="thetext" size="12"/>}
    folders: copy []
    foreach folder read %./Teachers/ [
        if find to-string folder {/} [
            append folders to-string folder
        ]
    ]
    print {Teacher: <select name="teacher">}
    foreach folder folders [
        folder: replace/all folder {/} {}
        print rejoin [
            {<option value="} folder {">} folder {</option>}
        ]
    ]
    print {</select>
    <anchor>
       <go method="get" href="wapinsert.cgi">
           <postfield name="teacher" value="$(teacher)"/>
           <postfield name="thetext" value="$(thetext)"/>
       </go>
       Submit
    </anchor>}
    print {</p></card></wml>}
    quit
]
chosen-file: rejoin [%./Teachers/ submitted/2 "/schedule.txt"]
adjusted-file: read/lines chosen-file
insert next next next next adjusted-file submitted/4
write/lines chosen-file adjusted-file
count: 0
parse read join http://site.com/folders/ submitted/2 [
    thru submitted/2 copy p to "past students"
]
print {<wml>}
forskip p 130 [
    count: count + 1
    print rejoin [
        {<card id="} count {" title="} submitted/2 "-" count {"><p>}
    ]
    print rejoin [
        {<anchor>Next<go href="#} (count + 1) {"/></anchor>}
    ]
    print rejoin [{<anchor>Back<prev/></anchor>}]
    print copy/part p 130
    print {</p></card>}
]
print {</wml>}
quit


#!./rebol276 -cs
REBOL [title: "CGI WAP Mail Reader"]
submitted: decode-cgi system/options/cgi/query-string
prin {Content-type: text/vnd.wap.wml^/^/}
prin {<?xml version="1.0" encoding="iso-8859-1"?>^/}
prin {<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">^/}
accounts: [
    ["pop.server" "smtp.server" "username" "password" you@site.com]
    ["pop.server2" "smtp.server2" "username" "password" you@site2.com]
    ["pop.server3" "smtp.server3" "username" "password" you@site3.com]
]
if ((submitted/2 = none) or (submitted/2 = none)) [   
    print {<wml><card id="1" title="Select Account"><p>}
    print {Account: <select name="account">}
    forall accounts [
        print rejoin [
            {<option value="} index? accounts {">}
            last first accounts {</option>}
        ]
    ]
    print {</select>
    <select name="readorsend">
        <option value="readselect">Read</option>
        <option value="sendinput">Send</option>
    </select>
    <anchor>
       <go method="get" href="wapmail.cgi">
           <postfield name="account" value="$(account)"/>
           <postfield name="readorsend" value="$(readorsend)"/>
       </go>
       Submit
    </anchor>}
    print {</p></card></wml>}
    quit
]
if submitted/4 = "readselect" [
    t: pick accounts (to-integer submitted/2)
    system/schemes/pop/host:  t/1
    system/schemes/default/host: t/2
    system/schemes/default/user: t/3 
    system/schemes/default/pass: t/4 
    system/user/email: t/5
    prin {<wml><card id="1" title="Choose Message"><p>}
    prin rejoin [{<setvar name="account" value="} submitted/2 {"/>}]
    prin {<select name="chosenmessage">}
    mail: read to-url join "pop://" system/user/email
    foreach message mail  [
        pretty: import-email message
        if (find pretty/subject "***SPAM***") = none [
            replace/all pretty/subject {"} {}
            replace/all pretty/subject {&} {}
            prin rejoin [
                {<option value="} 
                pretty/subject
                {">}
                pretty/subject
                {</option>}
            ]
        ]
    ]
    print {</select>
    <anchor>
       <go method="get" href="wapmail.cgi">
           <postfield name="subroutine" value="display"/>
           <postfield name="chosenmessage" value="$(chosenmessage)"/>
           <postfield name="account" value="$(account)"/>
       </go>
       Submit
    </anchor>
    </p></card></wml>}
    quit
]
if submitted/2 = "display" [
    t: pick accounts (to-integer submitted/6)
    system/schemes/pop/host:  t/1
    system/schemes/default/host: t/2
    system/schemes/default/user: t/3 
    system/schemes/default/pass: t/4 
    system/user/email: t/5
    prin {<wml><card id="1" title="Display Message"><p>}
    mail: read to-url join "pop://" system/user/email
    foreach message mail  [
        pretty: import-email message
        if pretty/subject = submitted/4 [
            replace/all pretty/content {"} {}
            replace/all pretty/content {&} {}
            replace/all pretty/content {3d} {}
            strip: copy ""
            foreach item (load/markup pretty/content) [
                if ((type? item) = string!) [strip: join strip item]
            ]
            prin strip
        ]
    ]
    print {</p></card></wml>}
    quit
]


#! /home/path/public_html/rebol/rebol -cs
REBOL [title: "CGI Remove Unwanted Emails"]
print "content-type: text/html^/"
print [<HTML><HEAD><TITLE>"Remove Emails"</TITLE></HEAD><BODY>]
spam: [
    {Failure} {Undeliverable} {failed} {Returned Mail} {not be delivered}
    {mail status notification} {Mail Delivery Subsystem} {(Delay)}
]
print "logging in..."
mail: open pop://user:pass@site.com
print "logged in"
while [not tail? mail] [
    either any [
        (find first mail spam/1) (find first mail spam/2)
        (find first mail spam/3) (find first mail spam/4)
        (find first mail spam/5) (find first mail spam/6)
        (find first mail spam/7) (find first mail spam/8)
    ][
        remove mail
        print "removed"
    ][
        mail: next mail        
    ] 
    print length? mail 
]
close mail
print [</BODY></HTML>]
quit


#!./rebol -cs
REBOL [title: "Basic HTML Demonstration"]
print {content-type: text/html^/}
print {
    <h1>This is some header text</h1>
    <h3>This header text is smaller</h3>
    In HTML, all spaces, tabs, newlines and other white spaces
    are compressed (i.e., this text is all printed on the same
    line, and wrapped to the length of the screen, and these
    spaces             are all compressed to one space.  If
    you want to explicitly display a certain number of spaces,
    use these characters:  &nbsp; &nbsp;  For newlines (carriage
    returns), use the "br" tag: <br><br>
    To adjust text size and color, use the "font" tag: <br><br>
    <font size=1 color=blue>Little blue text</font><br>
    <font size=6 color=red>Big red text</font><br><br>
    To display a link to a web site, use the "a" tag: <br><br>
    <a href="http://yahoo.com">yahoo.com</a><br><br>
    To display images, use the "img" tag: <br><br>
    <img src="http://adopt-cats.com/header.jpg"><br><br>
    To make an image link to a URL, use "img" and "a": <br><br>
    <a href="http://adopt-cats.com" target=_blank>
        click the image:<br>
        <img src="http://adopt-cats.com/header.jpg">
    </a><br><br>
    <strong>This text is bolded.</strong><br><br>
    <pre>
        The "pre" tag displays preformatted text.
        Spaces, tabs, newlines, etc. are kept intact.
    </pre>
    You can add a horizontal separator line with the "hr" tag:
    <br><br><hr width=80%><br>
    Center anything on a page with the "center" tag: <br><br>
    <center>Centered Text</center><br>
    Tables are used to display rows and columns of data.  They
    can also be used to align portions of an HTML page in certain
    areas of the screen (i.e., to layout menu bar areas, headers,
    main content areas, and footers): <br><br>
    <center>
        <table border=0 cellpadding=10 width=80%>
            <tr>
                <td width=33%>"tr" tags</td>
                <td width=33%>are</td>
                <td width=33%>rows</td>
            </tr>
            <tr>
                <td width=33%>"td" tags</td>
                <td width=33%>are</td>
                <td width=33%>columns</td>
            </tr>
            <tr>
                <td valign=top colspan=2 bgcolor=#CCCCCC>
                    You can set "td"s to span as many columns as
                    needed, using the "colspan" setting, and you
                    can use the "valign" property to set where
                    in the cell text is placed.  "bgcolor" sets
                    the cell's background color.
                </td>
                <td width=20 bgcolor=#000000>
                    <font color=white size=2>
                        You can set size properties of all different
                        parts of the table, using either percentage
                        or pixel values.
                    </font>
                </td>
            </tr>
        </table>
    </center>
    Try resizing the page to see how centering, text wrapping and
    table layouts work.
}


#!./rebol -cs
REBOL [title: "Generic HTML Page With Tables"]
print {content-type: text/html^/}
print {
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
      <TITLE>Generic HTML Page With Tables</TITLE>    
      <META 
            http-equiv=Content-Type content="text/html; 
            charset=windows-1252"
      >
    </HEAD>    
    <BODY bgColor=#CCCCCC>
        <TABLE align=center background="" border=0 
            cellPadding=20 cellSpacing=2 height="95%" width="85%"
        >
            <TR>
                <TD background="" bgColor=white vAlign=top>
                    Your page content goes here.
                </TD>
            </TR>
        </TABLE>
        <TABLE align=center background="" border=0 cellPadding=2
            cellSpacing=2 width="85%" height="5%"
        >
            <TR>
                <TD background="" cellPadding=2 bgColor=#000000 height=5>
                    <P align=center>
                        <FONT color=white size=1>
                            Copyright  2009 Yoursite.com.
                            All rights reserved.
                        </FONT>
                    </P>
                </TD>
            </TR>
        </TABLE>
    </BODY>
    </HTML>
}


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
    <TITLE>Table Based Page Layout,  No Menu</TITLE>
    <META http-equiv=Content-Type content="text/html;
         charset=windows-1252"
    >
    <META 
        HTTP-EQUIV="Page-Enter" 
        CONTENT="RevealTrans(Duration=2,Transition=14)"
    >
    <STYLE TYPE="text/css">
        a:hover {
            color: blue;
            text-decoration: underline;
            background: #F9EDED
        }
    </STYLE>
</HEAD>
<BODY bgColor=#000000>
<TABLE align=center background="" border=0 cellPadding=2 cellSpacing=2
    height="100%" width="95%"
>
    <TR>
        <TD background="" bgColor=lightgrey vAlign=top>
            <TABLE background="" border=0 cellPadding=2 cellSpacing=2
                height="100%" width="100%"
            >
                <TR>
                    <TD background="" bgColor=black height=10>
                        <P align=center>
                            <a href="./index.html">
                                <IMG align=baseline alt="HEADER IMAGE"
                                    border=0 hspace=0 src="header.jpg"
                                >
                            </a>
                        </P>
                    </TD>
                </TR>
                <TR>
                <TD background="" vAlign=top>
                    <TABLE bgColor=#ffffff border=0 cellPadding=2
                        cellSpacing=2 height="100%" width="100%"
                    >
                        <TR> 
                            <TD bgColor=lightgrey height=20>
                                <center></center>
                            </TD>
                            <TD bgColor=lightgrey height=10 width="90%">
                                <center>
                                    <a href="./Home.html">
                                        Home
                                    </a> : Contact
                                </center>
                            </TD>
                            <TD bgColor=lightgrey height=20>
                                <center></center>
                            </td>
                        </TR>
                        <TR>
                            <TD background="" colSpan=3 height="100%">
                                <TABLE border=0 cellPadding=15 
                                    cellSpacing=2 height="100%"
                                    width="100%"
                                >
                                    <TR>
                                        <TD background="" vAlign=top>
                                            YOUR PAGE CONTENT GOES HERE
                                        </TD>
                                    </TR>
                                </TABLE>
                            </TD>
                        </TR>
                    </TABLE>
                </TD>
            </TR>
            <TR>
                <TD background="" bgColor=#000000 height=5>
                    <P align=center>
                        <FONT color=white size=1>
                            Copyright  2010 This Web Site.
                            All rights reserved.
                        </FONT>
                    </P>
                </TD>
            </TR>
        </TABLE>
    </TD>
</TR>
</TABLE>
</BODY>
</HTML>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
    <TITLE>Table Based Layout Template, With Menu</TITLE>
    <META http-equiv=Content-Type content="text/html;
        charset=windows-1252"
    >
    <META HTTP-EQUIV="Page-Enter" 
        CONTENT="RevealTrans(Duration=2,Transition=12)"
    >
    <STYLE TYPE="text/css">
        a:hover {
            color: blue; 
            text-decoration: underline; 
            background: #F9EDED
        }
    </STYLE>
</HEAD>
<BODY bgColor=#000000>
    <TABLE align=center background="" border=0 cellPadding=2
        cellSpacing=2 height="100%" width="95%"
    >
        <TR>
            <TD background="" bgColor=lightgrey vAlign=top>
                <TABLE background="" border=0 cellPadding=2
                    cellSpacing=2 height="100%" width="100%"
                >
                    <TR>
                        <TD background="" bgColor=lightgrey width="23%">
                            <TABLE bgColor=white border=1 cellPadding=10
                                cellSpacing=2 height="100%" width="100%">
                                <TR>
                                    <TD>
                                        <P align=center>
                                            <FONT color=Black size=3>
                                               <STRONG>
                                                  <a href="index.html">
                                                     Home
                                                  </a>
                                               </STRONG>
                                            </FONT>
                                        </P>
                                    </TD>
                                </TR>
                            </TABLE>
                        </TD>
                        <TD background="" bgColor=black height=10>
                            <P align=center>
                                <a href="./index.html"> 
                                    <IMG 
                                        alt="HEADER IMAGE" 
                                        src="./header.jpg"
                                    >
                                </a>
                            </P>
                        </TD>
                    </TR>
                    <TR>
                        <TD vAlign=top>
                            <TABLE background="" bgColor=black border=0
                                cellPadding=2 cellSpacing=2 height="100%"
                                width="100%"
                            >
                                <TR>
                                    <TD background="" height=20>
                                        <P align=center>
                                            <FONT color=white size=2>
                                                <STRONG>Menu</STRONG>
                                            </FONT>
                                        </P>
                                    </TD>
                                </TR>
                                <TR>
                                    <TD bgColor=lightgrey vAlign=top>
                                        <P align=center>
                                            <BR>
                                            <TABLE width=95%>
    <CENTER>
        <TR>
            <TD style="border: solid" 
                onmouseOver="this.bgColor='#FFFFFF'";
                onmouseOut="this.bgColor='#D3D3D3'";
            > 
                <CENTER>
                    <FONT face="Arial, Verdana, MS Sans Serif" size=1>
                        <A HREF="./page1.html">
                            Page1
                        </A>
                    </FONT>                          
                </CENTER>
            </TD>
        </TR>
        <TR>
            <TD style="border: solid"
                onmouseOver="this.bgColor='#FFFFFF'";
                onmouseOut="this.bgColor='#D3D3D3'";
            > 
                <CENTER>
                    <FONT face="Arial, Verdana, MS Sans Serif" size=1>
                        <A HREF="./page2.html">
                            Page2
                        </A>
                    </FONT>
                </CENTER>
            </TD>
        </TR>
    </CENTER>
                                            </TABLE>
                                        </P>
                                    </TD>
                                </TR>
                            </TABLE> <br>
                        </TD>
                        <TD background="" vAlign=top>
                            <TABLE bgColor=#ffffff border=0 cellPadding=2
                                 cellSpacing=2 height="100%" width="100%"
                            >
                                <TR>
                                    <td bgColor=lightgrey height=20>
                                        <center></center>
                                    </td>
                                    <td bgColor=lightgrey height=20
                                        width="90%"
                                    >
                                        <FONT size=3>
                                            <center>Home</center>
                                        </font>
                                    </td>
                                    <td bgColor=lightgrey height=20>
                                        <center></center>
                                    </td>
                                </TR>
                                <TR>
                                    <TD colSpan=3 height="100%">
                                        <TABLE border=0 cellPadding=15 
                                            cellSpacing=2 height="100%"
                                            width="100%"
                                        >
                                            <TR>
                                                <TD vAlign=top>
                                                    YOUR CONTENT GOES HERE
                                                </TD>
                                            </TR>
                                        </TABLE>
                                    </TD>
                                </TR>
                            </TABLE>
                        </TD>
                    </TR>
                    <TR>
                        <TD background="" bgColor=#d3d3d3 height=5>
                            <P align=center></P>
                        </TD>
                        <TD background="" bgColor=#000000 height=5>
                            <P align=center>
                                <FONT color=white size=1>
                                    Copyright  2010 This Web Site.
                                    All rights reserved.
                                </FONT>
                            </P>
                        </TD>
                    </TR>
                </TABLE>
            </TD>
        </TR>
    </TABLE>
</BODY>
</HTML>


REBOL [title: "chmod777to555"]
start-dir: what-dir
all-files: to-file join start-dir %find777all.txt
write all-files ""
recurse: func [current-folder] [
    out-data: copy ""
    write/append all-files rejoin["CURRENT_DIRECTORY:  " what-dir newline]
    call/output {ls -al} out-data
    write/append all-files join out-data newline
    foreach item (read current-folder) [ 
        if dir? item [
            change-dir item 
            recurse %.\
            change-dir %..\
        ] 
    ]
]
recurse %.\
file-list: to-file join start-dir %found777.txt
write file-list ""
current-directory: ""
foreach line (read/lines all-files) [
    if find line "CURRENT_DIRECTORY:  " [
        current-directory: line
    ]
    if find line "rwxrwxrwx" [
        write/append file-list rejoin [
            (find/match current-directory "CURRENT_DIRECTORY:  ")
            (last parse/all line " ")
        ]
        write/append file-list newline
    ]
]
foreach file (read/lines file-list) [
    call rejoin [{chmod 755 } (to-local-file file)]
]


REBOL [title: "FTP Tool"]
Instructions: {

    Enter your username, password, and FTP URL in the text field, and
    hit [ENTER].

    BE SURE TO END YOUR FTP URL PATH WITH "/".  

    URLs can be saved and loaded in multiple config files for future use.

    CONFIG FILES ARE STORED AS PLAIN TEXT, SO KEEP THEM SECURE.

    Click folders to browse through any dir on your web server.  Click
    text files to open, edit and save changes back to the server.
    Click images to view.  Also upload/download any type of file,
    create new files and folders, change file names, copy and delete
    files, change permissions, etc.

}
connect: does [
    either (to-string last p/text) = "/" [
    if error? try [
            f/data: sort append read to-url p/text "../" show f
        ][
            alert "Not a valid FTP address, or the connection failed."
        ]
    ][
        editor to-url p/text
    ]
]
view center-face layout [
    p: field 600 "ftp://user:pass@website.com/" [connect]
    across
    btn "Connect" [connect]
    btn "Load URL" [
        config: to-file request-file/file %/c/ftp.cfg
        either exists? config [
            if (config <> %none) [
                my-urls: copy []
                foreach item read/lines config [append my-urls item]
                if error? try [
                    p/text: copy request-list "Select a URL:" my-urls
                ] [break]
            ]
        ][
            alert "First, save some URLs to that file..."
        ]
        show p focus p
    ]
    btn "Save URL" [
        url: request-text/title/default "URL to save:" p/text
        if url = none [break]
        config-file: to-file request-file/file/save %/c/ftp.cfg
        if (url <> none) and (config-file <> %none) [
            if not exists? config-file [
                write/lines config-file ftp://user:pass@website.com/
            ]
            write/append/lines config-file to-url url
            alert "Saved"
        ]
    ]
    below
    f: text-list 600x350 [
        either (to-string value) = "../" [
            for i ((length? p/text) - 1) 1 -1 [
                if (to-string (pick p/text i)) = "/" [
                    clear at p/text (i + 1) show p
                    f/data: sort append read to-url p/text "../" show f
                    break
                ]
            ]
        ][
            either (to-string last value) = "/" [
                p/text: rejoin [p/text value] show p
                f/data: sort append read to-url p/text "../" show f
            ][
                if ((request "Edit/view this file?") = true) [
                    either find [%.jpg %.png %.gif %.bmp] suffix? value [
                        view/new layout [
                            image load to-url join p/text value
                        ]
                    ][
                        editor to-url rejoin [p/text value]
                    ]
                ]
            ]
        ]
    ]
    across
    btn "Get Info" [
        p-file: to-url rejoin [p/text f/picked]
        alert rejoin ["Size: " size? p-file " Date: " modified? p-file]
    ]
    btn "Delete" [
        p-file: to-url request-text/title/default "File to delete:"
            join p/text f/picked
        if ((confirm: request "Are you sure?") = true) [delete p-file]
        f/data: sort append read to-url p/text "../" show f
        if confirm = true [alert "File deleted"]
    ]
    btn "Rename" [
        new-name: to-file request-text/title/default "New File Name:"
            to-string f/picked
        if ((confirm: request "Are you sure?") = true) [
            rename (to-url join p/text f/picked) new-name
        ]
        f/data: sort append read to-url p/text "../" show f
        if confirm = true [alert "File renamed"]
    ]
    btn "Copy" [
        new-name: to-url request-text/title/default "New Path:"
            (join p/text f/picked)
        if ((confirm: request "Are you sure?") = true) [
            write/binary new-name read/binary to-url join p/text f/picked
        ]
        f/data: sort append read to-url p/text "../" show f
        if confirm = true [alert "File copied"]
    ]
    btn "New File" [
        p-file: to-url request-text/title/default "New File Name:"
            join p/text "ENTER-A-FILENAME.EXT"
        if ((confirm: request "Are you sure?") = true) [
            write p-file ""
            ; editor p-file
        ]
        f/data: sort append read to-url p/text "../" show f
        if confirm = true [alert "Empty file created - click to edit."]
    ]
    btn "New Dir" [
        make-dir x: to-url request-text/title/default "New folder:" p/text
        alert "Folder created"
        p/text: x show p
        f/data: sort append read to-url p/text "../" show f
    ]
    btn "Download" [
        file: request-text/title/default "File:" (join p/text f/picked)
        l-file: next to-string (find/last (to-string file) "/")
        save-as: request-text/title/default "Save as..." to-string l-file
        write/binary (to-file save-as) (read/binary to-url file)
        alert "Download Complete"
    ]
    btn "Upload" [
        file: to-file request-file
        r-file: request-text/title/default "Save as..." 
            join p/text (to-string to-relative-file file)
        write/binary (to-url r-file) (read/binary file)
        f/data: sort append read to-url p/text "../" show f
        alert "Upload Complete"
    ]
    btn "Chmod" [
        p-file: to-url request-text/default rejoin [p/text f/picked]
        chmod: to-block request-text/title/default "Permissions:"
            "read write execute"
        write/binary/allow p-file (read/binary p-file) chmod
        alert "Permissions changed"
    ]
    btn-help [inform layout[backcolor white text bold as-is instructions]]
    do [focus p]
]


REBOL [title: "Jeopardy"] 
config: {

    REBOL []

    ;________________________________________________________________

    sizer: 4

    Category-1: "Category 1" 
    Category-2: "Category 2" 
    Category-3: "Category 3" 
    Category-4: "Category 4" 
    Category-5: "Category 5"

    answers: [
        "$100 Answer, Category 1" 
        "$100 Answer, Category 2" 
        "$100 Answer, Category 3" 
        "$100 Answer, Category 4" 
        "$100 Answer, Category 5" 
        "$200 Answer, Category 1" 
        "$200 Answer, Category 2" 
        "$200 Answer, Category 3" 
        "$200 Answer, Category 4" 
        "$200 Answer, Category 5" 
        "$300 Answer, Category 1" 
        "$300 Answer, Category 2" 
        "$300 Answer, Category 3" 
        "$300 Answer, Category 4" 
        "$300 Answer, Category 5" 
        "$400 Answer, Category 1" 
        "$400 Answer, Category 2" 
        "$400 Answer, Category 3" 
        "$400 Answer, Category 4" 
        "$400 Answer, Category 5" 
        "$500 Answer, Category 1" 
        "$500 Answer, Category 2" 
        "$500 Answer, Category 3" 
        "$500 Answer, Category 4" 
        "$500 Answer, Category 5" 
    ]
    questions: [
        "$100 Question, Category 1" 
        "$100 Question, Category 2" 
        "$100 Question, Category 3" 
        "$100 Question, Category 4" 
        "$100 Question, Category 5" 
        "$200 Question, Category 1" 
        "$200 Question, Category 2" 
        "$200 Question, Category 3" 
        "$200 Question, Category 4" 
        "$200 Question, Category 5" 
        "$300 Question, Category 1" 
        "$300 Question, Category 2" 
        "$300 Question, Category 3" 
        "$300 Question, Category 4" 
        "$300 Question, Category 5" 
        "$400 Question, Category 1" 
        "$400 Question, Category 2" 
        "$400 Question, Category 3" 
        "$400 Question, Category 4" 
        "$400 Question, Category 5" 
        "$500 Question, Category 1" 
        "$500 Question, Category 2" 
        "$500 Question, Category 3" 
        "$500 Question, Category 4" 
        "$500 Question, Category 5" 
    ]

    ;________________________________________________________________

}
do config
header: load to-binary decompress 64#{
eJyVj3s804v/xz/bzGyFucRGohgm1ziuuU7CNGxWuTaxbBpyLVJUpItLcyfXNIZI
jkuJboqFJsNodG9uuXRyya18ncfj93t8//4+3/+9X6/H6/1+bY1ufQKQzg5ODgAI
BAIo2wNsjQE4QFQEKgoVERWFisJgomIIJAIBhyNkJSR3IuVlUSh5WTk5BSWMsoKi
6m45ORVtFVV1DawWFq2so6+jqY/RxGr+GwKCwWAIMYQMAiGjqSCnoPk/s/UMkBID
dAEmBLQPAEuBIFKgrZeAIgBAQP8C/D/bT4qIbS+3xUNIAASGgiFQsNhOKPRfEQSG
ANtlpKT3wmQMxGT32br7X5JHHT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/tc0y4lDdT3jHiSLyb1w0K38rcmQRJwaRHrX9ZPT6Y/
kzCWO9z6mFnaBuOHBH/rVhqrMcQXkE0JBz7nD3ziZVdpWE35yFO9Tq4Fz8T5lWjk
U1qQiR0I1OBDbpzMpLjyzuVxCgmbtOHcvflM3HK5lPbPNYf1oj2/U72/zl+UOsEj
SsbQVq/tcZMeKOMHTdJIxKZ3KaxBN7veuhaPRHBWpofxGGz2ksnNHPPlfguPGhfj
r/NsDNaRd5VnDHf8s5byWOa6TG5atR7hkLEfVbytUc6X6PR6eHpj4CyLau5BBrL2
d1wP2QJsHD7ouDj3hiskzdk2zN5mlIep3NXEgk5zuwNas4+s5hwvI9ck90b4FtBD
iSSWDqbMQ2IS6FIsEbJ9RxI+Y4V7c3HQSmqh4l4Vmbb0GTMNnrRjD8cyUiouJjHT
kyuWUsMHnnAXTzE3nkbF6X/2ezD1aHCjwNdz691/ABEeZGXYCwAA
}
do-button: func [num] [
    alert pick answers num 
    alert pick questions num
    if find [1 2 3 4 5] num [val: $100]
    if find [6 7 8 9 10] num [val: $200]
    if find [11 12 13 14 15] num [val: $300]
    if find [16 17 18 19 20] num [val: $400]
    if find [21 22 23 24 25] num [val: $500]
    correct: request-list "Select:" ["Player 1 answered correctly" 
        "Player 1 answered incorrectly" "Player 2 answered correctly"
        "Player 2 answered incorrectly" "Player 3 answered correctly"
        "Player 3 answered incorrectly" "Player 4 answered correctly"
        "Player 4 answered incorrectly"
    ] 
    switch correct  [
        "Player 1 answered correctly" [
            player1/text: to-string ((to-money player1/text) + val)
            show player1
        ] 
        "Player 1 answered incorrectly" [
            player1/text: to-string ((to-money player1/text) - val)
            show player1
        ] 
        "Player 2 answered correctly" [
            player2/text: to-string ((to-money player2/text) + val)
            show player2
        ]
        "Player 2 answered incorrectly"[
            player2/text: to-string ((to-money player2/text) - val)
            show player2
        ]
        "Player 3 answered correctly" [
            player3/text: to-string ((to-money player3/text) + val)
            show player3
        ] 
        "Player 3 answered incorrectly" [
            player3/text: to-string ((to-money player3/text) - val)
            show player3
        ] 
        "Player 4 answered incorrectly"[
            player4/text: to-string ((to-money player4/text) - val)
            show player4
        ]
        "Player 4 answered correctly" [
            player4/text: to-string ((to-money player4/text) + val)
            show player4
        ]
    ]
]
view center-face layout gui: [
    tabs (sizer * 20)
    backdrop effect [gradient 1x1 tan brown]
    style button button effect [gradient blue blue/2] (
        to-pair rejoin [(20 * sizer) "x" (13 * sizer)]
    ) font [size: (sizer * 6)]
    style box box brown (to-pair rejoin [(20 * sizer) "x" (7 * sizer
        )]) font [size: (sizer * 3)]
    image header (to-pair rejoin [(132 * sizer) "x" (8 * sizer)]) [
        contin: request/confirm {
            This will end the current game.  Continue?}
        if contin = false [break]
        loadoredit:  request/confirm "Load previously edited config file?"
        if loadoredit = true [
            do to-file request-file/title/file {
                Choose config file to use:} "File" %default_config.txt
            unview
            view center-face layout gui
            break
        ]
        alert {Edit carefully, maintaining all quotation marks.  
            You can open a previously saved file if needed.
            When done, click SAVE-AS and then QUIT.  
            Be sure choose a filename/folder
            location that you'll be able to find later.
        }
        write %default_config.txt config
        unview
        editor %default_config.txt
        alert {Now choose a config file to use (most likely the file
            you just edited).}
        do to-file request-file/title/file {
            Choose config file to use:} "File" %default_config.txt
        view center-face layout gui
    ]
    space (to-pair rejoin [(8 * sizer) "x" (2 * sizer)])
    pad (sizer * 2)
    across
    box (to-pair rejoin [(132 * sizer) "x" (2 * sizer)]
        ) effect [gradient 1x0 brown black] 
    return
    box Category-1 
    box Category-2 
    box Category-3 
    box Category-4 
    box Category-5
    return
    box (to-pair rejoin [(132 * sizer) "x" (2 * sizer)]
        ) effect [gradient 1x0 brown black] 
    return
    button "$100" [face/feel: none face/text: "" do-button 1]
    button "$100" [face/feel: none face/text: "" do-button 2]
    button "$100" [face/feel: none face/text: "" do-button 3]
    button "$100" [face/feel: none face/text: "" do-button 4]
    button "$100" [face/feel: none face/text: "" do-button 5]
    return
    button "$200" [face/feel: none face/text: "" do-button 6]
    button "$200" [face/feel: none face/text: "" do-button 7]
    button "$200" [face/feel: none face/text: "" do-button 8]
    button "$200" [face/feel: none face/text: "" do-button 9]
    button "$200" [face/feel: none face/text: "" do-button 10]
    return
    button "$300" [face/feel: none face/text: "" do-button 11]
    button "$300" [face/feel: none face/text: "" do-button 12]
    button "$300" [face/feel: none face/text: "" do-button 13]
    button "$300" [face/feel: none face/text: "" do-button 14]
    button "$300" [face/feel: none face/text: "" do-button 15]
    return
    button "$400" [face/feel: none face/text: "" do-button 16]
    button "$400" [face/feel: none face/text: "" do-button 17]
    button "$400" [face/feel: none face/text: "" do-button 18]
    button "$400" [face/feel: none face/text: "" do-button 19]
    button "$400" [face/feel: none face/text: "" do-button 20]
    return
    button "$500" [face/feel: none face/text: "" do-button 21]
    button "$500" [face/feel: none face/text: "" do-button 22]
    button "$500" [face/feel: none face/text: "" do-button 23]
    button "$500" [face/feel: none face/text: "" do-button 24]
    button "$500" [face/feel: none face/text: "" do-button 25]
    return 
    box (to-pair rejoin [(132 * sizer) "x" (2 * sizer)]
        ) effect [gradient 1x0 brown black] 
    return tab
    box "Player 1:" effect [gradient 1x1 tan brown]
    player1: box white "$0" font [color: black size: (sizer * 4)] [
        face/text: request-text/title/default "Enter Score:" face/text
    ]
    box "Player 2:" effect [gradient 1x1 tan brown]
    player2: box white "$0" font [color: black size: (sizer * 4)] [
        face/text: request-text/title/default "Enter Score:" face/text
    ]
    return tab
    box "Player 3:" effect [gradient 1x1 tan brown]
    player3: box white "$0" font [color: black size: (sizer * 4)] [
        face/text: request-text/title/default "Enter Score:" face/text
    ]
    box "Player 4:" effect [gradient 1x1 tan brown]
    player4: box white "$0" font [color: black size: (sizer * 4)] [
        face/text: request-text/title/default "Enter Score:" face/text
    ]
]


REBOL [title: "Guitar Chords"]
help: {
    This program creates guitar chord diagram charts for songs.  It was
    written to help students in high school jazz band quickly play all of
    the common extended, altered, and complex chord types.  It can also
    be used to create chord charts for any other type of music (with
    simpler chords):  folk, rock, blues, pop, etc.

    To select chords for your song, click the root note (letter name:  A,
    Bb, C#, etc.), and then the sonority (major, minor, 7(#5b9), etc.) of
    each chord.  The list of chords you've selected will be shown in the 
    text area below.  When you've added all the chords needed to play your
    song, click the "Create Chart" button.  Your browser will open, with a
    complete graphic rendering of all chords in your song.  You can use
    your browser's page settings to print charts at different sizes.

    Two versions of each chord are presented:  1 with the root note on the
    6th string, and another with the root note on the 5th string.  Chord
    lists can be saved and reloaded with the "Save" and "Load" buttons.
    The rendered images and the HTML that displays them are all saved to
    the "./chords" folder (a subfolder of wherever this script is run).
    You can create a zip file of all the contents of that folder to play
    your song later, upload it to a web server to share with the world,
    etc.


    -- THEORY --

    Here are the formulas and fingering patterns used to create chords in
    this program:


    6th string notes:               5th string notes:

    0  1  3  5  7  8  10  12        0  2  3  5  7  8  10  12
    E  F  G  A  B  C  D   E         A  B  C  D  E  F  G   A


    The sharp symbol ("#") moves notes UP    one fret
    The flat  symbol ("b") moves notes DOWN  one fret


    Root 6 interval shapes:         Root 5 interval shapes:     
    ___________                     ___________
    | | | | 4 |                     | | | | | |
    | 3 6 9 | 7                     | | | | | |
    1 | | | 5 1                     | | | | 1 4
    | | 7 3 | |                     | | 3 6 | |
    | 5 1 4 6 9                     5 1 4 | 9 5
    | | | | | |                     | | | 7 | |
    | | 9 | 7 |                     | | 5 1 3 6


    To create any chord, slide either shape up the fretboard until the
    number "1" is on the correct root note (i.e., for a "G" chord, slide
    the root 6 shape up to the 3rd fret, or the root 5 shape up to the
    10th fret).  Then pick out the required intervals:


    CHORD TYPE:           INTERVALS:           SYMBOLS:

    Power Chord           1    5                5
    Major Triad           1    3    5           none  (just a root noot)
    Minor Triad           1   b3    5           m, min, mi, -
    Dominant 7            1    3   (5)  b7      7
    Major 7               1    3   (5)   7      maj7, M7, (triangle) 7
    Minor 7               1   b3   (5)  b7      m7, min7, mi7, -7
    Half Diminished 7     1   b3   b5   b7      m7b5, (circle with line) 7
    Diminished 7          1   b3   b5  bb7 (6)  dim7, (circle) 7
    Augmented 7           1    3   #5   b7      7aug, 7(#5), 7(+5)


    Add these intervals to the above 7th chords to create extended chords:

    9 (is same as 2)   11 (is same as 4)   13 (is same as 6)   

    Examples:              9          =    1   3  (5)  b7    9
                           min9       =    1  b3  (5)  b7    9
                           13         =    1   3   5   b7   13
                           9(+5)      =    1   3  #5   b7    9
                           maj9(#11)  =    1   3  (5)   7    9  #11


    Here are some more common chord types:

    "sus"       =  change 3 to 4
    "sus2"      =  change 3 to 2
    "add9"      =  1 3 5 9  (same as "add2", there's no 7 in "add" chords)
    "6,  maj6"  =  1 3 5 6
    "m6, min6"  =  1 b3 5 6
    "6/9"       =  1 3 5 6 9
    11          =  1 b7 9 11
    "/"         =  Bassist plays the note after the slash


    NOTE:  When playing complex chords (jazz chords) in a band setting,
    guitarists typically SHOULD NOT PLAY THE ROOT NOTE of the chord
    (the bassist or keyboardist will play it).  In diagrams created by 
    this program, unnecessary notes are indicated by light circles, and
    required notes are indicated by dark circles.
}
root6-shapes: [
    "." "major triad, no symbol (just a root note)" [1 3 5 11 55 111]
    "m" "minor triad, min, mi, m, -" [1 b3 5 11 55 111]
    "aug" "augmented triad, aug, #5, +5" [1 3 b6 11 111]
    "dim" "diminished triad, dim, b5, -5" [1 b3 b5 11]
    "5" "power chord, 5" [1 55]
    "sus4" "sus4, sus" [1 4 5 11 55 111]
    "sus2" "sus2, 2" [1 99 5 11]
    "6" "major 6, maj6, ma6, 6" [1 3 5 6 11]
    "m6" "minor 6, min6, mi6, m6" [1 b3 5 6 11]
    "69" "major 6/9, 6/9, add6/9" [1 111 3 13 9]
    "maj7" "major 7, maj7, ma7, M7, (triangle) 7" [1 3 5 7 11 55]
    "7" "dominant 7, 7" [1 3 5 b7 11 55]
    "m7" "minor 7, min7, mi7, m7, -7" [1 b3 5 b7 11 55]
    "m7(b5)" "half diminished, min7(b5), (circle w/ line), m7(-5), -7(b5)"
        [1 b3 b5 b7 11]
    "dim7" "diminished 7, dim7, (circle) 7" [1 b3 b5 6 11]
    "7sus4" "dominant 7 sus4 (7sus4)" [1 4 5 b7 55 11]
    "7sus2" "dominant 7 sus2 (7sus2)" [1 b7 99 5 11]
    "7(b5)" "dominant 7 flat 5, 7(b5), 7(-5)" [1 3 b5 b7 11]
    "7(+5)" "augmented 7, 7(#5), 7(+5)" [1 3 b6 b7 11]
    "7(b9)" "dominant 7 flat 9, 7(b9), 7(-9)" [1 3 5 b7 b9]
    "7(+9)" "dominant 7 sharp 9, 7(#9), 7(+9)" [1 111 3 b77 b33]
    "7(b5b9)" "dominant 7 b5 b9, 7(b5b9), 7(-5-9)" [1 3 b5 b7 b9]
    "7(b5+9)" "dominant 7 b5 #9, 7(b5#9), 7(-5+9)" [1 3 b5 b7 b33]
    "7(+5b9)" "augmented 7 flat 9, aug7(b9), 7(#5b9)" [1 3 b6 b7 b9]
    "7(+5+9)" "augmented 7 sharp 9, aug7(#9), 7(#5#9)" [1 3 b6 b7 b33]
    "add9" "add9, add2" [1 3 5 999 55 11]
    "madd9" "minor add9, min add9, m add9, m add2" [1 b3 5 999 55 11]
    "maj9" "major 9, maj9, ma9, M9, (triangle) 9" [1 3 5 7 9]
    "maj9(+11)" "major 9 sharp 11, maj9(#11), M9(+11)" [1 3 7 9 b5]
    "9" "dominant 9, 9" [1 3 5 b7 9 55]
    "9sus" "dominant 9 sus4, 9sus4, 9sus" [1 4 5 b7 9 55]
    "9(+11)" "dominant 9 sharp 11, 9(#11), 9(+11)" [1 3 b7 9 b5]
    "m9" "minor 9, min9, mi9, m9, -9" [1 b3 5 b7 9 55]
    "11" "dominant 11, 11" [1 b7 99 44 11]
    "maj13" "major 13, maj13, ma13, M13, (triangle) 13" [1 3 55 7 11 13]
    "13" "dominant 13, 13" [1 3 55 b7 11 13]
    "m13" "minor 13, min13, mi13, m13, -13" [1 b3 55 b7 11 13]
]
root6-map:  [
    1 20x70 11 120x70 111 60x110 3 80x90 33 40x50 b3 80x70 5 100x70
    55 40x110 b5 100x50 7 60x90 b7 60x70 9 120x110 99 80x50 6 60x50
    13 100x110 4 80x110 44 100x30 999 60x150 b77 100x130 b33 120x130
    b9 120x90 b6 100x90 b55 40x90
]
root5-shapes: [
    "." "major triad, no symbol (just a root note)" [1 3 5 11 55]
    "m" "minor triad, min, mi, m, -" [1 b3 5 11 55]
    "aug" "augmented triad, aug, #5, +5" [1 3 b6 11 b66]
    "dim" "diminished triad, dim, b5, -5" [1 b3 b5 11]
    "5" "power chord, 5" [1 55]
    "sus4" "sus4, sus" [1 4 5 11 55]
    "sus2" "sus2, 2" [1 9 5 11 55]
    "6" "major 6, maj6, ma6, 6" [1 3 55 13 11]
    "m6" "minor 6, min6, mi6, m6" [1 b3 55 13 11]
    "69" "major 6/9, 6/9, add6/9" [1 33 6 9 5]
    "maj7" "major 7, maj7, ma7, M7, (triangle) 7" [1 3 5 7 55]
    "7" "dominant 7, 7" [1 3 5 b7 55]
    "m7" "minor 7, min7, mi7, m7, -7" [1 b3 5 b7 55]
    "m7(b5)" "half diminished, min7(b5), (circle w/ line), m7(-5), -7(b5)"
        [1 b3 b5 b7 b55]
    "dim7" "diminished 7, dim7, (circle) 7" [1 b33 b5 6 111]
    "7sus4" "dominant 7 sus4, 7sus4" [1 4 5 b7 55]
    "7sus2" "dominant 7 sus2, 7sus2" [1 9 5 b7 55]
    "7(b5)" "dominant 7 flat 5, 7(b5), 7(-5)" [1 33 b5 b7 111]
    "7(+5)" "augmented 7, 7(#5), 7(+5)" [1 33 b6 b7 111]
    "7(b9)" "dominant 7 flat 9, 7(b9), 7(-9)" [1 33 5 b7 b9]
    "7(+9)" "dominant 7 sharp 9, 7(#9), 7(+9)" [1 33 b7 b3]
    "7(b5b9)" "dominant 7 b5 b9, 7(b5b9), 7(-5-9)" [1 33 b5 b7 b9]
    "7(b5+9)" "dominant 7 b5 #9, 7(b5#9), 7(-5+9)" [1 33 b5 b7 b3]
    "7(+5b9)" "augmented 7 flat 9, aug7(b9), 7(#5b9)" [1 33 b6 b7 b9]
    "7(+5+9)" "augmented 7 sharp 9, aug7(#9), 7(#5#9)" [1 33 b7 b3 b6]
    "add9" "major add9, add9, add2" [1 3 5 99 55]
    "madd9" "minor add9, min add9, m add9, m add2" [1 b3 5 99 55]
    "maj9" "major 7, maj9, ma9, M9, (triangle) 9" [1 33 5 7 9]
    "maj9(+11)" "major 9 sharp 11, maj9(#11), M9(+11)" [1 33 b5 7 9]
    "9" "dominant 9, 9" [1 33 5 b7 9]
    "9sus" "dominant 9 sus4, 9sus4, 9sus" [1 44 5 b7 9]
    "9(+11)" "dominant 9 sharp 11, 9(#11), 9(+11)" [1 33 b5 b7 9]
    "m9" "minor 9, min9, mi9, m9, -9" [1 b33 5 b7 9]
    "11" "dominant 11, 11" [1 b7 9 44 444]
    "maj13" "major 13, maj13, ma13, M13, (triangle) 13" [1 3 55 7 13]
    "13" "dominant 13, 13" [1 3 55 b7 13]
    "m13" "minor 13, min13, mi13, m13, -13" [1 b3 55 b7 13]
]
root5-map:  [
    1 40x70 11 80x110 111 100x30 3 100x110 33 60x50 b33 60x30 5 120x70
    55 60x110 b5 120x50 7 80x90 b7 80x70 9 100x70 6 80x50 13 120x110
    4 100x130 44 60x70 444 120x30 99 80x150 b3 100x90 b9 100x50 b6 120x90
    b66 60x130 b55 60x90
]
root6-notes:  [
    "e" {12} "f" {1} "f#" {2} "gb" {2} "g" {3} "g#" {4} "ab" {4}
    "a" {5} "a#" {6} "bb" {6} "b" {7} "c" {8} "c#" {9} "db" {9} "d" {10}
    "d#" {11} "eb" {11}
]
root5-notes: [
    "a" {12} "a#" {1} "bb" {1} "b" {2} "c" {3} "c#" {4} "db" {4}
    "d" {5} "d#" {6} "eb" {6} "e" {7} "f" {8} "f#" {9} "gb" {9} "g" {10}
    "g#" {11} "ab" {11}
]
f: copy []
for n 20 160 20 [append f reduce ['line (as-pair 20 n) (as-pair 120 n)]]
for n 20 120 20 [append f reduce ['line (as-pair n 20) (as-pair n 160)]]
fretboard: to-image layout/tight [box white 150x180 effect [draw f]]
; spacer: to-image layout/tight [box white 20x20]
view center-face layout [
    across
    t1: text-list 60x270 data [
        "E" "F" "F#" "Gb" "G" "G#" "Ab" "A" "A#" "Bb" "B" "C" "C#" "Db"
        "D" "D#" "Eb"
    ]
    t2: text-list 330x270 data extract/index root6-shapes 3 2 [
        either empty? a/text [
            a/text: rejoin [
                copy t1/picked " "
                pick root6-shapes ((index? find root6-shapes value) - 1)
            ]
        ] [
            a/text: rejoin [
                a/text newline copy t1/picked " " 
                pick root6-shapes ((index? find root6-shapes value) - 1)
            ]
        ]
        show a
    ]
    return
    a: area
    return
    btn "Create Chart" [if error? try [
        make-dir %chords
        delete/any %chords/*.*
        ; save/bmp %./chords/spacer.bmp spacer
        html: copy "<html><body bgcolor=#ffffffff>"
        foreach [root spacer1 spacer2 type] (parse/all form a/text " ") [
            diagram: copy [image fretboard]
            diagram2: copy [image fretboard]
            root1: copy root
            foreach itvl (third find root6-shapes type) [
                either find [1 55] itvl [
                    append diagram reduce [
                        'fill-pen white 'circle (select root6-map itvl) 5
                    ]
                ] [
                    append diagram reduce [
                        'fill-pen black 'circle (select root6-map itvl) 5
                    ]
                ]
            ]
            append diagram reduce ['text (trim/all join root1 type) 20x0]
            append diagram reduce [
                'text 
                trim/all to-string (
                    select root6-notes trim/all to-string root1
                )
                130x65
            ]
            save/png
                to-file trim/all rejoin [
                    %./chords/ (replace/all root1 {#} {sharp}) type ".png"
                ]
                to-image layout/tight [
                box white 150x180 effect [draw diagram]
            ]
            append html rejoin [
                {<img src="./} 
                trim/all rejoin [
                    replace/all copy root1 {#} {sharp} type ".png"
                ]
                {">}
            ]

            foreach itvl (third find root5-shapes type) [
                either find [1] itvl [
                    append diagram2 reduce [
                        'fill-pen white 'circle (select root5-map itvl) 5
                    ]
                ] [
                    append diagram2 reduce [
                        'fill-pen black 'circle (select root5-map itvl) 5
                    ]
                ]
            ]
            append diagram2 reduce ['text (trim/all join root type) 20x0]
            append diagram2 reduce [
                'text 
                trim/all to-string (
                    select root5-notes trim/all to-string root
                )
                130x65
            ]
            save/png 
                to-file trim/all rejoin [
                    %./chords/ (replace/all root {#} {sharp}) 
                    type "5th.png"
                ]
                to-image layout/tight [
                box white 150x180 effect [draw diagram2]
            ]
            append html rejoin [
                {<img src="./} (trim/all rejoin [
                    replace/all root {#} {sharp} type "5th.png"
                ]) {">}
                ; {<img src="./spacer.bmp">}
            ]
        ]
        append html [</body></html>]
        write %./chords/chords.html trim/auto html
        browse %./chords/chords.html 
    ] [alert "Error - please remove improper chord labels."]]
    btn "Save" [
        savefile: to-file request-file/file/save %/c/mysong.txt
        if exists? savefile [
            alert "Please choose a file name that does not already exist."
            return
        ]
        if error? try [save savefile a/text] [alert "File not saved"]
    ]
    btn "Load" [
        if error? try [
            a/text: load to-file request-file/file %/c/mysong.txt
            show a
        ] []
    ]
    btn "Create Zip" [
        if not exists? %chords/ [alert "Create A Chart First" return]
        ; rebzip by Vincent Ecuyer:
        do to-string to-binary decompress 64#{
        eJztW+uP20hy/+6/oldGsJ7bcEU2X00Zd4bX9iILXO4AY5N8EOYAjkTNMNaQOomy
        PTbmf8+vqptkU3xIM4cgARICHmvYVdX1fnRrPn745a9/FsvrFy9W1VfnW75biFVZ
        VNnXSixfCDyr/crZlsXtwvzeeVz885IkSsJEJYEQju96bhCHrhKOF8s4CGToSgKS
        QeQHnh/jo1KRG8aRFzb0HD9O/CCMPA+fvciPwziUEX4RMkhkpEAIH90gAGFf0j6h
        lCqUbhTRPkEcY3dftvx5kUwCMBYSCU+GIO1KIh64sR+5oAo8FUWhBDnwJIJEhX4U
        Bgq4IJbIOIqilj/phknoRrSMz1GcuJGrSC5wBCRFvHoKLISQzSchVOwr0PMJHjyr
        JArjlj8CVH6SsP4iBQFiLyR6TuCrIJRhABJJ7LsBRCQg3w8j3w8U6S+KPGI1avUn
        HNggCsKA9ZdIpUJgJ1hIkhgSu0lEJlBeEvpgFkDYzvO8JKJ9wtiVkCgMGnqe60ZK
        KS8I2XQkVBzR3k4cuxArimLCk6RJ6I32gd2TOJaQgei6RKCl50Bb0JRL8jqeD39x
        vTCCMgWwYdYgJP3BYSRkc0mIEDYIvdCnfQJP+lC+77XyRqEXwwqK9efHWPahENID
        VOdJ2A94xHMko4T2CaMwdGNJvEKqIJJebNFzlAv7h2HC+oOWwFWSkFxR7IGnhPzP
        C8mllMv+l4BXP/LZ/+BCkZcElrwiTkLlh6Ek1/IC2N93pQyJJwgC5cAXHUgVKC8G
        HxxDgUdUJHuH54VQTEPPIWbJA2lrOBR4ChLaG3huHICviA0FVv1YerRPhF29wA3I
        F32yrSv91v+kC6XFiBGXfwtJ867PsYQHvkN2dPA/wGQYUQz5McweRz4LRL8pz2/5
        g/IilYRxzC4sOSEkCcUERE1CWJhihewRKNIZ4ilCRMBTSR4J51CBp1r/U1BO7MKY
        gmMM1pCkJ0d6HqJAQgO8qx968EyyaUwBqRLONT4JLmPX0h+CN4CTUIoiwYIkSOKI
        bBrBt0PF9AQ0CgvAiwnBlyQF0Yb34iUiuPUXz4e/+WHCoSkSFSSkb9JfGMR4i1RF
        sSIhYBKHimMoAo8wNwUXtAd2PK/lLyQ4KJi3iwOIgqDlmIDh4bBuRLEC0jHUyj6n
        wlj6yqd9EBmsY7flDyaCjwQR2QMxBu1CZxxLgfQofkOOMWDCIsQTlBr6fkIJDsGF
        gEx87Nky6LnIXyCpONmQTZFWKdgD5B0w5VKyAZ4HHn1yQGTDIPDBIUUXIgRJTXmi
        5RCxhtiCY3K4wEt8BY/kaFIhJQ+OZuI2Voqjzw0SlA6XRIopuCjFWhyCHx+lIuTs
        66K6yMAnYJQkpCvgUkpAMqCADtlukfTJb8g8cF3lIUdJYdUkbAG2Ql2TAs6Yih0S
        kQXnTEhvKDsKviBp10C5LmKdc4JykbvAsUVQIANQRfRdjkCsJ+QJhIjcmniUvYEo
        FZiXigMNsuMfBbFEdkXSQ9RaHEqsgRUv4qqEihdHiUfUkQ6hfeQ7iowIe8HzyFNg
        fqRBN+RIgpeBhcAyigigGiklhx1kRe2OFZcRBEQEhmOXPikZIf0Q50IidFA3JaWi
        GC4ETwttHcLACAJPG4WqgkpYocJHeUKyIYdHrZYI5Yh6A4QatQYB9w+hQlFBeCuL
        QxSwGLHic0/hB1iOeHeH0lmAHEE6pOB2kd042FDIoE1FwQS3jVD/wsTiMIopMwfs
        bjC2knBu9nKUeKgAlYKIJFAg0iRnxQAMIF592gh5TmFjyygCFHyJxKkzMrIkJSny
        IfBBbQqXJo96IRmw90ewODZyyQ996BaeEUUWh/BYdFcel1+PyiYeyeEWI4uiDHFN
        g02gXS/k2gRXcWPuIZDEAAAci8PYRz1CeQ04DkPqtJKQnNbF5hQSFL+UPShwyFho
        xqjIUGNDXurD16SVvOC9iuwScdQgUSJsdXFC4kQajbmoUeeFxEuGjdDt+DCdx1GG
        foBSXJsaoDwXJLmYQJ9YhqOSXWNoB4mUTOJQQGMXlxtDMIi2hPIRVSrIg+xnpQbl
        I/BhK86uCFgoyKVWE0EVkOZZSPg1jImmh2IJFoQpKO84ktw+QuWykleM9EgFjgVD
        oUYUwru5PCnkyDgMOakjn8Nu3BrCi9F3UkoXAedMFNOWQ9RjlCBASM0wQiDi2ujF
        HrWHIduKOl4F0Ti/oByhpYkSTn2o2S6ylcUhmm1k/5gbYAHTkBlc0mGETgcGcqkT
        g1DcuLtc0UARfazkIKPONbECz6HyFlAAkQQOJXzEBHsekij6IF2t0PpT4eUCAGFg
        4iCmCg/fRGsCh7I6TPS/KI+xrqA+Eheyp8spCnUT/knujnQCD+Yy5lGCg4dziUQd
        hVfDjnaFgmIQooorFNIMFVD2Qm4GYBKSDGWBLBLSRtQ6QHpu19F9INTdxLdUGEgq
        skFAoSYirsKBz30bumvEleIeE70cQjIgFYZU0PyYUomA3WDAGA2bVaGgnASxy85B
        WQfr3PyFQEMB5pQBRqkwetysYSoj1H1+e1c5h7t8UzlqITbHYmUNY7OP7fJBVHeZ
        +Jxuj5m4eRBK3OR4lxZrsc+q4744iLz6edagasBljnnvNtv/cC1mvzfoVSmYpIa+
        bvfLcuyxF0V2m1b55+xNTaUzHTqe+FruzRLt71AfORf0kxawTm8pFVDH2uBen5Ah
        eALUhBi/hX3R/uQfx906rTIHE+uAkoz8pB9ApTTXWprgV8u0eHAO1T4vbkkX7+kd
        1LC6y1afDsf7Fhq4Ha39VuRVnm41lz2Fbcp9lq7uQCfdm426kzQz/KpjZXp3xZra
        5atPzRDOO5M+UGp5lWn+JLyeUprZ3ZfjykjFu4/vUEtrCZ+lkL5rZPe76uGNIfHy
        u2uexxPjbst0Lf6zzAsxe/l9JpZV6dxlX2vXaY2pCeH17HF2PSzo60N+W6QQKju8
        0KRX6dbZ5NvMwcoCTBsxxMvvCONfXEydj1pFWVHtp2ERqxo2K9ZOuXFqlGFoNK8a
        mrh21tlhtc93VbkfAcdQ8GhkWJXF52x/yMuCDaYlAUKuj19OjfiOwTm8hfFFMk4q
        tnlVQRhwm2OJkCdD/t/rcNf79wMeLNzkRbp/QBJhc3XNiGX2wjbW4ZyDECSLYfRV
        C42WU7lXJ7F9Ho2zZKQxUQn9S3HnddKJrgYzCWEc7sp99WyNM/b/PpWfS6EAfaKj
        3eS3/7CXrcuBFKDRKdw1a7dZdYFRhszAjDZs9zm0EpzYAX6KVUuXd1lKJZXCNbOM
        tSp3D/Ndim01eWmxf063A2H7P8t80LjF/WFdHpwqv88mBGCPYEhBkH1u6e2lzq+N
        bUJ2flce9+IPdACsrjpeXtZRPb/Pi2OVAciXfZDTIJgfMuy9pli46gaAlpQKz2WS
        EmRfUnr7RElptvyDeHWffhWuYfIhQ/w6NJe4o1KXRXWnhRZ1tzVfpw+WUOR7F9lv
        sy/vz1jwKf7WxV1YIazf2Dqg3eCQ6+PqtI3E0ICGvtMAwgk6IJidui2ifQ8g6DTQ
        WoUTDea+VktnbN/R0rD1/7u0RLuNaCmkQ2lbB+ROP7HrdAAD5V6qqvEu+1u+c6gD
        emjU9P1deb9D63XIKI9RJ9UZOSxmuS/TEJSFMupdVzXymhdaYNNnafB1vs9WaKMe
        BO+toa4fG+gihQ8tCZT0/Rf6rdwwaqentaLzX8t1vslXGGLQcPHSEMJ4E2zY1tBz
        lqwzINxn1V25tsRzmBxU1r455N8ycfL7qWu8RgHYlEIziaKb0TzRIIF5e9dFN7vr
        AYARG6geA4umyRTbrLit7nTr/mKyre84jhZ1IX48wEKW63ShXotv2/xGQJVZet9Z
        OdHRonnR5dxoY2MLD+VkG5gxh1v8s+D92xkvLw4V1NEhYIR5ZYt6Jf7Uvjhh5mrg
        3rNm0hTM3jo9h0/5rmd8OQ5apfm2B++oHkKj63W22cJrOwDXfV5HbNOofktl5mTf
        Lk0rFYw5Zbqpsv2wTz7R1wYT3Gs7cVjxbx5uIF9+fxywVHcQ7C3r4fQRG5jJawIC
        2r499NaNO5lg/6NR89BdeYdYAz9slQE7Gnx1gj/kBUyh96bTyHHCm9OncTjOiQy3
        HtqBchw9r02W6QMM5DX76SWiIVZMNaydhdP8a3YE/qjfT1gt+4oassmz7XoMlumw
        HDXVQd1rkKK0KA7mBaOStqhNBJSBNecJKHHP8PDTA4zzPi4O6KdXfSn7gOiq/z8g
        /s8FhGVhUAVL93Cx88Dr/PCpON7fwPiHaqgqtqA0je0LJPS0Ql91g8mt70fWuaHm
        +okYpr8sN5tD1uflSUE/EfEtkNHTaOnUP/k/aihp2zfjJ7O/f/y3D3Rw3HbTx705
        Xz78PLNHjephh3bWNI14oZvg+lQeWObjtdkcLrRLqztmoLf/92bQAeIP1OZyR23a
        +fvyMzp8UiwdYM7ms7b9NgxpaMK9ZOjJdb89fIOAxZfYAhG9yfeH+lBiaQYl6r1E
        Qd9S08J1UPXgMTjHNLwukChW5TpzGr0265xs/2k2O2GoPosAL+Crs8Rq1+ukWzGb
        XY+tIzIw5HUgOr4BZxU/YsRqZqtfjvl2TXMVvUz3q7v8c1aPoewccBJMBWh0PtUD
        zOFnTbt2JhOVWKVakcOGENCQ+rm14Rfk7Y4NhT4Z+kG0089/MAxsekNsibxqFaGr
        ShefuCK0X4krQsuL1fa4ziwGWgLzdZbt6DKFQQ5aFII8HG/q8Q/MWwjwqpsSY87s
        z/mhqhG+3JFWml60uB2c0DgBcL3maiuKG6dWjiZTIOvDP9o0Y5VpM4kyoJ7hymMl
        mqJguTje10GmHbWuj00OqNXecZglJhdEjFk7cfGTWrhkoIWYRLFjrre1IVDusmKu
        pZtry8+/7HOUPF63mv9W7oWlt4Vwx3VlIhYtzIsTh9HDHllx+Uq/ubq2XJJsuSzK
        iuejNwbnRANky4VZmnvdJWPFhY5BTofa9Plef+pGKotmgHvJPt1uxbJBNNvid3IA
        frOn2ZuJLrtkT1u+/KARUkGi8WDdnnC8GZpX9d4UIA3GG83t9QCnr0W6gzXX+ru8
        RVVncrFFoAwWsfqSkqEaOUbaNnqMu/HYakKfMOaL7iHOoAIGujnbj6xYtK8260cf
        0RXllxcDcpNmqSyUhQlvU0OJtzdDpDDItyEpltrNmISRqg0X42FypBk1ZEzV2qYo
        FFqHteuP4LE2N2zX2l0n9N5qgA8tGZq3+fHeOtByBjvU+un3wvVDljfBL0a7oj76
        iGS6ctdxbin1gu5cR5fdrQwzBM3VZWC5Q5mqBqKantekr9PDRvjX4MGi9ZijzubU
        s6kcWX+y0/vopKlrM3efVrXrzwR3aXGb6SMgpj+XIpDtKUmbawd2Ose7HaP98mW2
        G6Db15LupnugVPY0mX6Y2lXCqpQ/NaPLEOJpomSfQcvUeT3lUC0B4m1kbu7poptx
        e9f8neXuxEPN1dRyfYiNrTpg7SRnZTvIe9P0aIT+NJQedOecbVrocw7XisXNqWmx
        piZDevrQwy0J3ZM07chqS8Fsmo4aqBW51y0fC7tffp+t7NsIu2vmi7vW/9vG2fTL
        fy22D+JLuf+EJhK5vHPMrM8XDvVxBg1E9Qms1ULTo6Xo9MFUQupe2Oqh1w2rnUaa
        Bes3091riLetTC2ZLo2p9rjFoVHuFSRJj9vq6oTA3485zSrvy+LHiluHCSKDXTYf
        EQ3chHAmGD/uoBTraLfS6badwOvXXNubg5sGs0OTYaxY4dmMnZEPr7P9vtwfTjt2
        /dZuZgl4pImnpkwriaq30fdpf16gFxnv3qlmma9AzJ7VtpsG9CReCIG4O8Xi7vEr
        mdK8OeHnPv2UUYrQwxhDnGOn9tU6Lds9hOnXB8KYNNy83qX7QzYnhmtiJ8lp6iD/
        UA42qtXd/nju/P/VeNt51QOWukqP3xVwn6ddXsMO5sRXptf7lu3LNxp8br4NKZbm
        6GKTbuFHfRZ4BxNOU1vUlz7WfbJ+NUKSA8nI90p/UaD7xQGGGEHmXqhGHuTH6le7
        B6mj0HPNxOB5bEuR6Tg0Csy/Ich6kH2Gg9qGo0e0u4deogomNN2732q+7HNKZkR7
        /fvgqe0GLm/bDXuLI1va6XXKiyy4jitZ70d26OfrqX160J3deqsTUnVEm3DIZrgY
        nyvo4TIxuNrnoS/yoMDd++3a5IOgw6wf0Jqs7uamYtfJYHxedM/Mkr2KuZgEp6f9
        ppj+JvWZSwv7YY3O/uYI50+i/ISaQd3U9d9OzlPtZ3xWVeen5Ha419m2H2zTJGpp
        +eBqCmhitK+fM9/pHHteflf014sfgviRmvD37lvvrfuWGvHmO88X0jGXI+8J97d/
        ef9xqnE/fWaEMAMiXTcsxsbBoQfzcL5GNPyxo3xx1lPqx3wt9YLLsaGnkdrTd0L0
        HXuw4qGbHagXIxQU4d7kcPdsd6G+aN9HnqS3GDNIadj1dp8+HNCPXM76ozWMt1PI
        k9CR4Sr7PrYYKpRTBIpS39dt04FzmzHE9h6uaP9e4EJ/eYJb1s5B33aLOt8lu9xF
        Zr+9f/t769qDhzpDz8vvsUrePdZfa3pSSLhsiNo2dM8Hvyie4pOuoD+OFL9++PVX
        AUVfhPYP5G175+fbtov9pPTz4S/vWxtlxeUx8Dxux6uOXp1crr8vR5PkG0Fnhktd
        i/gvXujjBeXCrpSbFG3Kms7/+cBhsl42TJg5Vv8/eJB++vRbgfPZ4gJJntFh0EOT
        aHMD+fTsv892WVqJ/Fk1nx778LQnwkUU6Kn/EIP/jIt/6G8mXmCOaR/ULHa7qUv9
        Y5zy8MrUxQWxsDzxU1NsZnXVmRFH45s+wVWf4qLDG1r3r3wkN3wBaz9D96uT3xgZ
        QrBPjCZtc3p9NJ1p9D3g5e55rU+jlj2MJxv+tQ7Q9jg15b+oQClr7z/GLT52VTY9
        PGz6x1fzxQWI9AwcbGnc50bK9JZ0Mr1sDhyvxWG3zSu+yzpv1WE5GfeZchLuM+U0
        DPUPVs+zwo5QnwReqvH6eXrKPTT3oU/zDHp6d6eL8fMp+znXJzxtpf+2e87QXa/K
        TiNknc6anHxSBfS3cObvc+TYY2EuRdYLpGnr5LOP1V6o0ARS5+pZna07CC0Pet62
        j9hfoGv6L0cgfyluTAAA
    }
    zipfile: to-file request-file/file/save %/c/mysong.zip
    if exists? zipfile [
        alert "Please choose a file name that does not already exist." 
        return
    ]
    zip/deep zipfile %chords/
    ]
    btn "Help" [editor help]
]


REBOL [title: "Bingo"]
write/append %bingo_history.txt rejoin [
    newline newline "NEW GAME:  " now newline newline
]
write %bingo_designer.r {rebol []
    view center-face board-gui: layout/tight [
        size 200x240 across space 0x0
        style b button red 40x40 font-size 28 [
            alert {
                Click the squares, then press the 'S' 
                key to save the image.
            }
        ]
        style n button blue 40x40 effect [] [
            either face/color = blue [
                face/color: white show face
            ] [
                face/color: blue show face
            ]
        ]
        b "B" b "I" b "N" b "G" b "O" return
        n n n n n return
        n n n n n return
        n n n n n return
        n n n n n return
        n n n n n return
        key keycode #"s" [
            save/png file-name: to-file request-file/only/save/file
                %bingo-board_1.png to-image board-gui
            view/new layout [image load file-name]
        ]
    ]
}
insert-event-func [
    either event/type = 'close [
        really: request "Really close the program?"
        if really = true [quit]
    ] [event]
]
cur-let: copy ""
view center-face layout/tight [
    size 1024x768 across space 0x0
    style bb button 64x72 red bold font [size: 48] [
        if ((request/confirm "End game?") = true) [quit]
    ]
    style nn button 64x72 black bold font [size: 14 color: 23.23.23] [
        either face/font/size = 14 [
            set-font face size 46 
            set-font face color white
            show face
            cur-num: to-integer face/text
            case [
                (cur-num <= 15) [cur-let: "B"]
                ((cur-num > 15) and (cur-num <= 30))  [cur-let: "I"]
                ((cur-num > 30) and (cur-num <= 45))  [cur-let: "N"]
                ((cur-num > 45) and (cur-num <= 60))  [cur-let: "G"]
                ((cur-num > 60) and (cur-num <= 75))  [cur-let: "O"]
            ]
            write/append %bingo_history.txt rejoin [
                now "   " cur-let " " face/text newline
            ]
            box1/text: cur-let show box1
            loop 3 [
                box2/text: "" show box2 wait .4
                box2/text: face/text show box2 wait .85
            ]
        ] [
            set-font face size 14 
            set-font face color white
            show face
        ]
    ]
    bb "B" nn "1" nn "2" nn "3" nn "4" nn "5" 
        nn "6" nn "7" nn "8" nn "9" nn "10" 
        nn "11" nn "12" nn "13" nn "14" nn "15" return
    bb "I" nn "16" nn "17" nn "18" nn "19" nn "20" 
        nn "21" nn "22" nn "23" nn "24" nn "25" 
        nn "26" nn "27" nn "28" nn "29" nn "30" return
    bb "N" nn "31" nn "32" nn "33" nn "34" nn "35" 
        nn "36" nn "37" nn "38" nn "39" nn "40" 
        nn "41" nn "42" nn "43" nn "44" nn "45" return
    bb "G" nn "46" nn "47" nn "48" nn "49" nn "50" 
        nn "51" nn "52" nn "53" nn "54" nn "55" 
        nn "56" nn "57" nn "58" nn "59" nn "60" return
    bb "O" nn "61" nn "62" nn "63" nn "64" nn "65" 
        nn "66" nn "67" nn "68" nn "69" nn "70" 
        nn "71" nn "72" nn "73" nn "74" nn "75" return
    box white 512x60 
    box 200.200.255 512x60 font-color blue font-size 52 "Prize: $" [
        face/text: request-text/title/default 
            "Enter Prize Text:" face/text
    ]
    return
    box1: box white 512x80 "" font [size: 50 color: (blue / 2)] 
    box 200.200.255 512x80 font-size 38 font-color black "Current Game:"
    return
    box2: box white 512x240 "" font [size: 200 color: blue] 
    box 200.200.255 136x240
    image1: image 235.235.255 240x240   [
        either true = request/confirm "Create new image?" [
            launch %bingo_designer.r
        ] [
            if error? try [
                image1/image: load request-file/only show image1
            ] [alert "Error loading image."]
        ]
    ] 
    box 200.200.255 136x240
    return
    box white 512x30 
    box 200.200.255 512x30
]


REBOL [title: "Time Clock"]
insert-event-func [
    either event/type = 'close [
        really: request {
            To restart this program you must also 
            restart the computer.  Really close?
        }
        if really = true [quit]
    ] [event]
]
do decompress #{
789C6D544B6FDB300CBEFB57B005861D0ADB49BA6081D7B5971D765977688162
087C506D3AD1224B811E09BC61FF7D941C278A13388E2592FAF8FA44CB5B4C0D
EA1D6A53C032819A759664459EFB4FCA32C98DCD566A77A17ABFAAF2B2692ABB
CC199270B9CA945E5D18644C8974C732D3B52D5ACD2BD566F42665D2C7924A55
C024F1B66938078D93958FEFEF33921E9C41B06B6E82DC7225A1551A41351625
299804252B042EA1514E83C14AC9DADCFC4B2017AA62028ED0D0FEAE61DD9AA4
F4F04E5A2EFC02A2408E4BB88329A97813891E41A05CD9F513D8A896B08CCE4F
4B3A249505D45A6932D41D2CA3DC34B21AB6BCDA9C431C11E838FDB64C1BCC99
88635F9A0DDF42A5B65D48630E613FA30A6807B7F4041565078BA02298C8EFF4
73FEAC76F974315F50665651B92CAE50DF78B0C832EFCDC9C02F6E42B54E5A6A
5AA5B4C6D086D443E81D13D4BE62514C62558F22D51E52B872A2EFF649E111E8
3913637D4687432F351A276CE85FBFECBDDCC10831F19DBBE2191EBE42CD9B06
357AD2F418308A3C906280BFCCEA580D187B2DAE605378A1A7FD36D0DEA6A633
16DB8092EEB98C384F5AE8B5A1039ED66F5CD66A6FBE1084755AC2AB76415E31
E3AF01185755680C117E59315BAD4B7F072D1EF93F7238B05FD019A092387C82
8F1BD412C5FD0C96C3AA00A1589D0BFEAE1991F8C320CF6A21C8C308B480966D
2867E52C97C49B70AD82FA405EAB5D65495E96A1B63E111A42D416CF7838BABF
7D41FB12CEBDD2B9DB3E9322FC1395FC27FFA32426A765E04E021378781C07D5
C774744D8EF7BF90698A66ADB4770CFB1F4ADA752CF8C6BA9FCD1BE266248CB7
DFFD9C8941B8741663C94B1842E73642F0C36C3AC94B2A45EDAA9E7121A58E02
1CD6AD0F6ED8EC29261AADC3365A867BBBA698CE046D088A44F1653FA9FB5048
3DF1ECBC60254DC23D272E1D9A98FB29E5472FA3AC26997F66F3B97F7DE4BDE0
3E9BC2B2B8C2EE72B0F894CDAE58086F4183C5D12D9236BE64E7936064D128DD
422C0A792561609FB3E00AD661268F2650F91F6BB4707323070000
} ;  Ladislav Mecir's nistclock.r
make-dir img-dir: %./clock_photos/
unless exists? %employees [
    write %employees {"Nick Antonaccio" "(Add New...)"}
]
cur-employee: copy ""
avicap32.dll: load/library %avicap32.dll
user32.dll: load/library %user32.dll
find-window-by-class: make routine! [
    ClassName [string!] WindowName [integer!] return: [integer!]
] user32.dll "FindWindowA"
sendmessage: make routine! [
    hWnd [integer!] val1 [integer!] val2 [integer!] val3 [integer!]
    return: [integer!]
] user32.dll "SendMessageA"
sendmessage-file: make routine! [
    hWnd [integer!] val1 [integer!] val2 [integer!] val3 [string!]
    return: [integer!]
] user32.dll  "SendMessageA"
cap: make routine! [
    cap [string!] child-val1 [integer!] val2 [integer!] 
    val3 [integer!] width [integer!] height [integer!]
    handle [integer!] val4 [integer!] return: [integer!]
] avicap32.dll "capCreateCaptureWindowA"
log-it: func [inout] [
    if ((cur-employee = "") or (cur-employee = "(Add New...)")) [
        alert "You must select your name." return
    ]
    if set-system-time nist-corrected-time [nist-correction: 0:0]
    cur-time: now
    record: rejoin [
        newline {[} mold cur-employee 
        { "} mold cur-time {" "} inout { "]}
    ]
    either true = request/confirm rejoin [
        record " -- IS YOUR NAME AND THE TIME CORRECT?"
    ] [
        make-dir %./edit_history/
        write/append %time_sheet.txt ""
        write rejoin [
            %./edit_history/time_sheet--
             "_" now/date "_"
             replace/all form now/time ":" "-"
        ] read %time_sheet.txt
        write/append %time_sheet.txt record
        if error? try [
            write ftp://user:pass@site.com/public_html/time_sheet.txt
                read %time_sheet.txt
        ] [alert "Error uploading to web site (saved locally)."]
        alert rejoin [
            uppercase copy cur-employee ", YOU ARE " inout "."
        ]
    ] [
        alert "CANCELED"
        return
    ]
    time-filename: copy replace/all copy to-string cur-time "/" "_"
    time-filename: copy replace/all copy time-filename ":" "+"
    img-file: rejoin [
        img-dir 
        (replace/all copy cur-employee " " "_")
        "_"
        time-filename "_" 
        next find inout " "
        ".bmp"
    ]
    sendmessage cap-result 1085 0 0
    sendmessage-file cap-result 1049 0 img-file
    ; call to-rebol-file img-file
]
timeclock-report: does [
    timeclock-start-date: request-date
    timeclock-end-date: request-date
    totals: copy ""
    names: load %employees
    log: load %time_sheet.txt
    foreach name names [
        if name <> "(Add New...)" [
            times: copy reduce [name]
            foreach record log [
                if name = log-name: record/1 [
                    flag: none
                    date-time: parse record/2 "/"
                    log-date: to-date date-time/1
                    log-time: to-time first parse date-time/2 "-"
                    if (
                        (log-date >= timeclock-start-date) and 
                        (log-date <= timeclock-end-date)
                    ) [
                        previous-flag: flag
                        either record/3 = "CLOCKED IN " [
                            flag: true
                        ] [
                            flag: false
                        ]
                        either flag <> previous-flag [
                            append times log-date
                            append times log-time
                        ] [
                            alert rejoin [
                                "Duplicate successive IN/OUT entry: "
                                name ", " record/2
                            ] 
                        ]
                    ]
                ]
            ]
            append totals rejoin [name ":" newline]
            total-hours: 0
            foreach [in-date in-time out-date out-time] (at times 2) [
                append totals rejoin [
                    newline 
                    "    in: " in-date ", " in-time 
                    "  out: " out-date ", " out-time "    "
                ]
                if error? try [
                    total-hours: total-hours + (out-time - in-time)
                ] [
                    alert rejoin [
                        "Missing login or Missing logout: " name
                    ]
                ]
            ]
            append totals rejoin [
                newline newline
                "    TOTAL HOURS: " total-hours
                newline newline newline
            ]
        ]
    ]
    write filename: copy rejoin [
        %timeclock_report-- timeclock-start-date 
        "_to_" timeclock-end-date ".txt"
    ] totals
    call/show rejoin ["notepad " to-local-file filename]
]
view/new center-face layout/tight [
    image 320x240
    tl1: text-list 320x200 data sort load %employees [
        cur-employee: value
        if cur-employee = "(Add New...)" [
            write/append %employees mold trim request-text/title "Name:"
            tl1/data: sort load %employees show tl1
        ]
    ]
    key #"^~" [
        del-emp: copy to-string tl1/picked
        temp-emp: sort load %employees
        if true = request/confirm rejoin ["REMOVE " del-emp "?"] [
            new-list: head remove/part find temp-emp del-emp 1
            save %employees new-list
            tl1/data: sort load %employees show tl1
            alert rejoin [del-emp " removed."]
        ]
    ]
    across
    btn "Clock IN" [log-it "CLOCKED IN"]
    btn "Clock OUT" [log-it "CLOCKED OUT"]
    btn "Report" [timeclock-report]
    btn "EXIT" [
        sendmessage cap-result 1205 0 0
        sendmessage cap-result 1035 0 0
        free user32.dll   quit
    ]
]
hwnd: find-window-by-class "REBOLWind" 0
cap-result: cap "cap" 1342177280 0 0 320 240 hwnd 0
sendmessage cap-result 1034 0 0
sendmessage cap-result 1077 1 0
sendmessage cap-result 1075 1 0
sendmessage cap-result 1074 1 0
sendmessage cap-result 1076 1 0
do-events


REBOL [title: "PDF Barcode Generator"]
text-string: "item2342"
x-offset: 10
y-offset: 257   
create-pdf-barcode: func [barcode-string xshift yshift] [
    barcode-width: .3  barcode-height: 12  
    code39: first to-block decompress #{
    789C5D93490EC2400C04EF794514C10504D8EC1CD9F77D07F1FF6F30C9C4E3F6
    200529E54EA91D866F92BA4FC699BB989828FF6277EB793BE7EE3EE69D322F03
    E15D9F27629BEFA9DFE4FBEA377C103CC520F021F684FC087B0227EC037C2C9E
    F209E113F1447C1AF6F503E1B3D2CF517E1EFC36BF087ECB97E221BBEF0A7B42
    7E8D3D816FB00FF0AD7A8A89F09D7A0CDFC3BEF940F841FD267F847D317F827D
    919FC3BE6C3C17E889F92BF4447E833EC8EFDE43A212FE28F2C4317F4A9EED79
    7E95F9F83CBFD56FF21FF51BDE081EFBFB36B127E453EC09BC867D80578447E7
    B3051CDF4F5DFB185ED5FF9DE7C9EF0F6518AA1B22040000
    }
    convfrom: rejoin ["*" barcode-string "*"]
    pdf-dialect-out: copy []
    x: 0
    foreach char convfrom [
        pattern: select code39 form char
        foreach bit pattern [
            x: x + 1
            if bit = #"1" [
                append pdf-dialect-out compose [
                    line width (barcode-width)
                    line
                    ((x * barcode-width) + xshift) (yshift)
                    (
                        (x * barcode-width) + xshift
                    ) (yshift + barcode-height)
                ]
            ]
        ]
        x: x + 1
    ]
    return pdf-dialect-out
]
do load-thru http://www.colellachiara.com/soft/Misc/pdf-maker.r 
barcode-layout: copy []
current-barcode-page: copy [page size 215.9 279.4 offset 0 0]
append current-barcode-page create-pdf-barcode text-string x-offset
    y-offset
append current-barcode-page compose/deep [
    textbox 
    (x-offset - 9.5) (y-offset - 8)
    56 8
    [
        center font Helvetica 3 
        (mold text-string)
    ]
]
append/only barcode-layout current-barcode-page
write/binary %labels.pdf layout-pdf barcode-layout
call %labels.pdf
editor barcode-layout


REBOL [title: "Snake Game"]
do[p: :append u: :reduce k: :pick r: :random y: :layout q: 'image z: :if
g: :to-image v: :length? x: does[alert join{SCORE: }[v b]quit]s: g y/tight
[btn red 10x10]o: g y/tight[btn tan 10x10]d: 0x10 w: 0 r/seed now b: u[q
o(((r 19x19)* 10)+ 50x50)q s(((r 19x19)* 10)+ 50x50)]view center-face
y/tight[c: area 305x305 effect[draw b]rate 15 feel[engage: func[f a e][z a
= 'key[d: select u['up 0x-10 'down 0x10 'left -10x0 'right 10x0]e/key]z a
= 'time[z any[b/6/1 < 0 b/6/2 < 0 b/6/1 > 290 b/6/2 > 290][x]z find(at b
7)b/6[x]z within? b/6 b/3 10x10[p b u[q s(last b)]w: 1 b/3:((r 29x29)*
10)]n: copy/part b 5 p n(b/6 + d)for i 7(v b)1 [either(type?(k b i)=
pair!)[p n k b(i - 3)][p n k b i]]z w = 1[clear(back tail n)p n(last b)w:
0]b: copy n show c]]]do[focus c]]]


REBOL [title: "VID Shooter"]
score: 0   speed: 10   lives: 5   fire: false   random/seed now/time
alert "[SPACE BAR: fire] | [K: move left] | [L: move right]"
do game: [
    view center-face layout [
        size 600x440
        backdrop black
        at 246x0 info: text tan rejoin ["Score: " score " Lives: " lives]
        at 280x440 x: box 2x20 yellow
        at (as-pair -50 (random 300) + 30) y: btn 50x20 orange
        at 280x420 z: btn 50x20 blue
        box 0x0 #"l" [z/offset: z/offset + 10x0 show z]
        box 0x0 #"k" [z/offset: z/offset + -10x0 show z]
        box 0x0 #" " [
            if fire = false [
                fire: true
                x/offset: as-pair (z/offset/1 + 25) 440
            ]
        ]
        box 0x0 rate speed feel [
            engage: func [f a e] [
                if a = 'time [
                    if fire = true [x/offset: x/offset + 0x-30]
                    if x/offset/2 < 0 [x/offset/2: 440  fire: false]
                    show x
                    y/offset: y/offset + as-pair 
                        ((random 20) - 5) ((random 10) - 5)
                    if y/offset/1 > 600 [
                        lives: lives - 1
                        if lives = 0 [
                            alert join "GAME OVER!!! Final Score: " score
                            quit
                        ]
                        alert "-1 Life!"   unview   do game
                    ]
                    show y
                    if within? x/offset (y/offset - 5x5) 60x30 [
                        alert "Ka-blammmm!!!"
                        score: score + 1   speed: speed + 5  fire: false
                        unview   do game
                    ]
                ]
            ]
        ]
    ]
]


REBOL [Title: "Collect the Boxes"]
random/seed now
start-time: now/time
level: to-integer request-text/title/default "Number of Boxes?" "10"
gui: [
    size 600x440  backdrop white
    at -99x0 key keycode [up]    [p/offset: p/offset + 0x-10 show p]
    at -99x0 key keycode [down]  [p/offset: p/offset + 0x10  show p]
    at -99x0 key keycode [left]  [p/offset: p/offset + -10x0 show p]
    at -99x0 key keycode [right] [p/offset: p/offset + 10x0  show p]
    at -99x0 box rate 0 feel [engage: func [f a e][if a = 'time [
        foreach f system/view/screen-face/pane/1/pane [
            if  f <> p [
                if within? (f/offset + 10x10) p/offset 30x30 [
                    remove find system/view/screen-face/pane/1/pane f
                    show system/view/screen-face/pane/1/pane
                ]
            ]
            if (length? system/view/screen-face/pane/1/pane) < 8 [
                alert rejoin ["Your time: " now/time - start-time]
                quit
            ]
        ]
    ]]]
]
for counter 1 level 1 [
    append gui [at random 590x420 box 10x10 random 255.255.255]
]
append gui [p: btn red 20x20]
view center-face layout gui


REBOL [title: "Animated GIF Example"]
anim-frames-block: [64#{
eJxz93SzsEwMZwhn+M4AAg1g3ACmGsCsBjDnPx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+6/zzLD8ez7p/X9/u1/d+fiEq2+Joe3owHjRxqKx408Zi9eNAs
4KbxsEUkLONhq0SaqACDNQAYMLy/ZgQAAA==
}]
count: 1
make-dir %./frames/
for count 1 length? anim-frames-block 1 [
    write/binary rejoin [
        %./frames/ "frame-" count ".gif"
    ] to-binary decompress pick anim-frames-block count
]
file-list: read %./frames/
animation-frames: copy []
for count 1 length? file-list 1 [
    append animation-frames rejoin [
        %./frames/ "frame-" count ".gif"
    ]
]
view center-face layout [
    size 625x415
    backcolor black
    anim: anim rate 10 frames load animation-frames
    btn "Run Animation" [
        for counter 0 31 1 [
            anim/offset: anim/offset + (as-pair counter 0)
            show anim wait .05
        ]
        for counter 0 24 1 [
            anim/offset: anim/offset + (as-pair 0 counter) 
            show anim wait .05
        ]
        for counter 0 31 1 [
            anim/offset: anim/offset + (as-pair (negate counter) 0)
            show anim wait .05
        ]
        for counter 0 24 1 [
            anim/offset: anim/offset + (as-pair 0 (negate counter))
            show anim wait .05
        ]
    ]
]


REBOL [title: "FTP with symbols in username"]
print "reading..."
; print read ftp://user@site.com:pass@site.com/public_html/  ; error
write [
    scheme: 'FTP
    host: "site.com"
    port-id: 21
    target: "/test.txt"
    user: "user@site.com"
    pass: "pass"
    user-data: "some text"
] "test"
halt


REBOL [title: "FTP CHMOD"]
website: request-text/title/default "Web Site:" "site.com (or IP address)"
username: request-text/title/default "User Name:" "user"
password: request-text/title/default "Password:" "pass"
folder: request-text/title/default "Folder:" "public_html"
file: request-text/title/default "File:" "example.cgi"
permission: request-text/title/default "Permission:" "755"
write %ftpargs.txt trim rejoin [{
    open } website {
    user } username { } password {
    cd } folder {
    literal chmod } permission { } file {
    bye
}]
call/show "ftp -n -s:ftpargs.txt"


REBOL [title: "USPS Intelligent Mail Encoder"]
unless exists? %usps4cb.dll [
    write/binary %usps4cb.dll read/binary http://re-bol.com/usps4cb.dll
]
GEN-CODESTRING: make routine! [
    t [string!]  r[string!]  c [string!]  return: [integer!]
]  load/library request-file/only/file %usps4cb.dll "USPS4CB"
t: request-text/title/default "Tracking #:" "00700901032403000000"
r: request-text/title/default "Routing #:" "55431308099"
GEN-CODESTRING t r (make string! 65)
alert first second first :GEN-CODESTRING


REBOL [Title: "Simple Menu Example"]
view center-face gui: layout [
    size 400x300
    at 100x100 H3 "You selected:"
    display: field
    origin 2x2 space 5x5 across
    at -200x-200 file-menu: text-list "item1" "item2" "quit" [
        switch value [
            "item1" [
                face/offset: -200x-200
                show file-menu
                ; PUT YOUR CODE HERE:
                set-face display "File / item1"
            ]
            "item2" [
                face/offset: -200x-200
                show file-menu
                ; PUT YOUR CODE HERE:
                set-face display "File / item2"
            ]
            "quit" [quit]
        ]
    ]
    at 2x2
    text bold "File" [
        either (face/offset + 0x22) = file-menu/offset [
            file-menu/offset: -200x-200
            show file-menu
        ][
            file-menu/offset: (face/offset + 0x22)
            show file-menu
        ]
    ]
    text bold "Help" [
        file-menu/offset: -200x-200
        show file-menu
        ; PUT YOUR CODE HERE:
        set-face display "Help"
    ]
]


REBOL [title: "Days Between"]
sd: ed: now/date    
view layout [
    btn "Select Start Date" [
        sd: request-date 
        sdt/text: to-string sd
        show sdt 
        db/text: to-string ((to-date edt/text) - sd)
        show db
    ]
    sdt: field to-string sd [
        either error? try [to-date sdt/text] [
            alert "Improper date format."
        ] [
            db/text: to-string ((to-date edt/text) - (to-date sdt/text))
            show db
        ]
    ]
    btn "Select End Date" [
        ed: request-date
        edt/text: to-string ed 
        show edt 
        db/text: to-string (ed - (to-date sdt/text)) 
        show db
    ]
    edt: field to-string ed [
        either error? try [to-date edt/text] [
            alert "Improper date format."
        ] [
            db/text: to-string ((to-date edt/text) - (to-date sdt/text))
            show db
        ]
    ]
    h1 "Days Between:"
    db: field "0" [
        either error? try [to-integer db/text] [
            alert "Please enter a number."
        ] [
            edt/text: to-string (
                (to-date sdt/text) + (to-integer db/text)
            )
        ]
        show edt
    ]
]


REBOL [title: "Update My Haxelibs"]
write %haxelibs.txt read http://lib.haxe.org/files/
the-list: read/lines %haxelibs.txt
clean: copy []
foreach line the-list [
    x: (parse/all form (find line ".zip") ">")
    if (length? x) > 2 [
        y: parse form second x "<"
        append clean first y
    ]
]
errors: copy []
make-dir %haxelibs
change-dir %haxelibs
save %list.txt clean
downloaded: read %.
if exists? %previously_downloaded.txt [
    append downloaded load %previously_downloaded.txt
]
save %previously_downloaded.txt unique downloaded
foreach file clean [
    if not (find downloaded (to-file file)) [
        either error? try [size? (join http://lib.haxe.org/files/ file)] [
            print join "ERROR:  " file
            append errors file
        ] [
            print rejoin [
                {Downloading:  } file {  (} 
                size? (join http://lib.haxe.org/files/ file) { kb)}
            ]
            if error? try [
                write/binary 
                    (to-file file)
                    (read/binary (join http://lib.haxe.org/files/ file))
            ] [
                print join "ERROR:  " file
                append errors file
            ]
        ]
    ]
]
save %haxe_lib_download_errors.txt errors
halt
foreach file clean [if find downloaded (to-file file) [print file]]


REBOL [title: "Typing Tutor"]
start-time: now/time
random/seed now/time  
wrds: first system/words
new-word: does [
    x: form pick wrds (random length? wrds)
    t/text: x
    start: now/time/precise
    clear-face f  show t  show a  focus f
]
view center-face layout[
    t: text 200 font-size 20
    f: field [
        dif: to-decimal now/time/precise - start
        a/text: rejoin [
            either x = f/text ["CORRECT! "]["Incorrect :( "] 
            "That took " dif " seconds."
        ]
        new-word
    ]
    a: text bold aqua 200
    do [new-word]
]


REBOL [title: "Print Time Clock Hours Readable"]
dec-time: func [tm] [
    qq: (to-decimal second q: parse form round/to tm 00:00:60 ":") / 60   
    write clipboard:// form round/to ((to-decimal q/1) + qq) .01
]
data1: copy read clipboard://
data2: copy parse/all data1 "^/"
foreach line data2 [
     if line = (trim copy line) [print line]
     if find line "TOTAL HOURS:" [
         hours: to-time (last parse line " ")
         if hours <> none [
             dec-time hours
             ask "Paste Into Paychex, Then Press [ENTER]..."
         ]
     ]
]
halt


REBOL [title: "Parse Prices From Sales Report"]
x: parse {
Item #:  1    Price:  0.99    (tax-free)    8-Nov-2012_11-30-47+rich.txt
Item #:  3    Price:  1.49    (tax-free)    8-Nov-2012_11-30-47+rich.txt
Item #:  2    Price:  7.49    Tax: 0.4494    8-Nov-2012_11-41-12+rich.txt
} none
z: copy []
g: 0
for i 1 (length? x) 1 [
    if "Price:" = pick x i [
         ; print pick x (i)
         y: to-decimal pick x (i + 1)
         g: g + y
         if y > 10 [append z y]
    ]
]
print z
t: 0
foreach i z [t: t + i]
print t
print g
halt


REBOL [title: "Enumerate Blog Photos"]
count: 18
filename: "photoname"
for i 1 count 1 [
    num: form i
    if (length? num) = 2 [num: join "0" num]
    if (length? num) = 1 [num: join "00" num]
    print rejoin [
        {<img alt="" src="} filename num 
        {.jpg" border="0" vspace="" hspace=""><br><br>}
    ]
]
halt


REBOL [title: "NS Basic Image Encoder"]
title-text: "NS Basic Image Encoder"
if system/version/4 = 3 [
    user32.dll: load/library %user32.dll
    get-tb-focus: make routine! [return: [int]] user32.dll "GetFocus"
    set-caption: make routine! [
        hwnd [int] 
        a [string!]  
        return: [int]
    ] user32.dll "SetWindowTextA"
    show-old: :show
    show: func [face] [
        show-old [face]
        hwnd: get-tb-focus
        set-caption hwnd title-text
    ]
]
image-name: request-text/title/default 
    "ID property of image widget:" "Image1"
system/options/binary-base: 64
x: at (form read/binary to-file my-file: request-file/only) 4
y: parse form x "^/"
z: rejoin [{myimage="data:Image/} (at form suffix? my-file 2) {;base64,"}]
len: length? y
for i 2 (len - 1) 1 [
    append z rejoin [
        newline {myimage=myimage & "} (pick y i) {"}
    ]
]
append z rejoin [
    {^/^/} image-name
    {.innerHTML="<img src='" & myimage & "'/>"}
]
editor z


REBOL [title: "Always on Top"]   ; Windows API example
user32.dll: load/library %user32.dll
FindWindowByClass: make routine! [
    ClassName [string!] WindowName [integer!] return: [integer!]
] user32.dll "FindWindowA"
SetWindowPos: make routine! [
    hWnd [integer!] hWndInsertAfter [integer!] X [integer!] Y [integer!]
    cx [integer!] cy [integer!] wFlags [integer!] return: [integer!]
] user32.dll "SetWindowPos"
view/new center-face layout [
    h4 "Try opening some other applications."
    h4 "This window always stays on top."
    area
    field 400
    btn "Quit" [quit]
]
hwnd: FindWindowByClass "REBOLWind" 0
SetWindowPos hwnd -1 0 0 0 0 3
do-events


Rebol [title: "Embedded binary file demo"]  ; .exe created not with Rebol
program: load to-binary decompress 64#{
eJztF11sU2X03K4VqJsrkZJp6OzchhFJsx8qDB9od1fHdIO6ds7AgJX2jttyey/p
vWUjJuNnmNhMibzwaCSLi+EBE1ziGIkBGh0BSYTwwAMme9Dk4kgkgSiKcj3nu7es
QrKFhMUQOcn5+c7fd875+vXe27FJAg4AbIiGAQwWIwZMEbqTcmODN5xRdmRi6aoy
Z83YogngLlaNtV+s6kV7q9KelHeu9LYqQTXt7e/v97UqLcLuqKJIvriShnAIoJ0r
gXvPn+StlDAF5dyzHLwAdlw4TZ1Mm7oQvWDu7jKLslsxBc4KQ30bb9bMHF3F/D5j
MFAHEIbHD+cwb88s9riSEIjvK7EKogZs//bxAvQmYlqM5JsOUwHPWFgEAYDTvqTp
eYdy1Fn5Sh/O96h9nLrrDcD4IpQm7UOkWL/nt6MlqMvxrkl+GVWS7xqWalzDzqGz
9rbyD5ehpmnl+ezt3M/RSPe7Q9/ajeh5+9Ztm3vKh9xoM7SaimLUR18C2JKf+Kg2
APoJwzDOuiAF+hHU/pHXryObdLyP+y2kEhx7UaLfo0gq/RJa60/n88Ndrpz7FmqG
u5bk3L8zwdWXc0+jdOYXkn4lnYfW++/qOPLyDz7BfH3jTXVnplx949inhPvnSgw/
8RSIHM7P8PdSUYtxlxSkONE+o/u7EkNElMbpcuRKUhTjmLH/iHbDQQ7DHqL77zbh
oQxeRa9duBQHkRj+HnIdr7y/e178AvmmnHt5VQAmaNo59/EZ8QSJAY7EURJvMu2x
KipYj2CaEToYve2eYYiwl4rWY6jN8RWF5XtsuWSyhO7aJG8XXQFkNdWYIqIHK8nH
8FOSFJMoteEfZfQEo1SNCPCW2/BTjWK1uXkp9dDDegjrDqpkAUtiJhNp4ma3qUrx
MG6dqkyFMQ2ExQmaxgU2c/07D2ZJsCz3Q68Xh76Cvac2pZwi8jCO8rIZd4jielmc
uHxmsEMe1vMBZJf0YY8Pda95yH5p+tWrI86XMZbTE5a1gVlXFKyryeowp0Cy4Wf+
hdSrWGp26N008hW4XnS6/OBS7MnUVHoK0osoTV+22qF56c95qKdtZBzB66J/imSc
/Rmsg/KDdHFbA9O3RrZWByD/qPf1KTCwze3y2KCbn9vnP4ExoItiwr11zvncqq6+
oXGV//XVa5qCzXxL6M3ZfBfMZyFPBvywgD3FGDjLnGVl83o4T+HJAZ/PFxWTqrcj
GxerHljRqyL9sWXxqU2/nkHki1H4HDkvJeM7vZooeLdnNU2R10K34G1XdgveTmE7
vmv7fNDcFY1u3ABpNa5J6rZd9MouqGpjw6z1GLXn6vDxV/s9o1cYvcroNUanGP2J
UZ3RG4zeZPQ2o3cY/YtRqCdqZ3Qho6WMuhitYHQZ0pr6mRr21Zvv03VFuuMoX0Gd
VqT7BlupKFoXw8eo/8yynUR+HvEa4g3EPxEXYuwSxOWIaxADiGHEBKKGeADxCOIx
a1wXkE81zH/ut0OdG0LtjQ2+hCSBzLUKWoeSyErC+pickIQgfAmhgaSG319xPEvo
ioQ6Ld9D0CL04ddZQuknaxA4W1hRtXeySa0DXWM7BHjDFhHkhLUKYs2cJTcrA0H4
mmtXYgk+m1GVTBBOsVVbXJGDsNTWKexIqpqQ4aWYqgbps4LPCDFNMPcLYXQpldrC
g0bcVHcKcQ220DqyB4PTHYKWScZVgCGsw/LBEgHWsjYLZR2zRTMxWZUwfaFwOAot
SXVXTIuLM9V/ZeuSMw/UxW/s4KOF6W2GNjmp8Uo6rci8ImsZRVLxG+1hZWhgrlv6
/4F/ABcSIgQAEAAA
}
write/binary %program.exe program
call/show %program.exe


REBOL [title: "Tric Trac Game"]  ; Be sure to see the one liner version above!
random/seed now/time
count: 0
view center-face layout [
    backdrop white across
    style tog toggle tan 50x100 [
        sum: 0
        show face
        foreach bttn [a b c d e f g h i j k l] [
            do rejoin [
                {if not find } bttn {/text "(" [sum: sum + to-integer }
                bttn {/text]}
            ]
        ]
        if not find u/text "(" [u/text: rejoin ["(" u/text ")"]  show u]
        t/text: form sum  show t
    ]
    a: tog "1" "" b: tog "2" "" c: tog "3" "" d: tog "4" "" e: tog "5" ""
    f: tog "6" "" g: tog "7" "" h: tog "8" "" i: tog "9" "" j: tog "10" ""
    k: tog "11" "" l: tog "12" ""  return
    u: btn 690x50 font-size 20 "Roll" [
        face/text: (form (1 + random 11)) show face
        count: count + 1
        cnt/text: count  show cnt
    ]
    return
    text "Score:"
    t: text bold "000"
    text "Save" [write %trictrac t/text]
    text "Previous High" [attempt [alert read %trictrac]]
    text "Count:"
    cnt: text bold "000"
]


REBOL [title: "Tiny Tric Trac Game"]  ; see one-liner & big versions above
random/seed now
g: [across btn "Roll" [alert form 1 + random 11]] 
repeat i 12 [append g compose [text (mold i) check]]
view center-face layout g


REBOL [title: "Little Decimal to Binary Conversion Algorithm"]
x: to-integer ask "Decimal Number:  "  y: ""
until [
    insert head y either odd? x [1][0] 
    x: x / 2
    x <= 1
]
alert y


REBOL [title: "Asynchronous Get Keys (Console)"]
print ""
p: open/binary/no-wait console://
q: open/binary/no-wait [scheme: 'console]
count: 0
forever [
    count: count + 1
    if not none? wait/all [q :00:00.01] [
        wait q
        qq: to string! copy q
        probe qq
        print ["^/count incremented to" count "while waiting^/"]
    ]
]


REBOL [title: "Hand-Rolled Multi Column Data Grid #1]
x: copy [] for i 1 179 1 [append x reduce [i random "abcd"]]
grid: copy [across space 0]
forskip x 2 [append grid compose [field (form x/1)field (form x/2)return]]
view center-face layout [across
    g: box 400x200 with [pane: layout/tight grid pane/offset: 0x0]
    scroller [g/pane/offset/y: g/size/y - g/pane/size/y * value show g]
]


REBOL [title: "Hand-Rolled Multi Column Data Grid #2]
x: copy [] 
block1: copy system/locale/months  block2: copy system/locale/days
for i 1 (max length? block1 length? block2) 1 [
    append x either g: pick block1 i [g] [""]
    append x either g: pick block2 i [g] [""]
]
grid: copy [across space 0]
forskip x 2 [append grid compose [field (form x/1)field (form x/2)return]]
view center-face layout [across
    g: box 400x200 with [pane: layout/tight grid pane/offset: 0x0]
    scroller [g/pane/offset/y: g/size/y - g/pane/size/y * value show g]
]


REBOL [title: "Hand-Rolled Multi Column Data Grid #3]
grid: copy [origin 0x0 across space 0x0]
forskip x 2 [
    color: either (remainder ((index? x) - 1) 4) = 0 [white][wheat]
    append grid compose [
        field 180 (form x/1) (color) edge none
        field 180 (form x/2) (color) edge none return
    ]
]
view center-face layout [
    across space 0  
    g: box 360x200 with [pane: layout grid pane/offset: 0x0]
    scroller[g/pane/offset/y: g/size/y - g/pane/size/y * value / 2 show g]
    return box 1x10 return  ; just a spacer
    btn "Get Data Block (INCLUDING USER EDITS)" [
        q: copy [] foreach face g/pane/pane [append q face/text] editor q
    ]
]


REBOL [title: "Hand-Rolled Multi Column Data Grid #4]
x: copy [] for i 1 179 1 [append x reduce [i random "abcd"]]
update: does [q: copy [] foreach face g/pane/pane [append q face/text]]
do qq: [grid: copy [across space 0]
forskip x 2 [append grid compose [
    field (form x/1) 40 edge none 
    field (form x/2) 260 edge [size: 1x1] return
]]
view center-face gui: layout [across space 0
    g: box 300x290 with [pane: layout/tight grid pane/offset: 0x0]
    slider 16x290 [
        g/pane/offset/y: g/size/y - g/pane/size/y * value show g
    ]
    return btn "Add" [
        row: (to-integer request-text/title "Insert at Row #:") * 2 - 1
        update insert at q row ["" ""] x: copy q unview do qq
    ]
    btn "Remove" [
        row: (to-integer request-text/title "Row # to delete:") * 2 - 1
        update remove/part (at q row) 2 x: copy q unview do qq
    ]
    btn "Col 1" [update editor extract q 2]
    btn "Col 2" [update editor extract/index q 2 2]
    btn "Save" [update save to-file request-file/save q]
    btn "Load" [x: load to-file request-file do qq]
    btn "History" [
        m: copy "ITEMS YOU'VE EDITED:^/^/" update for i 1 (length? q) 1 [
            if (to-string pick x i) <> (to-string pick q i) [
                append m rejoin [pick x i " " pick q i newline]
            ]
        ] editor m 
    ]
]]


REBOL [title: "Hand-Rolled Multi Column Data Grid #5]
x: copy [] for i 1 99 1 [append x reduce [i random 99x99 random "abcd"]]
grid: copy [origin 0x0 across space 0x0]
forskip x 3 [
    append grid compose [
        b: box 520x26 either (remainder((index? x)- 1)6)= 0 [white][beige]
        origin b/offset
        text bold 180 (form x/1)
        text 120 center blue (form x/2) [alert face/text]
        text 180 right purple (form x/3) [face/text: request-text] return
        box 520x1 green return
    ]
]
view center-face layout [
    across space 0  
    g: box 520x290 with [pane: layout grid pane/offset: 0x0]
    scroller 16x290 [
        g/pane/offset/y: g/size/y - g/pane/size/y * value / 2 show g
    ]
    return box 1x10 return  ; just a spacer
    btn "Get Data Block" [
        q: copy [] 
        foreach face g/pane/pane [
            if face/style = 'text [append q face/text]
        ]
        editor q
    ]
]


REBOL [title: "NS Basic Image Uploader"]
image-name: request-text/title/default 
    "ID property of image widget:" "Image1"
system/options/binary-base: 64
x: at (form read/binary to-file my-file: request-file/only) 4
y: parse form x "^/"
z: rejoin [
    {myimage="data:Image/} (at form suffix? my-file 2) 
    {;base64,"}
]
len: length? y
for i 2 (len - 1) 1 [
    append z rejoin [
        newline {myimage=myimage & "} (pick y i) {"}
    ]
]
append z rejoin [
    {^/^/} image-name 
    {.innerHTML="<img src='" & myimage & "'/>"}
]
print rejoin ["sending: " form last split-path my-file]
write [
    scheme: 'FTP
    host: "site.com"
    port-id: 21
    target: join "/share_image/" form last split-path replace my-file
    user: "user@site.com"
    pass: "pass"
] z
print "DONE"
halt


REBOL [title: "NS Basic Image Uploader 2"]
system/options/binary-base: 64
x: at (form read/binary to-file my-file: request-file/only) 4
y: parse form x "^/"
z: rejoin [{data:Image/} (at form suffix? my-file 2) {;base64,}]
len: length? y
for i 2 (len - 1) 1 [
    append z rejoin [
        (pick y i) {|}
    ]
]
z: copy/part z ((length? z) - 1)
print rejoin ["sending: " form last split-path my-file]
write [
    scheme: 'FTP
    host: "site.com"
    port-id: 21
    target: join "/share_image/" form last split-path replace my-file
    user: "user@site.com"
    pass: "pass"
] z
print "DONE"
halt


REBOL [title: "Edit Compress Encrypted"]
if error? try [data: read file: request-file/only] [quit]
compressed: find data "#{"
either compressed = none [
    flag: true
    compressed: copy data
    uncompressed: copy data
] [
    flag: false
    uncompressed: decompress load compressed
]
write %uncompressed.txt uncompressed
editor %uncompressed.txt
if true <> request "Save updated file?" [
    ; alert "Changes NOT saved." 
    delete %uncompressed.txt
    quit
] 
replace data compressed (form compress read %uncompressed.txt)
if flag = true [insert head data "rebol []^/^/do decompress "]
write file data
delete %uncompressed.txt
alert "Changes saved."


REBOL [title: "Edit Compress Encrypted 2 - More Encrypted"]
if error? try [data: read file: request-file/only] [quit]
compressed: find data "#{^/"
either compressed = none [
    flag: true
    compressed: copy data
    uncompressed: copy data
] [
    flag: false
    compressed: copy/part compressed ((length? compressed) - 1)
    uncompressed: decompress load compressed
]
write %uncompressed.txt uncompressed
editor %uncompressed.txt
if true <> request "Save updated file?" [
    ; alert "Changes NOT saved." 
    delete %uncompressed.txt
    quit
] 
replace data compressed (form compress read %uncompressed.txt)
if flag = true [
    insert head data rejoin [
        "rebol []^/^/do do form reduce "
        "[to-string #{6465636F6D7072657373} "
    ]
    append data "]"
]
write file data
delete %uncompressed.txt
alert "Changes saved."


REBOL [title: "Convert Compress Encrypted - from version 1 to 2"]
foreach file read %. [
    txt: read file
    if ((not dir? file) and (file <> %convert-compress-encrypted.r)) [
        if find txt "do decompress " [
            replace txt 
                {do decompress } 
                {do do form reduce [to-string #{6465636F6D7072657373} }
            append txt "]"
        ]
        if find txt{do do form reduce [to-string #{6465636F6D7072657373}}[
            if (last txt) <> #"]" [append txt "]"]
        ]
        write file txt
    ]
]


REBOL [title: "Embed a Folder Full of Files"]
system/options/binary-base: 64
sounds: copy []
foreach file load %./  [
    print file
    uncompressed: read/binary file
    compressed: compress to-string uncompressed
    if ((length? uncompressed) > 5000) [
        append sounds compressed
    ]
]
editor sounds


REBOL [title: "Add Spaces Before Comments"]
file: %/C/7-14-10/My_Docs/rebol/rebol_examples.txt
lines: read/lines file  newlines: ""  total-lines: length? lines  count: 1
foreach line lines [
    print rejoin ["Line:  " count " of " total-lines]
    line: to-string line
    linesize: length? line 
    while [(length? line) < 76] [  ; currently, max length of line = 75
        if not find line #";" [break]
        print "updating..."
        replace/all line ";" " ;"
    ]
    newlines: rejoin [newlines line "^/"]
    count: count + 1
]
editor newlines


REBOL [title: "Generic CGI Form Submission Viewer"]
sort-column: 4  ; even numered cols contain data (2nd col is time stamp)
signups: load http://yoursite.com/submitted_forms.txt
do create-list: [
    name-list: copy []
    foreach item signups [append name-list (pick item sort-column)]
]
view center-face layout [
    the-list: text-list 600x150 data name-list [
        foreach item signups [
            if (pick item sort-column) = value [
                dt: copy ""
                foreach [label data] item [
                    dt: rejoin [
                        dt newline label "  " data 
                    ]
                ]
                a/text: dt
                show a
            ]
        ]
    ]
    a: area 600x300 across
    btn "Sort by..." [
        sort-column: to-integer request-text/title/default {
            Data column to list:} "4"
        do create-list
        the-list/data: name-list
        show the-list
    ]
    tab text join (form length? signups) " entries."
]


REBOL [title: "Generic Form Submission Editor"]
submissions: load http://yoursite.com/submitted_forms.txt
do create-list: [
    data: copy []
    foreach block submissions [append/only data (extract/index block 2 4)]
    datastring: copy {}
    foreach block data [
        datastring: join datastring "[^/"
        foreach item block [datastring: rejoin [datastring item newline]]
        datastring: join datastring "]^/^/"
    ]
    editor datastring
]


REBOL [title: "Determine OS"]
switch system/version/4 [
    2 [print "OSX"]
    3 [print "Windows"]
    4 [print "Linux"]
    7 [print "FreeBSD"]
    8 [print "NetBSD"]
    9 [print "OpenBSD"]
    10 [print "Solaris"]
] [alert "Can't be dertermined"]


REBOL [title: "Insert HTML Into Web Page"]
file: %mp3.html
a-string: {<BODY bgcolor="#C8C8C8">}
; first way:
write file read http://re-bol.com/examples/mp3.html
content: read file
insert (skip find content a-string length? a-string) trim {
    <center><h1>MP3 Example!</h1></center>}
write file content
editor file
; second way:
write file read http://re-bol.com/examples/mp3.html
content: read file
begin: (index? find content a-string) + (length? a-string)
altered: rejoin [
    (copy/part content begin)
    {<center><h1>MP3 Example!</h1></center>}
    (at content begin)
]
write file altered
editor file


REBOL [title: "Find Long Lines"]
doc: read/lines to-file request-file
the-text: {}
foreach line doc [
    if ((find/part line "   " 4)) [
        if ((length? line) > 78) [
            print line
            the-text: rejoin [the-text newline line]
        ]
    ]
]
editor the-text


REBOL [title: "Countdown Timer"]
call ""
s: to-integer request-text/title "Seconds: "
repeat i s [print i wait 1]
loop 5 [call "echo ^G" wait 1]
; or:
call ""
seconds: to-integer ask "Seconds: " 
repeat i seconds [print join newpage i  wait 1] 
loop 5 [call/wait "echo ^G"  wait 1]


REBOL [title: "Room Poll (HTML Survey Generator for LANs)"]
view center-face layout [
    style area area 500x100
    across
    h4 200 "SURVEY TOPIC:" 
    h4 200 "Response File:" return
    f1: field 200 "Survey #1"
    f2: field 200 "survey1.db"
    below
    h4 "SURVEY CHECK BOX OPTIONS:"
    a1: area "Check Option 1^/Check Option 2^/Check Option 3"
    h4 "SURVEY RADIO BUTTON OPTIONS:"
    a2: area "Radio Option 1^/Radio Option 2^/Radio Option 3"
    h4 "SURVEY TEXT ENTRY FIELDS:"
    a3: area "Text Field 1^/Text Field 2^/Text Field 3"
    btn "Submit" [
        checks: parse/all a1/text "^/" remove-each i checks [i = ""]
        radios: parse/all a2/text "^/" remove-each i radios [i = ""]
        texts: parse/all a3/text "^/" remove-each i texts [i = ""]
        title: join uppercase f1/text ":"
        response-file: to-file f2/text
        unview
    ]
]
write response-file ""
write %poll-report.r rejoin [{
rebol [title: "Poll Report"]
view center-face layout [
    btn 100 "Generate Report" [
        all-checks: copy []
        all-radios: copy []
        print newpage
        print {All Entries:^/}
        foreach response load %} response-file {[
            x: construct response
            ?? x
            if find first x 'checks [
                either block? x/checks [
                    foreach check x/checks [
                        append all-checks check
                    ]
                ][
                    append all-checks x/checks
                ]
            ] 
            if find first x 'radios [
                either block? x/radios [
                    foreach radio x/radios [
                        append all-radios radio
                    ]
                ][
                    append all-radios x/radios
                ]
            ]            
        ]
        alert rejoin [
            "All Checks: "  mold all-checks
            " All Radios: " mold all-radios
        ]
        check-count: copy []
        foreach i unique all-checks [
            cnt: 0
            foreach j all-checks [
                if i = j [cnt: cnt + 1]
            ]
            append check-count reduce [i cnt]
        ]
        radio-count: copy []
        foreach i unique all-radios [
            cnt: 0
            foreach j all-radios [
                if i = j [cnt: cnt + 1]
            ]
            append radio-count reduce [i cnt]
        ]
        bar-size: to-integer request-text/title/default
            "Bar Chart Size:" "40"
        g: copy [backdrop white text "Checks:"] 
        foreach [m v] check-count [
            append g reduce ['button m v * bar-size]
        ]
        append g [text "Radios:"]
        foreach [m v] radio-count [
            append g reduce ['button gray m v * bar-size]
        ]
        view/new center-face layout g
    ]
    btn 100 "Edit Raw Data" [
       alert "Be careful!"
       editor %} response-file {
    ]
]
}]
launch %poll-report.r
poll: copy ""
repeat i len: length? checks [
    append poll rejoin [
        {<input type="checkbox" name="checks" value="} i {">}
        checks/:i {<br>} newline
    ]
]
append poll {<br>}
repeat i len: length? radios [
    append poll rejoin [
        {<input type="radio" name="radios" value="} i {">}
        radios/:i {<br>}
        newline
    ]
]
append poll {<br>}
repeat i len: length? texts [
    append poll rejoin [
        texts/:i {:<br><INPUT TYPE="TEXT" NAME="text} i 
        {" SIZE="35"><br>} newline
    ]
]
append poll {<br><INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit">}
l: read join dns:// read dns://
print join "Waiting on:  " l
port: open/lines tcp://:80
browse join l "?"
responses: copy []
forever [
    q: first port
    if error? try [
        z: decode-cgi replace next find first q "?" " HTTP/1.1" ""
        if not empty? z [
            append/only responses z
            save response-file responses
            print newpage
            entry-received: construct z
            ?? entry-received
        ]
        d: rejoin [
            {HTTP/1.0 200 OK^/Content-type: text/html^/^/
            <HTML><BODY><FORM ACTION="} l {">} title {<br><br>}
            poll
            {</FORM></BODY></HTML>}
        ]
        write-io q d length? d
    ] [] ;[print "(empty submission)"]
    close q
]
halt


REBOL [title: "GUI CRUD App Builder"]    ; instant app creator
builder: {
fields: copy []
foreach widget widgets [
    if (set-word! = (type? widget)) [append fields to-word widget]
]
count: length? fields
write/append filename ""
dlt: does [
    if true = request "Sure?" [
        temp-block: copy [] 
        foreach fld fields [
            append temp-block compose do rejoin ["copy " fld "/text"]
        ]
        m: reduce temp-block
        remove/part find f: load filename do rejoin [
            fields/1 "/text"
        ] count
        save filename f clr
        t/data: extract f count
        t/sld/redrag t/lc / max 1 length? head t/lines
        show g
    ]
]
tl: does [
    indx: (index? find t/data t/picked) - 1 * count
    repeat i (length? fields) [
        wdgt: fields/:i
        cnt: i
        do rejoin [wdgt "/text: pick f (indx + cnt)"]
    ]
    show g
]
clr: does [
    foreach fc fields [
        do rejoin ["clear-face " fc]
    ] 
    do rejoin ["focus " fields/1]
]
sv: does [
    dlt 
    save filename sort/skip repend f m count
    t/data: extract f count
    t/sld/redrag t/lc / max 1 length? head t/lines
    show g
]
gui: [backdrop white]
append gui widgets
append gui [
    h2 "Existing Records:"
    t: text-list blue 400x100 data (extract f: load filename count) [tl]
    box 1x10 white
    across
    btn "Save" #"^s" [sv]
    n: btn "New" #"^n" [clr]
    d: btn "Delete" #"^~" [dlt]
    btn "Edit Raw Data File" [editor filename]
]
view center-face g: layout gui
}
view layout [
    h4 "Application Title:"
    filename: field "MyApp"
    h4 "Add New Data Fields to Your App:"
    across
    field-label: field 250 "(Type a new field label here - no spaces)"
    field-type: drop-down data ["field" "area"] [
        if face/text = "field" [field-size/text: "200x25"]
        if face/text = "area" [field-size/text: "400x100"]
        show field-size
    ]
    text "Size: " 
    field-size: field 60 "400x100"
    btn "Add Data Field" [
        if find filename/text " " [
            alert "Please remove spaces from the App Title"
            return
        ]
        if find field-label/text " " [
            alert "Please remove spaces from the field label"
            return
        ]
        if field-type/text = none [
            alert "Please select a field type from the drop-down selector"
            return
        ]
        if find code-area/text join field-label/text ":" [
            alert {Duplicate field labels not allowed.  Please choose
                   a new label for any added fields"}
            return
        ]
        append code-area/text rejoin [
            {    h4 "} field-label/text {:" } 
            field-label/text {: } field-type/text { } field-size/text
            newline
        ]
        show code-area
    ]
    return
    h4 "App Layout Code (generated automatically by adding fields above):"
    return
    code-area: area  600x300
    return
    btn "CREATE NEW APP" [
        replace filename/text ".r" ""  show filename
        if exists? to-file join filename/text ".r" [
            alert {An application by that name already exists.  Please
                   create a new application file name.}
            return
        ]
        write created-app: to-file join filename/text ".r" rejoin [
            {rebol [title: "} filename/text {"]} newline
            "filename: %" to-file filename/text newline
            "widgets: [" newline
            code-area/text newline
            "]" newline builder
        ]
        launch created-app
    ]
    btn "Run Existing App" [
        if error? try [do request-file/only] [
            alert {Error running selected app. Be sure to run ".r" files.}
        ]
    ]
    btn "Edit Existing App Code" [
        if error? try [editor request-file/only] [
            alert "Error editing selected app"
        ]
    ]
]


REBOL [title: "Sync Time to Web Server"]
write ftp://user:pass@site.com/public_html/time.cgi 
    {#! /home/path/public_html/rebol/rebol -cs
    REBOL [title: "time"]
    print "content-type: text/html^/"
    print now}
dif: 7:00  ; difference between web server and your local time zone
date: (to-date trim read http://site.com/time.cgi) + dif
lib: load/library %kernel32.dll
set-clock: make routine! [
    systemtime [struct! []]
    return:    [integer!]
] lib "SetSystemTime"
current: make struct! [
    wYear         [short]
    wMonth        [short]
    wDayOfWeek    [short]
    wDay          [short]
    wHour         [short]
    wMinute       [short]
    wSecond       [short]
    wMilliseconds [short]
] reduce [
    date/year
    date/month
    date/weekday
    date/day
    date/time/hour
    date/time/minute
    to-integer date/time/second
    0
]
either ((set-clock current) = 1) [
    ask rejoin ["Time has been set to:  " now "^/^/[Enter]... "]
] [
    ask "Error setting time.  Please check your Internet connection."
]
free lib
; see http://www.fm.tul.cz/~ladislav/rebol/nistclock.r


REBOL [Title: "UDP Group Chat Program"]
net-in: open udp://:9905  ; This is UDP, so NO known IP addresses required
net-out: open/lines udp://255.255.255.255:9905
set-modes net-out [broadcast: on]
svv/vid-face/color: white
name: request-text/title "Your name:"
prev-message: ""
gui: view/new layout [
    a1: area wrap rejoin [name ", you are logged in."]  across
    f1: field
    btn "Save Chat" [write request-file/only/save/file %chat.txt a1/text]
    btn "?" [alert "Press [CTRL] + U to see who's online."]
    at 0x0 key #"^M" [
        if f1/text = "" [return]
        insert net-out rejoin [name {, } now/time {:    } f1/text]
    ]
    at 0x0 key #"^u" [
        insert net-out rejoin [name {, } now/time {:    Who's online?}]
    ]
]
forever [
    focus f1
    received: wait [net-in]
    if not viewed? gui [quit]
    if find (message: copy received) "Who's online" [
        insert net-out rejoin [name " is online."]
    ]
    if message <> prev-message [
        insert (at a1/text 1) message show a1
        attempt [
            insert s: open sound:// load %/c/windows/media/ding.wav
            wait s close s
        ]
    ]
    prev-message: copy message
]


REBOL [Title: "UDP Signin Client Alarm"]
if error? try [net-in: open udp://:9905] [
    alert {
        This program is already running.  If you want to start a new
        instance, please close the currently open program.  If you have
        any problems, close "rebol" in the task manager or just restart
        your computer.
    }
    quit
]
svv/vid-face/color: white
name: request-list "Your name:" [
    "alex" "brian" "chad" "chris" "david" "dorian" "doug" "emerald"
    "jarrod" "josh" "kevin" "kyle" "lindsey" "mark" "nick" "peter"
    "ryan_gaughan" "stef" "steve"
]
previous-signin: []
attempt [
    insert s: open sound:// load %/c/windows/media/ding.wav
    wait s close s
]
gui: view/new center-face layout [
    a1: area 600x400 wrap rejoin [name ", you are logged in."]
    across
    btn "Save History" [
        write request-file/only/save/file (to-file now/date) a1/text
    ]
    btn "Quit" [quit]
    ; at 0x0 key #"^M" [if a1/text = "" [return]]
]
arrive-sound: load %/c/windows/media/ding.wav
forever [
    received: wait [net-in]
    if not viewed? gui [quit]
    if find (message: copy received) name [
        teacher: first parsed: parse copy message none
        student: at (find/match copy message teacher) 2  ; erase newline
        insert (at a1/text 1) rejoin [
            now/time {, } now/date {:     }
            uppercase teacher ", your student has arrived:   " 
            uppercase student
        ] 
        show a1
        attempt [insert s: open sound:// arrive-sound wait s close s]
    ]
    wait 1
]


REBOL [Title: "UDP Signin Server"]
net-out: open/lines udp://255.255.255.255:9905
set-modes net-out [broadcast: on]
svv/vid-face/color: white
previous-signin: []
write/append %last-signin.txt ""
gui: view/new center-face layout [
    a1: area wrap "Server started"  across
    btn "Quit" [quit]
    ; at 0x0 key #"^M" [if a1/text = "" [return]]
]
forever [attempt [
    if not viewed? gui [quit]
    if previous-signin <> current-signin: load %last-signin.txt [
        insert net-out rejoin [current-signin/1 " " current-signin/2]
        previous-signin: current-signin
        insert (at a1/text 1) rejoin [
            "Last signed in student:  " current-signin/2 newline
            "Last signed in teacher:  " current-signin/1 newline
        ] 
        show a1
        write/append %alarm_history.txt rejoin [
            now 
            {  student: } current-signin/2 
            {  teacher: } current-signin/1 newline
        ]
        attempt [
            insert s: open sound:// load %/c/windows/media/ding.wav
            wait s close s
        ]
    ]
    wait 1
]]
quit
{%last-signin.txt contents should be 2 strings  "nick" "john smith"}


REBOL [title: "Request Examples"]
request "Could this be useful?"
request ["Just some information."]
request ["Here are 2 buttons with altered text:" "Probably" "Not Really"]
request ["3 buttons with altered text:" "Probably" "Not Really" "Dunno"]
answer: form request ["Complex example:" "choice 1" "choice 2" "choice 3"]
switch/default answer [
    "true"  [the-answer: "choice 1"]  
    "false" [the-answer: "choice 2"]
    "none"  [the-answer: "choice 3"]
] []
alert join "You chose: " the-answer
request/type ["Here's a better icon for information display."] 'info
request/type ["Altered title and button text go in a block:" "Good"] 'info
request/ok/type "This example is the EXACT same thing as 'alert'." 'alert
request/ok/type "Here's alert with a different icon." 'info
request/ok/type "Here's another icon!" 'stop


REBOL [title: "AutoIt DLL Example"]
if not exists? %AutoItDLL.dll [
    write/binary %AutoItDLL.dll
    read/binary http://musiclessonz.com/rebol_tutorial/AutoItDLL.dll
    write/binary %madplay.exe
    read/binary http://musiclessonz.com/rebol_tutorial/madplay.exe
]
lib: load/library %AutoItDLL.dll
move-mouse: make routine! [
    return: [integer!] x [integer!] y [integer!] z [integer!]
] lib "AUTOIT_MouseMove"
send-keys: make routine! [
    return: [integer!] keys [string!]
] lib "AUTOIT_Send"
winactivate: make routine! [
    return: [integer!] wintitle [string!] wintext [string!]
] lib "AUTOIT_WinActivate"
set-option: make routine! [
    return: [integer!] option [string!] param [integer!]
] lib "AUTOIT_SetTitleMatchMode" 
set-option "WinTitleMatchMode" 2
call/show {madplay.exe -v *.mp3}
view layout [
    across
    btn "forward" [
        winactivate "\reb" ""
        send-keys "f"
    ]
    btn "back"[
        winactivate "\reb" ""
        send-keys "b"
    ]
    btn "volume up" [
        winactivate "\reb" ""
        send-keys "+"
    ]
    btn "volume-down" [
        winactivate "\reb" ""
        send-keys "-"
    ]
    btn "pause" [
        winactivate "\reb" ""
        send-keys "p"
    ]
    btn "quit" [
        winactivate "\reb" ""
        send-keys "q"
        quit
    ]
]


REBOL [title: "Word Count Example"]
view layout [
    i: info rate 0 feel [
        engage: func [f a e] [
            if a = 'time [
                l: length? parse m/text none
                i/text: join "Wordcount: " l
                show i
            ]
        ]
    ]
    m: area 
]


REBOL [title: "Count Characters"]
s: ask "In: " c: ask"For: " r: 0 repeat i length? s [if s/:i = c/1 [++ r]] r
s: ask"" c: ask"" r: 0 repeat i length? s[if s/:i = c/1[++ r]]r
s: ask""c: ask""r: 0 repeat i length? s[if s/:i = c/1[++ r]]r


REBOL [title: "FizzBuzz"]
repeat i 100 [
    j: "" 
    if i // 3 = 0 [j: "fizz"]  ; modulo operator (can also use "mod")
    if i // 5 = 0 [j: join j "buzz"]
    if j = "" [j: i] 
    print j
]


REBOL [title: "Test Script Loop"]
do test-script: [
    if error? try [previous-file: read %previous-file] [previous-file: ""]
    current-file: request-file/only/file previous-file
    if current-file = none [quit]
    write %previous-file current-file
    do current-file   ; launch current-file
    if true = request "Run again?" [do test-script]
]


REBOL [title: "Black Screen"]
view/options layout/tight[box black system/view/screen-face/size]'no-title


REBOL [title: "Echo Clipbord"]
print "started..."
x: copy {}
forever [
    if x <> y: read clipboard:// [
        write/append %clipboard.txt y
        probe y
        x: copy y
    ]
]


REBOL [title: "Choice Button Menu Example"]
menu: [
    "Options" []
    "_________________________^/" []
    "Open File" [attempt [a1/text: read request-file/only show a1]]
    "Copy to Clipboard" [do-face b1 1]
    "Paste from Clipboard" [a1/text: read clipboard:// show a1]
    "_________________________^/" []
    "About" [alert "This menu is just a choice button widget :)"]
    "_________________________^/" []
    "Halt" [halt]
    "Quit" [quit]
]
foreach i (at menu 3) [unless find i "____" [insert head i "     "]]
menu-color: 235.240.245  svv/vid-face/color: 253.253.253
view center-face layout [
    size 440x250 
    across  origin 0x0  space 0x0  box menu-color 8x20
    choice 190x20 left menu-color data (extract menu 2) with [
        para: [indent: 4x0]  colors: reduce [menu-color 215.220.225]
        font: [style: none  shadow: none  colors: [0.0.0]]  edge: none
    ] [do select menu value  face/text: face/texts/1  show face]
    box menu-color 2000x20  origin 20x40  space 20x20  below
    a1: area wrap with [colors: [254.254.254 248.248.248]]
    b1: btn "Submit" [write clipboard:// a1/text alert "Copied"]
]


REBOL [title: "Choice Button Menu Example Multiple"]
request: do replace/all mold :request "bold" ""  ; not required for menus
menu: [[
    "Options" []
    "_________________________^/" []
    "Open File" [attempt [a1/text: read request-file/only show a1]]
    "Copy to Clipboard" [do-face b1 1]
    "Paste from Clipboard" [a1/text: read clipboard:// show a1]
    "_________________________^/" []
    "About" [alert "This menu is just a choice button widget :)"]
    "_________________________^/" []
    "Halt" [halt]
    "Quit" [quit]
][
    "Preferences" []
    "_________________________^/" []
    "Option 1" [alert "Option 1"]
    "Option 2" [alert "Option 2"]
    "Option 3" [alert "Option 3"]
]]
foreach m menu [
    foreach i (at m 3) [unless find i "_____" [insert head i "     "]]
]
clr: func [face] [face/text: face/texts/1  show face]
menu-color: 235.240.245  svv/vid-face/color: 253.253.253
view center-face layout [
    size 440x250 
    style mnu choice 190x20 left menu-color with [
        edge: none  font: [style: none  shadow: none  colors: [0.0.0]]
        para: [indent: 4x0]  colors: reduce [menu-color 215.220.225]
    ]
    across  origin 0x0  space 0x0  box menu-color 8x20
    mnu data (extract menu/1 2) [do select menu/1 value  clr face]
    at 70x0 mnu data (extract menu/2 2) [do select menu/2 value  clr face]
    box menu-color 2000x20  origin 20x40  space 20x20  below
    a1: area wrap with [colors: [254.254.254 248.248.248]]
    b1: btn "Copy" [write clipboard:// a1/text alert "Copied"]
]


REBOL [title: "Choice Button Menu Example"]
menu: [[
    "File" []
    "_________________________^/" []
    "File Option 1" [alert "File Option 1"]
    "File Option 2" [alert "File Option 2"]
    "File Option 3" [alert "File Option 3"]
    "_________________________^/" []
    "About" [do-face b1 1]
][
    "Edit" []
    "_________________________^/" []
    "Edit Option 1" [alert "Edit Option 1"]
    "Edit Option 2" [alert "Edit Option 2"]
    "Edit Option 3" [alert "Edit Option 3"]
][
    "Preferences" []
    "_________________________^/" []
    "Preferences Option 1" [alert "Preferences Option 1"]
    "Preferences Option 2" [alert "Preferences Option 2"]
    "_________________________^/" []
    "Preferences Option 3" [alert "Preferences Option 3"]
]]
gui: [
    a1: area wrap with [colors: [254.254.254 248.248.248]]
    b1: btn "About" [alert "These menus are just a choice button widgets"]
]
do decompress #{
789C5553DBAE9B30107CE72B567929E911C12149A5F2D20F41A87260093E3536
B24D427A947FEFDA26093542D87B19CFEC2E9D36C89B1E0618504D502540AB5B
8C0252EEC875D842352989D64227544BF6CD6FBF36500965D138E89107B3CF86
4D5D2775D248534237A906AA8E3758C74FEE7076647F6E6DBE07B0BDBE05539D
781659A3A5A6E4E270DA154746EF8962AED7FC2ADA2C643E034E87DDF22616DD
34968B006C2F5882D20ABD18451756D6DDE5CB667BDEEADBF314D02CC5B01D3D
44DE438CDCF0D2EB6BD1E71F6756BF230DB6538350BDD942B127B205912D4E5E
FD197D11331F5082E4773D39B84C2259D78BCE5069232E4241C1E623AB133E8E
A8164FA07146A96F71A76760F39E854350030375ACE9B5202AFB9F6C2E1848EC
1CAC58DD84EB219426A42D97B19905B85560CA6D36726160453CB7E22FE63371
DB866CDE184D23B046013B523FC29644CFD9A8A93A2C3138224D8E203EEAE2FA
5FEBE11A54094E6767A99B3F54C84F4D50D1E3D717A53DE04926000261BFDC41
73CB1D8794A6C7F026CACD1F74D91714DB15945FAD26F512FF8FBA7239F9B64B
1386EE95503FC236F6DF6BA7114BD31FF0FD25A313C63A1805310F8AC4163E68
0A637916F591F34704889DF3FFCCA0E09BBD5B8743ACE5BBD1834AEA7FEAF212
1C87030000
}
view center-face layout gui


REBOL [Title: "Quick Color Guide"]
echo %colors.txt ? tuple! echo off
lines: read/lines %colors.txt
colors: copy []
gui: copy [across space 1x1]
count: 0
foreach line at lines 2 [
    if error? try [append colors to-word first parse line none][] 
]
foreach color colors [
    append gui [style box box [alert to-string face/color]]
    append gui reduce ['box 110x25 color to-string color]
    count: count + 1
    if count = 5 [append gui 'return count: 0]
]
view center-face layout gui


REBOL [title "Several List Widget Examples"]
x: copy []
for i 1 10 1 [
    append/only x reduce [form random 1000 form random 1000]
]
slider-pos: 0
view layout [
    across
    the-list: list 220x240 [across text 100 text 100] supply [
        count: count + slider-pos
        if none? q: pick x count [face/text: none exit]
        face/text: pick q index
    ]
    slider 16x240 [
        slider-pos: (length? x) * value
        show the-list
    ]
    return
    btn "Remove" [remove head x  show the-list
    ]
    btn "Add" [
        insert/only head x reduce [form random 1000 form random 1000]
        show the-list
    ]
]
x: copy [
    ["row 1, column 1" "row 1, column 2"]
    ["row 2, column 1" "row 2, column 2"]
    ["row 3, column 1" "row 3, column 2"]
    ["row 4, column 1" "row 4, column 2"]
]
do qq: [view gui: layout [
    the-list: list 304x100 [
        across space 0 
        info 150 [face/text: request-text/default face/text show gui]
        info 150 [face/text: request-text/default face/text show gui]
    ] supply [
        either count > length? x [face/text: "" face/image: none] [
            the-list/set-it face x index count
        ]
    ]
    across
    btn "Save" [
        save to-file request-file/save x
    ]
    btn "Load" [
        x: copy load to-file request-file
        unview do qq
    ]
]]


REBOL [Title: "Editor with Undo-Redo"]
do undo: decompress #{
789CAD58DD6EA33A10BEA64F61F55C546A85C856DA1BBAE7F441908FE4829358
4B2002A709FBF4677E6C6C2034ED9E8DD406EC99F137BF9E49D936565FAC7833
4DC5FF8ABBE4D4546D7A50975C7CDB6C3642BC88A66DB4F85B9C9ADA1C8CD595
7044AAAA72B13D35A528B6AAD412B913B315AAAE45611A818BE20149418415DB
5AED525C7BE59DBDA9B44496C434BDEEAC286BAD3ADACB8849C1527B1C788580
02447D7915A5EAB425467798C72CC6871FA2D6CDCEEE5FC55EAB2A0805909D3E
B4EF7ABE8EE2C6B75C5865EAB00B9B40209DDE3B6D977A8F2073964C1881CC74
BD9D08A2E7DA343AAD4D0F14685D5876A8169495E9ECF00A80BA932608CE5804
F0A71E0EEA48E7FF75FFEFAF7BE138E165B8179DF62F27DE49C15824E365DB76
42F7E55DD26B2B1EF6A636BBBDC56DA7973B5D646D530FC0422BDAD8BD06BEC3
1110455E293032901FDFD8A37B78E7B5DEAACEDB64649992E8A68A0DEE086414
4C183E88448C5105E025593F83A77C1627E4ABBB040DEA1DA5DF7503E164BB5A
1C6B659AA946B899F57BB3056554338862865F2CF421F74A39551D243AB74F04
9790665D5B47A7B36A93631D07F143B2CD01CC6C3C339E4313D44E87384245A5
6BAB4456B7A502046D2FECE1887FCFE42D78C845BBDD422CA4B64D1942C4F784
2CEE10246052A6F0A988C25648602B981AE9B241FCF80765C243010BB260FC0C
9F22525786559DC523BB5195D6B46844A711A481C08C1A447F5647E6F31A8AA3
DAE9F474E4EFAA3D7304A5BDF9A57D608F0B39C7103E8AD43B91A3ACDA69513C
8BC7F04A64B2D8A0DB0141EEFC098FECDE6BF52E00CCE964B67D48A5A88A70F6
2BB0FFF8943B5BCEA3ACEBDAEE152AC48065375448594C934A16CAAE1453E912
0E374CB36D193155297ADDC01E59380F8BA47FE6942DF70A20A023482D6F3ABC
5360B1C79870856BA4192F113A8C56982445618C808D99C8820CDCEB5A97D657
3DF892A14E9CDBAE8A0038AF8395391D58DCE868F02E078CFF7E149B4BFA4D8E
AC18283799918979E0B672E058B55A634E5345E7902DDE54F9334590DE37B810
12173E1DE6F394A901774C987061C204811D73F8609F009F68C86C94070BC6B0
BA64F59C93133CCE70E3490F21A25E1CC67119D3230973ECDB835E155EBCE91D
D49614614DCCA0B1775939A180CDAB4CE4128A3576DA95804CE836E0C704AAA1
B61002E4685DA5FE2643D48031EA4B92D9D5E26F002F89D33E2677F77F76C462
EFD23B848C2B668E56FA1626A20B699C704A2457FB87711374F943AAA3A53FA3
FA4241B188EE58ADCFAB02A7E8518F2B7517849DBA6654E5666576747CC984D4
A70ABC2EC3AAB737688D8B6D5B9E7A566D6B74CD0695DE321763277A5D31FBA2
0636FA8CA11B690C3D115F7245D4B951AB169D862D91A30A8F2470DEB300EDC9
DDB6EBD1403226FE8F36D7C3E323C71D550F4C37CEBD217AD948AF1EEA6F4D3F
6D500C76545C6A737C6B5557E55916E1A37924A54AB28E6F19D68B7273DB1210
3C936CFC20BEA63936F6C39DE6C01B2B0C1DE757A34E73AC2151297A9E35ACAE
25A5FA130571B112D59F4EA90F732A61A808C763FC3F5903F68A0CFC024934F6
1C91955746552EE761381C6B0787CE5746D464325652A98E67BC519D9D8E134A
46D8718CBB0D99CBF0127274F8EFA1BF81CECF95AB08613E5B4407C5D008319A
FBA360F9EA0F09B35F0F6410D3DBCE343B671C8453C496087D37CE945FBC24FE
D44540FFA56B775D478BF43006E08443F2D9C26BC8D898EF469F1FB3C5B43A5F
A6A171AC976C8DAC82AE2E32228D1EF78FF7E30F29530761C71B1B03400BF709
CDCDCAB418113EBB4107EAA7CAFA123A853AECFB1000BA0C7FD2D9F0F8488F92
47DB9831BBE49E2015C423AFCB1A82AC614DD6907B02963544B2B88CE5938980
DAB3F830A221ACDF3F84FA144853F15D5E138220B913FF08E7532077030A4555
BF6FCF3E7769C49602AF8D7E80CBF79061648807B85DB7B858DA0BDFC7B4F21F
C9601ECC1F140000
}
base-color: 230.230.255  base-effect: []
ctx-edit: mold :ctx-edit
changes: [
    {style tx vtext bold 40x22 font [colors: [0.0.0 200.200.200]]} 
    {style tx text 40x22 font [colors: [0.0.0 170.170.170]]}
    {vtext} {text}
    {btn-enter} {btn} {btn-cancel} {btn} {btn green} {btn} {btn red + 50}
        {btn}
    {[tabs: 28 origin: 4x4]}
    {[tabs: 28 origin: 4x4] with [
            undo: []
            colors: [254.254.254 255.255.255]
        ]}
    {Ctrl-V - paste text}
    {Ctrl-V - paste text^/^-^-Ctrl-Z - undo^/^-^-Ctrl-Y - redo}
]
foreach [original changed] changes [replace/all ctx-edit original changed]
ctx-edit: do ctx-edit
editor none


REBOL [title: "REBOL/flash Build Tool"]
write %shape.rswf {
    REBOL [
        type: 'swf
        file: %shape.swf
        background: 230.230.230
        rate: 40
        size: 320x240
    ]
    a-rectangle: Shape [
        Bounds 0x0 110x50
        fill-style [color 255.0.0]
        box 0x0 110x50
    ]
    place [a-rectangle] at 105x100
    showFrame
    end
}
write %text.rswf {
    REBOL [
        type: 'swf
        file: %text.swf
        background: 255.255.255
        rate: 40
        size: 320x240
    ]
    fnt_Arial: defineFont2 [name "Arial"]
    some-text: EditText 'the-text 110x18 [
        Color 0.0.0
        ReadOnly
        NoSelect
        Font [fnt_Arial 12]
        Layout [align: 'center]
    ]
    place [some-text] at 105x100
    doAction [the-text: "Hello world!"]
    showFrame
    end
}
do [
    my-rswf-folder: %./
    change-dir my-rswf-folder
    do http://re-bol.com/rswf.r   ; do %rswf.r
    current-source: to-file request-file/filter/file """*.rswf" %text.rswf
    unset 'output-html
    do edit-compile-run: [
        editor current-source
        if error? err: try [make-swf/save/html current-source] [
            err: disarm :err
            alert reform [
                "The following compile error occurred: "
                err/id err/where err/arg1
            ]
            either true = request "Edit/Compile/Run Again?" [
                do edit-compile-run quit
            ] [
                quit
            ]
        ]
        unless value? 'output-html [
            output-html: to-file request-file/filter "*.html"
        ]
        browse output-html
        if true = request "Edit/Compile/Run Again?" [do edit-compile-run]
    ]
]


REBOL [title: "Generate from source and upload SWF and HTML to web site"]
write %mp3.rswf {
    REBOL [
        type: 'swf5
        file: %mp3.swf
        background: 200.200.200
        rate: 12
        size: 1x1
    ]
    mp3Stream http://re-bol.com/example.mp3
    finish stream
    end
}
source-file: %mp3.rswf
output-html: %mp3.html
output-swf:  %mp3.swf
inserted-html: {<center><h1>MP3 Example!</h1></center>}
insert-at: {<BODY bgcolor="#C8C8C8">}
my-ftp-info: ftp://username:password@site.com/public_html/folder/
destination-url: http://re-bol.com/examples/mp3.html
do http://box.lebeda.ws/~hmm/rswf/rswf_latest.r  ; do %rswf.r
make-swf/save/html source-file 
content: read output-html
insert (skip find content insert-at length? insert-at) inserted-html
write output-html content
write (join my-ftp-info form output-html) (read output-html)
write/binary (join my-ftp-info output-swf) (read/binary output-swf)
browse destination-url


REBOL [title: "Little GUI Metaprogramming Example"]
view center-face layout [
    text "Select a button width, in pixels:"
    d: drop-down data [250 400 550]
    text "Enter any number of button labels (text separated by spaces):"
    f: field 475
    btn "Generate GUI" [
        created-buttons: copy compose [
            style new-btn btn (to-integer d/text) [
                alert join "This button's label is: " face/text
            ]
        ]
        foreach item to-block f/text [
            append created-buttons compose [
                new-btn (form item)
            ]
        ]
        view/new center-face layout created-buttons
    ]
]


REBOL [title: "Math Test - Simple"]
random/seed now
ceil: counter: total: score: 0
calculate: does [
    if error? try [
        either (to-integer f3/text) = do rejoin [
            (to-integer f1/text) " " oprtr/text " " (to-integer f2/text)
        ] [
            alert "Correct!"
            score: score + 1
        ] [
            alert "Wrong!!!!"
        ]
        total: total + 1
        counter: counter + 1
        if (counter > 10) [
            ceil: ceil + 10
            counter: 0
        ]
        f3/text: copy ""
        f1/text: copy form (random 9 + ceil)
        f2/text: copy form (random 9 + ceil)
        show gui
        focus f3
    ] [alert "** ERROR: Please type a number" focus f3]
]
show-score: does [
    alert rejoin [
        {You answered } score { CORRECT and } (total - score) { WRONG.}
    ]
]
view center-face gui: layout [
   f1: field copy form (random 9 + ceil)
   f2: field copy form (random 9 + ceil)
   f3: field 
   key #"^M" [calculate]
   across
   oprtr: rotary 40 "+" "-" "*" "/"
   btn "Score" [show-score]
   do [focus f3]
]


REBOL [title: "Random Smileys 'Sprite Sheet'"] code: [
rows: 4   cols: 3   x: 64  y: 64   random/seed now 
update-pic: does [
    z: as-pair (random rows) * x - x (random cols) * y - y
    img/effect: [crop z]  show img
]
view layout [
   backdrop white
   img: image 61x61 pic #"^M" [update-pic]
]]
pic: load to-binary decompress 64#{
eJyUu2dQE94TLpzQAkhv0ouEkiCoCEjvJQk1IXRQpAkISFcQkd6khlClkwChCUgX
6b1JCR2kg1SlSfGnvv7nnTv3832+7s6zZ8/s7uyenfN3/u8agAGhDdcGAP/hLvAu
APB3CaABoCAjpyAno6AgpwCBKCipGaipqaioWejoaRhus7Cz32ZhY+PkEeLj5BLk
ZmPjv8svKCwCgUI4+MTvi4veFxKFiP6PBAgCgagpqZmpqZlFOdk4Rf+f8bcTwEgJ
6AD8JQXeAZAwAkkZgX97ATwAAAkJ6b/TAv4PKEDklABSMhIg1T+xFgMASEpKQkZK
Tv7PCRIQAAAkIf3nDSNAAMT0QI0Z+ZSS5Y5XKKukekohm+BDlB0G7B1We1vDp65L
atLYPjx1/cfJPxpOIOB/RgD/F2Tk/4gAFP9kMoz/TJCQkVCSk5ECSP8n+ydh/KfA
JPBADcn81Cs0pbD2BwXLna5JQcn1E1Z11EO7ur+LABrSf6SM/zRVAPUh2GQWOKhQ
5dC349OriOaZtKX0SNk5D1XJTbiZGMPAmfKu2h9ky14y7Mu42PLZRpxf7XOCSn1a
H6TR2gwWD/w1MHPKMZBFFr9JIeOXy/vO9YFa2GY8akvc0HTfoudLPRazhor6b5yb
JjEWyuOVw/tGXFUhu85Yimn5UiJ7UcDaLKHHBJVL09ZXyti/po2U3bbqAjen/Le0
2bKknfgD0U1LeDG1LV9DJQF9vm9xsWCVnzxR+etGqINpRZMwgwAj6j1/K9MKc9uN
sveuNyhsCCEsY1bUZEk9KVShDouXNFmerkezqPkyJF6ODZVJJvAVjX/ai8OoolhS
h+Fdg0P9vjyb43Xxv6hbVeVR4g9dfLElNqVPOtydO7ebyo1mfysFW8C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664a1c1TpalmPWUrJ6RnGwsp+o3A
+f66ZEb2drjlKxVLuZQyeoZbcdJ+hUkaPbM4EWjbzrcmY27WZiSCFzcFtKvNLYGD
/q5sahuyMy4Z8/Wr3WPtqb6O3by9cx5CJ79OqlFwo4Z1fiFU2K9dvjN0FtQUlLgK
TLxvyoHZvzV3GwyclNtGWkMMobZbShCAEoQkBIAAwAB2AHbW0JCQABgAYAHbXrTA
AJECvNrcU4oqWZJr/9l+BsVcgFoAAA==
}
do code


REBOL [title: "Math Test"] code: [
random/seed now
ceil: counter: total: score: 0
calculate: does [
    if error? try [
        either (to-integer f3/text) = do rejoin [
            (to-integer f1/text) " " oprtr/text " " (to-integer f2/text)
        ] [
            alert "Correct!"
            score: score + 1
            update-pic true
        ] [
            alert "Wrong!!!!"
            update-pic false
        ]
        total: total + 1
        counter: counter + 1
        if (counter > 10) [ceil: ceil + 10  counter: 0]
        f3/text: copy ""
        f1/text: copy form (random 9 + ceil)
        f2/text: copy form (random 9 + ceil)
        show gui
        focus f3
    ] [alert "** ERROR: Please type a number" focus f3]
]
show-score: does [
    alert rejoin [
        {You answered } score { CORRECT and } (total - score) { WRONG.}
    ]
]
update-pic: func [correct] [
    z: either correct [
        first random [0x0 64x0]
    ] [
        first random [0x64 64x64]
    ]
    img/image: to-image layout/tight [
        image 64x64 pic effect [crop z]
    ]
    show img
]
view center-face gui: layout [
   backdrop white
   f1: field copy form (random 9 + ceil)
   f2: field copy form (random 9 + ceil)
   f3: field 
   key #"^M" [calculate]
   across
   oprtr: rotary 40 "+" "-" "*" "/"
   btn "Score" [show-score]
   text ""
   img: image 64x64
   do [focus f3  update-pic true]
]]
pic: load to-binary decompress 64#{
eJyVlnc02w/09z9GhdRetUcTIzGqKRWxaYMgiMSmatQqNUrNIqjWFqvUFsQetVWV
1mxLEZtWja/aOpSq1q+/55znnOff5/3v69z3eZ977rn3ns+drwDsGLQBGqD5J1ka
WQA4XwR0AQb6CwwX6BkYLjCAQAyMYHYwmIkJzM3K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LmxLvvTd1wlU97rr74LS2BeNyeLS+isACKBZVxzNulxpLpS7se9D
OAewpM9uLmRpl6QtD17TsixakyaIIXpMUih0LN7Q0NAeFY7yzUgVw3bKtX38KhDI
aOumgiExqrGeA/XZ2V0mHtzL7brYIXN0BQj88kPCnOYizhugKwZoeWKjVJlZ5OT8
D95tFCxAj3/Ozm++zM4uxqRcxmZnZ3cYYn38G9XaMk6dHSTEaskp17c8PPvvJxHa
dUN18oOSjW1zxzZuaqv8WjN5Ibl2rVnV3YNJFGyaBqwHCdjYNIQQVoO89joUFEjA
2pzXAcrGJkNV9WaBnJzc/Rfn8/8D1e5Xw6EgAAA=
}
do code


REBOL [title: "Spelling Rules Pretty Printer"]
rules: [
    {"a" says uh} [ago alone ahead above agree]
    {"ai" says long a} [main rain paint wait afraid]
    {"air"} [chair airplane hair unfair repair]
    {"alk"} [walk talk]
    {ar says ar} [alarm farther charge garbage]
    {"ar" says "or"} [warm war]
]  ; rules: load http://re-bol.com/spelling_rules.txt
html: copy {<center><h1>Spelling Rules</h1>
    <table border=1 cellpadding=5 width=90%>}
count: 1
foreach [rule words] rules [
    if count = 1 [append html {<tr>}]
    append html rejoin [
        {<td width=33% valign=top><h3>} (uppercase rule) {</h3>}
    ]
    sort words
    foreach word words [
        append html join form word "<br>"
    ]
    append html {</td>} 
    count: count + 1
    if count > 3 [
        append html {</tr>}
        count: 1
    ]
]
append html {</tr></table></center>}
write %spelling_table.html html
browse %spelling_table.html


REBOL [title: "Student Photo Database (variation on Data Card File)"]
write %StudentList.csv {STUDENTID,LASTNAME,FIRSTNAME,DOB,GRADE
111111,Doe,Steven D,6/16/1992,12
111112,Doe,Jonathan Daniel,12/16/1991,12
111113,Smith,Karen J,12/3/1991,12
111114,Jones,Michael J,6/4/1992,12
111115,Taylor,Ryan C,1/10/1992,12
111116,Adam,Kaitlan C,4/30/1992,12
111117,Washington,Gabryela,3/31/1992,12
111118,Travolta,Juan D,1/24/1992,12
111119,Cruise,Amber E,5/8/1992,12}
either exists? %data.txt [
    database: load %data.txt
][
    filename: %StudentList.csv
    database: copy []
    lines: read/lines filename
    foreach line lines [
        append database parse/all line ","
    ]
    remove/part database 5                    ; get rid of headers
    for counter 6 ((length? database) + 12) 6 [
        insert (at database counter) to-file rejoin [
            "/C/Photos/image_" (pick database (counter - 5)) ".jpg"
        ]
    ]
    save %data.txt database
]
update: func [marker] [
    n/text: pick database marker
    a/text: pick database (marker + 1)
    p/text: pick database (marker + 2)
    o/text: pick database (marker + 3)
    g/text: pick database (marker + 4)
    i/text: pick database (marker + 5)
    if error? try [photo/image: load to-file i/text] [
        ; alert "No image selected"
        photo/image: none
    ]
    photo/text: ""
    show gui
]
view center-face gui: layout [
    text "Load an existing record:"
    name-list: text-list blue 300x80 data sort (extract database 6) [
        if value = none [return]
        marker: index? find database value
        update marker
    ]
    text "ID:"       n: field 300
    text "Last:"     a: field 300
    text "First:"    p: field 300
    text "BD:"       o: field 300
    text "Grade:"    g: field 300
    text "Image:"    i: btn 300 [
        i/text: to-file request-file 
        photo/image: load to-file i/text
        show gui
    ]
    at 340x20 photo: image white 300x300
    across
    btn "Save" [
        if n/text = "" [alert "You must enter a name." return]
        if find (extract database 6) n/text [
            either true = request "Overwrite existing record?" [
               remove/part (find database n/text) 6
            ] [
               return
            ]
        ]
        save %data.txt repend database [
            n/text a/text p/text o/text g/text i/text
        ]
        name-list/data: sort (extract copy database 6)
        show name-list
    ]
    btn "Delete" [
        if true = request rejoin ["Delete " n/text "?"] [
            remove/part (find database n/text) 6
            save %data.txt database
            do-face clear-button 1
            name-list/data: sort (extract copy database 6)
            show name-list
        ]
    ]
    clear-button: btn "New" [
        n/text: copy  ""
        a/text: copy  ""
        p/text: copy  ""
        o/text: copy  ""
        g/text: copy  ""
        i/text: copy  ""
        photo/image: none
        show gui
    ]
    next-btn: btn "Next"  [
        if error? try [
            old-num: copy n/text
            n/text: form ((to-integer n/text) + 1)
            show n
            marker: index? find database n/text
            update marker
        ] [n/text: copy old-num show n alert "No more records"]
    ]
    prev-btn: btn "Previous"  [
        if error? try [
            old-num: copy n/text
            n/text: form ((to-integer n/text) - 1)
            show n
            marker: index? find database n/text
            update marker
        ] [n/text: copy old-num show n alert "No more records"]
    ]
    key keycode [down] [do-face next-btn 1]
    key keycode [up] [do-face prev-btn 1]
    at 340x340 d1: drop-down 300 data [
        "Last Name" "First Name" "Birthday" "Grade"
    ]
    at 340x380 f2: field 300 "Select field above, type search text here" [
        if d1/data = none [alert "Select a search field above" return]
        search-field: to-integer select [
            "Last Name" 2 "First Name" 3 "Birthday" 4 "Grade" 5
        ] d1/data
        results: copy []
        for counter search-field (length? database) 6 [
            if find (pick database counter) copy f2/text [
                append results pick database (counter - search-field + 1)
            ]
        ]
        t/data: copy results  show t
        if [] = results [alert "None found"]
    ]
    at 340x420 t: text-list 300x60 [
        name-list/picked: copy value
        show name-list
        if value = none [return]
        marker: index? find database value
        update marker
    ]
]


REBOL [title: "Space Invaders Shootup"]
alien1:  load to-binary decompress 64#{
eJx9UzFLQzEQjijUOognHTIVhCd0cXJ1kLe3g7SbFKcsWQoWZ7MFhNKxg0PpH3Cx
WbKUqpPoUNcOPim1Q+kPkCJekvf0NTx7cLl7d8l33+XywvL+FrFyhVpCPUY9QN0g
LnG7ScjjrtM98iedToeM3kbW7/f71k4/p6R+USe9Xo/UqjUbi94jMhgMrL/8XpLm
ZZP4spPyzxVTT35MM2Zir4vFYu4dM7GP2M483Fa8f8w0O/Vy24yzo8RXipfJmdb8
kJxwrdJ7K4gxiSs7/09czYpdW6vcsI+AtrEKQ7ScDPlLHO/aNQ8huzaVeSDaHrNi
3IlBjDI6mqVsWvIA0E5ZJ2OtlUIuAKHmqoS5kHOt9UPMP0sm3TU5PHdHQVIZMs3v
qZTPmrMAQAj6ZXOSUtkwPKRwloKQNlexCDOvR4fpclGq76KNzC2mQPiG681i5gAw
ZusVJEAh5JojBzrEGQYC2dncuh7+y83d7ASVAu8MpAQqkT9+3Gg3Q+wHI2AZSAFm
1+99FzMQ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BUhlwj
XgEAAA==
}
ship-fire: load to-binary decompress 64#{
eJxz8t3FAAFlQKwBxOxALAjEjAwsYHEXIBbmhmABqFo2FhYG9l4eBvajbAwKSTIM
/H8FGFjUOBg4tnEyGP1VYWAXZWOwadNg4KhiYdA5JMLAacbJIHNLhUFnkgiDIpMg
2IyDd2UYVMqdGNLLyxoOz7RpCJ5p2pDi4sYAwlFpSz+AcEoJkF8O5KstZWhUkvig
4uLEoAIUO7f7zQcA8m8lvboAAAA=
}
bottom: 270  end: sidewall: false  random/seed now
b: ['image 300x400 ship1 'line -10x270 610x270]
for row 60 220 40 [
    for column 20 380 60 [
        pos: to-pair rejoin [column "x" row]
        append b reduce ['image pos alien1]
    ]
]
view center-face layout/tight [
    scrn: box black 600x440 effect [draw b] rate 1000 feel [
        engage: func [f a e] [
            if a = 'key [
                if e/key = 'right [b/2: b/2 + 5x0]
                if e/key = 'left [b/2: b/2 - 5x0]
                if e/key = 'up [
                    if not find b ship-fire [
                        fire-pos: b/2 + 25x-20
                        append b reduce ['image fire-pos ship-fire]
                    ]
                ]
                system/view/caret: none
                show scrn
                system/view/caret: head f/text
            ]
            if a = 'time [
                if (random 1000) > 900 [ 
                    f-pos: to-pair rejoin [random 600 "x" bottom]
                    append b reduce ['image f-pos alien-fire]
                ]
                for i 1 (length? b) 1 [
                    removed: false
                    if ((pick b i) = ship-fire) [
                        for c 8 (length? head b) 3 [
                            if (within? (pick b c) (
                            (pick b (i - 1)) + -40x0) 50x35)
                            and ((pick b (c + 1)) <> ship-fire) [
                                removed: true 
                                d: c
                                e: i - 1
                            ]
                        ]
                        either ((second (pick b (i - 1))) < -10) [
                            remove/part at b (i - 2) 3
                        ] [
                            do compose [b/(i - 1): b/(i - 1) - 0x9]
                        ]
                    ]
                    if ((pick b i) = alien1) [
                        either ((second (pick b (i - 1))) > 385) [
                            end: true
                        ] [
                            if ((first (pick b (i - 1))) > 550) [
                                sidewall: true
                                for item 4 (length? b) 1 [
                                    if (pick b item) = alien1 [
                                        do compose [
                                          b/(item - 1): b/(item - 1) + 0x2
                                        ]
                                    ]
                                ]
                                bottom: bottom + 2       
                                b/5: to-pair rejoin [-10 "x" bottom]
                                b/6: to-pair rejoin [610 "x" bottom]
                            ]
                            if ((first (pick b (i - 1))) < 0) [
                                sidewall: false
                                for item 4 (length? b) 1 [
                                    if (pick b item) = alien1 [
                                        do compose [
                                          b/(item - 1): b/(item - 1) + 0x2
                                        ]
                                    ]
                                ]
                                bottom: bottom + 2
                                b/5: to-pair rejoin [-10 "x" bottom]
                                b/6: to-pair rejoin [610 "x" bottom]
                            ]
                            if sidewall = true [
                                do compose [b/(i - 1): b/(i - 1) - 2x0]
                            ]
                            if sidewall = false [
                                do compose [b/(i - 1): b/(i - 1) + 2x0]
                            ]
                        ]
                    ]
                    if ((pick b i) = alien-fire) [
                        if within? ((pick b (i - 1)) + 0x14) (
                            (pick b 2) + -10x0) 65x35 [
                            alert "You've been killed by alien fire!" quit
                        ]
                        either ((second (pick b (i - 1))) > 400) [
                            remove/part at b (i - 2) 3
                        ] [
                            do compose [b/(i - 1): b/(i - 1) + 0x3]
                        ]
                    ]
                    if removed = true [
                        remove/part (at b (d - 1)) 3
                        remove/part (at b (e - 1)) 3
                    ]
                ]
                system/view/caret: none
                show scrn
                system/view/caret: head f/text
                if not (find b alien1) [
                    alert "You killed all the aliens. You win!" quit
                ] 
                if end = true [alert "The aliens landed! Game over." quit]
            ]
        ]
    ]
    do [focus scrn]
]


REBOL [title: "Sheep Herder"]
sheep: load to-binary decompress 64#{
eJwB/gMB/P/Y/+AAEEpGSUYAAQEBAGAAYAAA/9sAQwAGBAUGBQQGBgUGBwcGCAoQ
CgoJCQoUDg8MEBcUGBgXFBYWGh0lHxobIxwWFiAsICMmJykqKRkfLTAtKDAlKCko
/8AACwgAMgAyAQERAP/EABwAAAICAwEBAAAAAAAAAAAAAAUGBAcAAQgCA//EAC8Q
AAEDAgUDAwIGAwAAAAAAAAECAwQFEQAGEiExB0FREyJxFGEygZGh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3eMS+sjLQzzSUBtGkxGgRpFiLcYvPp8wzGyhT
mozTbTSUGyG0hKRcknYffDFjMf/Z5+qx2f4DAAA=
}
movestyle: [
    engage: func [f a e] [
        if a = 'down [
            initial-position: e/offset
            remove find f/parent-face/pane f
            append f/parent-face/pane f
        ]
        if find [over away] a [
            f/offset: f/offset + (e/offset - initial-position)
            if overlap? home f [
                if find f/parent-face/pane f [
                    score: score + 1
                    scoreboard/text: rejoin ["Score: " score]
                    show scoreboard
                    screen-count: screen-count + 1
                ]
                remove find f/parent-face/pane f
                show screen
                if screen-count = count [
                    screen-count: 0  count: count + 2
                    new-screen
                    ; loop count [append screen/pane screen/styles/animal]
                ]
            ]
        ]
        show f
    ]
]
make-screen: func [count] [
    gui: copy [
        size 600x400
        backdrop white
        at 250x0 scoreboard: text bold 100 rejoin ["Score: " score] 
        at 250x150 home: box 100x100 "Home" effect [gradient brown red]
        style animal image sheep feel movestyle
    ]
    repeat i count [
        append gui compose [at (random 550x350) animal]
    ]
    append gui [
        box 0x0 rate 0 feel [engage: func [f a e] [if a = 'time [
            if (now/time - start-time) > timer [
                alert rejoin ["TIME! GAME OVER. Score: " score]
                quit
            ]
        ]]]
    ]
]
check-overlap: does [   
    foreach item1 at screen/pane 5 [
        foreach item2 at screen/pane 5 [
            if ((item1 <> item2) and (overlap? item1 item2)) [
                item1/offset: random 550x350
                check-overlap
            ]
        ]
    ]
]
random/seed now/time/precise
score: 0  count: 1  screen-count: 0  timer: 00:00:10
new-screen: does [
    unview
    make-screen count
    screen: layout gui
    check-overlap
    start-time: now/time
    view center-face screen
]
new-screen


REBOL [title: "Camera Manager"]
svv/vid-face/color: white
tt: "Camera Manager"
do set-title: {user32.dll: load/library %user32.dll
gf: make routine![return:[int]]user32.dll"GetFocus"
sc: make routine![hw[int]a[string!]return:[int]]user32.dll"SetWindowTextA"
so: :show show: func[face][so[face]hw: gf sc hw tt]}
make-dir %./history/
write %view1cam.r rejoin [{
    REBOL []
    cam: first parse (first system/options/args) "."
    tt: uppercase form cam } set-title {
    blank-image: to-image layout/tight [box black 640x480]
    file: to-file first system/options/args
    gui: view/new center-face layout [
        across
        i1: image (blank-image)
        return
        btn "Stop" [flag: false]
        btn "Start" [flag: true]
        box 0x0 []
    ]
    flag: true
    forever [
        wait .15  if not viewed? gui [quit]  show gui  if flag = true [
            attempt [i1/image: (load file) show i1]
        ]
    ]    
}]
write %viewhist.r rejoin [{
    REBOL []
    svv/vid-face/color: 230.230.230
    change-dir %./history/
    cam: to-file first system/options/args
    tt: uppercase form cam } set-title {
    files: read %./
    if cam <> %all [
        remove-each file files [
            cam-in-file: to-file (first parse (last parse file "_") ".")
            cam <> cam-in-file
        ]
    ]
    last-file: length? files
    counter: 0
    blank-image: to-image layout/tight [box black 640x480]
    update-screen: does [
        attempt [
            i1/image: (load cf: pick files counter)  show i1
            t1/text: rejoin [
                "Current file:  " form cf {  (} counter {/} last-file {)}
            ]
            show t1
        ]
    ]
    gui: view center-face layout [
        across
        i1: image (blank-image)
        return
        btn "Reverse" feel [engage: func [f a e] [
            if find [down over away] a [
                counter: counter - 1
                if counter < 1 [counter: 1]
                update-screen
            ]
        ]]
        btn "Forward" feel [engage: func [f a e] [
            if find [down over away] a [
                counter: counter + 1
                if counter > last-file [counter: last-file]
                update-screen
            ]
        ]]
        btn "Select" [
            selected-file: to-file request-list "Select An Image:" files
            if selected-file = %none [return]
            counter: index? find files selected-file
            update-screen
        ]
        btn "Save" [
            save/png request-file/only/save/file (pick files counter)
                i1/image
        ]
        t1: text bold 370 {
            Select image, or scroll forward/back (arrow keys work)
        }
        key keycode [left] [
            counter: counter - 1
            if counter < 1 [counter: 1]
            update-screen
        ]
        key keycode [right] [
            counter: counter + 1
            if counter > last-file [counter: last-file]
            update-screen
        ]
        key keycode [up] [
            counter: counter - 20
            if counter < 1 [counter: 1]
            update-screen
        ]
        key keycode [down] [
            counter: counter + 20
            if counter > last-file [counter: last-file]
            update-screen
        ]
    ]
}]
write %localcam.r {
    REBOL [title: "Local Camera Test Streamer"]
    avicap32.dll: load/library %avicap32.dll
    user32.dll: load/library %user32.dll
    find-window-by-class: make routine! [
        ClassName [string!] WindowName [integer!] return: [integer!]
    ] user32.dll "FindWindowA"
    sendmessage: make routine! [
        hWnd [integer!] val1 [integer!] val2 [integer!] val3 [integer!]
        return: [integer!]
    ] user32.dll "SendMessageA"
    sendmessage-file: make routine! [
        hWnd [integer!] val1 [integer!] val2 [integer!] val3 [string!]
        return: [integer!]
    ] user32.dll  "SendMessageA"
    cap: make routine! [
        cap [string!] child-val1 [integer!] val2 [integer!] 
        val3 [integer!] width [integer!] height [integer!]
        handle [integer!] val4 [integer!] return: [integer!]
    ] avicap32.dll "capCreateCaptureWindowA"
    gui: view/new center-face layout/tight [
        at -10x-10 b1: box 0x0 
        pic1: image 320x240
    ]
    hwnd: find-window-by-class "REBOLWind" 0
    cap-result: cap "cap" 1342177280 0 0 320 240 hwnd 0
    sendmessage cap-result 1034 0 0
    sendmessage cap-result 1077 1 0
    sendmessage cap-result 1075 1 0
    sendmessage cap-result 1074 1 0
    sendmessage cap-result 1076 1 0
    counter: 1  flag: true
    forever [
        wait .05
        if not viewed? gui [
            sendmessage cap-result 1205 0 0
            sendmessage cap-result 1035 0 0
            free user32.dll
            quit
        ]  
        show b1
        if flag = true [
            sendmessage cap-result 1085 0 0
            filename: rejoin ["cam" counter ".png"]
            sendmessage-file cap-result 1049 0 filename
            counter: counter + 1
            if counter > 24 [counter: 1]
        ]
    ]
}
blank-image: to-image layout/tight [box black 160x120]
gui: view/new center-face layout/tight [
    across
    btn "Stop" [flag: false]
    btn "Start" [flag: true]
    btn "Test With Local Camera" [launch %localcam.r]
    text "View History: "
    drop-down data [
        "cam1" "cam2" "cam3" "cam4" "cam5" "cam6" "cam7" "cam8" "cam9"
        "cam10" "cam11" "cam12" "cam13" "cam14" "cam15" "cam16" "cam17"
        "cam18" "cam19" "cam20" "cam21" "cam22" "cam23" "cam24" "all"
    ] [call/show join "rebol -s %viewhist.r " value]
    t1: text blue "Updating Camera: 000"
    return
    i1: image (blank-image) [call/show "rebol -s %view1cam.r cam1.png"]
    i2: image (blank-image) [call/show "rebol -s %view1cam.r cam2.png"]
    i3: image (blank-image) [call/show "rebol -s %view1cam.r cam3.png"]
    i4: image (blank-image) [call/show "rebol -s %view1cam.r cam4.png"]
    i5: image (blank-image) [call/show "rebol -s %view1cam.r cam5.png"]
    i6: image (blank-image) [call/show "rebol -s %view1cam.r cam6.png"]
    return
    i7: image (blank-image) [call/show "rebol -s %view1cam.r cam7.png"]
    i8: image (blank-image) [call/show "rebol -s %view1cam.r cam8.png"]
    i9: image (blank-image) [call/show "rebol -s %view1cam.r cam9.png"]
    i10: image (blank-image) [call/show "rebol -s %view1cam.r cam10.png"]
    i11: image (blank-image) [call/show "rebol -s %view1cam.r cam11.png"]
    i12: image (blank-image) [call/show "rebol -s %view1cam.r cam12.png"]
    return
    i13: image (blank-image) [call/show "rebol -s %view1cam.r cam13.png"]
    i14: image (blank-image) [call/show "rebol -s %view1cam.r cam14.png"]
    i15: image (blank-image) [call/show "rebol -s %view1cam.r cam15.png"]
    i16: image (blank-image) [call/show "rebol -s %view1cam.r cam16.png"]
    i17: image (blank-image) [call/show "rebol -s %view1cam.r cam17.png"]
    i18: image (blank-image) [call/show "rebol -s %view1cam.r cam18.png"]
    return
    i19: image (blank-image) [call/show "rebol -s %view1cam.r cam19.png"]
    i20: image (blank-image) [call/show "rebol -s %view1cam.r cam20.png"]
    i21: image (blank-image) [call/show "rebol -s %view1cam.r cam21.png"]
    i22: image (blank-image) [call/show "rebol -s %view1cam.r cam22.png"]
    i23: image (blank-image) [call/show "rebol -s %view1cam.r cam23.png"]
    i24: image (blank-image) [call/show "rebol -s %view1cam.r cam24.png"]
]
previous-files: read %./
remove-each file previous-files [%.png = suffix? file]
flag: true
forever [
    wait .05  show i1  if flag = true [
        current-files: read %./
        new-files: exclude current-files previous-files
        foreach file new-files [
            if not viewed? gui [quit]  show i1  if flag = true [
                do process-image: [
                    loaded-file: load file
                    if error? try [
                        rename file to-file rejoin [
                            %./history/ 
                            now/year "-" now/month "-" now/day 
                            "_" replace/all form now/time ":" "-"
                            "_" file
                        ]
                    ] [
                        ; print "error deleting"
                        do process-image
                    ]
                ]
                camnum: replace replace form copy file "cam" "" ".png" ""
                t1/text: join "Updating Camera: " camnum  show t1
                do rejoin [
                    "i" camnum "/image: " loaded-file " show i" camnum
                ]
                wait .05
            ]
        ]
    ]
]


REBOL [title: "PDF Composing Values Example"]
do http://www.colellachiara.com/soft/Misc/pdf-maker.r
xpos: 50  ypos: 200  offset: 5  
size: 5  width: (10 * size)  height: (2.4 * size)
page1: compose/deep [[
    image 
        (xpos + offset) (ypos + offset)
        (width) (height)
        (system/view/vid/image-stock/logo)
]]
write/binary %example.pdf layout-pdf page1
call %example.pdf


REBOL [title: "PDF Guitar Fretboard Note Overlay Printer"]
chosen-scale: none
view center-face layout [
    h1 "Fretboard length:"
    text-list "25.5" "27.67" "30" [
        chosen-scale: join "scale" value
        unview
        alert rejoin [
            "Now printing " 
            value 
            " inch scale fretboard overlay to 'notes.pdf'"
        ]
    ]
]
notes: [
    [{F}{C}{ }{ }{ }{F}]
    [{ }{ }{A}{E}{B}{ }]
    [{G}{D}{ }{F}{C}{G}]
    [{ }{ }{B}{ }{ }{ }]
    [{A}{E}{C}{G}{D}{A}]
    [{ }{F}{ }{ }{ }{ }]
    [{B}{ }{D}{A}{E}{B}]
    [{C}{G}{ }{ }{F}{C}]
    [{ }{ }{E}{B}{ }{ }]
    [{D}{A}{F}{C}{G}{D}]
    [{ }{ }{ }{ }{ }{ }]
    [{E}{B}{G}{D}{A}{E}]
]

scale25.5: [
    36.35 70.66 103.05 133.62 162.47 189.71 215.41 239.67 262.58 284.19
    304.59 323.85 342.03 359.18 375.38 390.66 405.09 418.70 431.56 443.69
    455.14 465.95 476.15 485.77
]

scale27.67: [
    39.45 76.68 111.82 144.99 176.30 205.85 233.74 260.07 284.92 308.38
    330.51 351.41 371.13 389.75 407.32 423.91 439.56 454.34 468.28 481.45
    493.87 505.60 516.67 527.11
]

scale30: [
    42.77 83.14 121.24 157.20 191.15 223.18 253.43 281.97 308.91 334.34
    358.34 381.00 402.38 422.57 441.62 459.60 476.57 492.59 507.71 521.99
    535.46 548.17 560.17 571.50
]

x: 40  line-width: 30  text-width: 4  height: 5

make-overlay: does [
    page1: copy [
        textbox 40 0 4 6 [center font Helvetica 5 "E"]
        textbox 45 0 4 6 [center font Helvetica 5 "B"]
        textbox 50 0 4 6 [center font Helvetica 5 "G"]
        textbox 55 0 4 6 [center font Helvetica 5 "E"]
        textbox 60 0 4 6 [center font Helvetica 5 "A"]
        textbox 65 0 4 6 [center font Helvetica 5 "E"]
    ]
    output: copy []
    for i 1 10 1 [
        y: do compose [pick (to-word chosen-scale) i]
        notes-at-fret: pick notes i
        append page1 compose/deep [
            line width 4 (x) (y) (x + line-width) (y)
            textbox (x) (y - 10) (text-width) (height + 1) [
                center font Helvetica (height) (notes-at-fret/1)
            ]
            textbox (x + 5) (y - 10) (text-width) (height + 1) [
                center font Helvetica (height) (notes-at-fret/2)
            ]
            textbox (x + 10) (y - 10) (text-width) (height + 1) [
                center font Helvetica (height) (notes-at-fret/3)
            ]
            textbox (x + 15) (y - 10) (text-width) (height + 1) [
                center font Helvetica (height) (notes-at-fret/4)
            ]
            textbox (x + 20) (y - 10) (text-width) (height + 1) [
                center font Helvetica (height) (notes-at-fret/5)
            ]
            textbox (x + 25) (y - 10) (text-width) (height + 1) [
                center font Helvetica (height) (notes-at-fret/6)
            ]
        ]
    ]
    append/only output page1
    write/binary %notes.pdf layout-pdf output
    alert "Done"
]
do http://www.colellachiara.com/soft/Misc/pdf-maker.r
make-overlay


REBOL [title: "RebGUI Request-List"]
do %rebgui.r
display "Main" [
    button -1 "Click for a requestor" [
        rslt: ""
        display/dialog "Delete" compose [
            text 50 "Pick a Month:" 
            return
            tl1: text-list 50 data system/locale/months [
                rslt: tl1/selected hide-popup
            ]
            return
            button -1 "Cancel" [rslt: "" hide-popup]
        ]
        alert rslt
    ]
]
do-events


REBOL [title: "Request-List2"]
request-list2: func [
    titl [string!] 
    alist [block!] /offset xy /local rslt list-lay
][
    list-lay: layout [
        backdrop white
        origin 10x10 
        h3 titl 
        text-list 600x400 data alist [rslt: value hide-popup] 
        btn-cancel #"^[" [rslt: none hide-popup]
    ] 
    rslt: none 
    either offset [inform/offset list-lay xy] [inform list-lay] 
    rslt
]
x: request-list2 "asdf" system/locale/months
alert form x


REBOL [title: "RebGUI Point of Sale System"]
write %posp.db {["username" "password"] ["username2" "password2"]} ; etc.
make-dir %./receipts/
write/append %./receipts/deleted.txt ""
unless exists? %scheme_has_changed [
    write %ui.dat decompress #{
        789C9552CB92A3300CBCE72BBCDCA18084995A7E652A078115F08EB129592C33
        7FBFC24E32CC2387A5EC2A49ED6EB56C267845E5BB3FD8F32FF57250F2CD3060
        ABEAA629E23E95B1CAF8C6AD7A3A1571A5D28813E6D60CA32055752AAAE67751
        97CF3B5003BDB6EA5817CF821E9B8804067E484BE04F34BFB035EE4EACCB5371
        DD9FE044AD8E4FC5751FCE6AFA3E648FD6B62A51516F035731BE78B7B9AAEF49
        3EE2D5693A3CC02CCD63B8F5DB8CC464021A8CBB49066B3492901EB4879E8D77
        B92C74BC1D7CD1E467992DB0D8319CA28B41ABE53D42583D691566E31C521438
        7F9161E844241276780F84BCC117DF2F410E480E7BFCBDB7A697FA407E99F3CE
        BF493787568511919588E631DF5146131F602FFA1F8645B1437D35A2BA85D93B
        F5317A8C9810BF5DC240E6A1F0CF374CE4D790B31F507E45B9E10BD8801122D0
        6633DEEC5E3CFB8BA4C14176AF6D936540066CA6B2DE2F649094C35532361386
        EC0B270D18660B61CC355A78BFFD53ECBD6533DF8A655BCA4AD08A9D366E905E
        4C4B72B71AA7FDDA2AE71D1ECEFF004BE40F38A0030000
    }
]
do http://re-bol.com/rebgui.r
do login: [
    userpass: request-password
    if (length? userpass) < 2 [quit]
    posp-database: to-block read %posp.db
    logged-in: false
    foreach user posp-database [
        if (userpass/1 = user/1) and (userpass/2 = user/2) [
            logged-in: true
        ]
    ]
    either logged-in = true [] [
        alert "Incorrect Username/Password"
        do login
    ]
]
calculate-totals: does [
    tax: .06
    subtotal: 0
    foreach [item booth price] pos-table/data [
        subtotal: subtotal + to decimal! price
    ]
    set-text subtotal-f subtotal
    set-text tax-f (round/to (subtotal * tax) .01)
    set-text total-f (round/to (subtotal + (subtotal * tax)) .01)
    set-focus barcode
]
add-new-item: does [
    if ("" = copy f1/text) or ("" = copy f2/text) or (error? try [
        to-decimal copy f3/text
    ]) [
        alert trim/lines {You must enter a proper Item Description,
            Booth Number, and Price.}
        return
    ]
    pos-table/add-row/position reduce [
        copy f1/text copy f2/text copy f3/text
    ] 1
    calculate-totals
]
print-receipt: does [
    if empty? pos-table/data [
        alert "There's nothing to print." return
    ]
    html: copy rejoin [
        {<html><head><title>Receipt</title></head><body>
        <table width=40% border=0 cellpadding=0><tr><td>
        <h1>Business Name</h1>
        123 Road St.<br>
        City, State 98765<br>
        123-456-7890
        </td></tr></table><br><br>
        <center><table width=80% border=1 cellpadding=5>
        <tr>
        <td width=60%><strong>Item</strong></td>
        <td width=20%><strong>Booth</strong></td>
        <td width=20%><strong>Price</strong></td></tr>}
    ]    
    foreach [item booth price] pos-table/data [
        append html rejoin [
            {<tr><td width=60%>} item 
            {</td><td width=20%>} booth 
            {</td><td width=20%>} price {</td></tr>}
        ]
    ]
    append html rejoin [
        {<tr><td width=60%></td><td width=20%><strong>SUBTOTAL:
        </strong></td><td width=20%><strong>}
        copy subtotal-f/text 
        {</strong></td></tr>}
    ]
    append html rejoin [
        {<tr><td width=60%></td><td width=20%><strong>TAX:
        </strong></td><td width=20%><strong>}
        copy tax-f/text 
        {</strong></td></tr>}
    ]
    append html rejoin [
        {<tr><td width=60%></td><td width=20%><strong>TOTAL:
        </strong></td><td width=20%><strong>}
        copy total-f/text 
        {</strong></td></tr>}
    ]
    append html rejoin [
        {</table><br>Date: <strong>} now/date 
        {</strong>, Time: <strong>} now/time 
        {</strong>, Salesperson: } userpass/1
        {</center></body></html>}
    ]
    write/append to-file saved-receipt: rejoin [
        %./receipts/
        now/date "_"
        replace/all copy form now/time ":" "-"
        "+" userpass/1 
        ".html"
    ] html
    browse saved-receipt
]
save-receipt: does [
    if empty? pos-table/data [
        alert "There's nothing to save." return
    ]
    if allow-save = false [
        unless true = resaving: question trim/lines {
            This receipt has already been saved.  Save again?
        } [
            if true = question "Print another copy of the receipt?" [
                print-receipt
            ]
            return
        ]
    ] 
    if resaving = true [
        resave-file-to-delete: copy ""
        display/dialog "Delete" compose [
            text 150 (trim/lines {
                IMPORTANT - DO NOT MAKE A MISTAKE HERE!  
                Since you've made changes to an existing receipt,
                you MUST DELETE the original receipt.  The original
                receipt will be REPLACED by the new receipt (The
                original data will be saved in an audit history file,
                but will not appear in any future seaches or totals.)
                Please CAREFULLY choose the original receipt to DELETE:
            })
            return
            tl1: text-list 150 data [
                "I'm making changes to a NEW receipt that I JUST SAVED" 
                "I'm making changes to an OLD receipt that I've RELOADED"
            ] [
                resave-file-to-delete: tl1/selected
                hide-popup
            ]
            return
            button -1 "Cancel" [
                resave-file-to-delete: copy "" 
                hide-popup
            ]
        ]
        if resave-file-to-delete = "" [
            resaving: false
            return
        ]
        if resave-file-to-delete = trim/lines {
            I'm making changes to a NEW receipt that I JUST SAVED
        }  [
            the-file-to-delete: saved-file
        ]
        if resave-file-to-delete = trim/lines {
            I'm making changes to an OLD receipt that I've RELOADED
        } [
            the-file-to-delete: loaded-receipt
        ]
        if not question to-string the-file-to-delete [return]
        write %./receipts/deleted--backup.txt read %./receipts/deleted.txt
        write/append %./receipts/deleted.txt rejoin [
            newline newline newline
            to-string the-file-to-delete
            newline newline
            read the-file-to-delete
        ]
        delete the-file-to-delete
        alert "Original receipt has been deleted, and new receipt saved."
        resaving: false
    ]
    if true = question "Print receipt?" [print-receipt]
    saved-data: mold copy pos-table/data
    write/append to-file saved-file: copy rejoin [
        %./receipts/
        now/date "_"
        replace/all copy form now/time ":" "-"
        "+" userpass/1 
        ".txt"
    ] saved-data
    splash compose [
        size: 300x100
        color: sky
        text: (rejoin [{^/      *** SAVED ***^/^/      } saved-file {^/}])
        font: ctx-rebgui/widgets/default-font
    ]
    wait 1
    unview
    allow-save: false
    if true = question "Clear and begin new receipt?" [clear-new]
]
load-receipt: does [
    if error? try [
        loaded-receipt: to-file request-file/file/filter %./receipts/
            ".txt" "*.txt"
    ] [
        alert "Error selecting file"
        return
    ]
    if find form loaded-receipt "deleted" [
        alert "Improper file selection" 
        return
    ]
    if error? try [loaded-receipt-data: load loaded-receipt] [
        alert "Error loading data"
        return
    ]
    insert clear pos-table/data loaded-receipt-data
    pos-table/redraw
    calculate-totals
    allow-save: false
]
search-receipts: does [
    search-word: copy request-value/title "Search word:" "Search"
    ; if search-word = none [return]
    found-files: copy []
    foreach file read %./receipts/ [
        if find (read join %./receipts/ file) search-word [
            if (%.txt = suffix? file) and (file <> %deleted.txt) [
                append found-files file
            ]
        ]
    ]
    if empty? found-files [alert "None found" return]
    found-file: request-list "Pick a file to open" found-files
    if found-file = none [return]
    insert clear pos-table/data (
        load loaded-receipt: copy to-file join %./receipts/ found-file
    )
    pos-table/redraw
    calculate-totals
    allow-save: false
]
clear-new: does [
    if allow-save = true [
        unless (true = question "Erase without saving?") [return]
    ]
    foreach item [barcode f1 f2 f3 subtotal-f tax-f total-f] [
        do rejoin [{clear } item {/text show } item]
    ]
    clear head pos-table/data
    pos-table/redraw
    allow-save: true
]
change-appearance: does [
    request-ui
    if true = question "Restart now with new scheme?" [
        if allow-save = true [
            if false = question "Quit without saving?" [return]
        ]
        write %scheme_has_changed ""
        launch %pos.r  ; EDIT
        quit
    ]
]
title-text: "Point of Sale System"
if system/version/4 = 3 [
    user32.dll: load/library %user32.dll
    get-tb-focus: make routine! [return: [int]] user32.dll "GetFocus"
    set-caption: make routine! [
        hwnd [int] 
        a [string!]  
        return: [int]
    ] user32.dll "SetWindowTextA"
    show-old: :show
    show: func [face] [
        show-old [face]
        hwnd: get-tb-focus
        set-caption hwnd title-text
    ]
]
allow-save: true
resaving: false
saved-file: ""
loaded-receipt: ""
screen-size: system/view/screen-face/size
cell-width: to-integer (screen-size/1) / (ctx-rebgui/sizes/cell)
cell-height: to-integer (screen-size/2) / (ctx-rebgui/sizes/cell)
table-size: as-pair cell-width (to-integer cell-height / 2.5)
current-margin: ctx-rebgui/sizes/margin
top-left: as-pair negate current-margin negate current-margin
display/maximize/close "POS" [
    at top-left #L main-menu: menu data [
        "File" [
            "     Print      " [print-receipt]
            "     Save       " [save-receipt]
            "     Load       " [load-receipt]
            "     Search     " [search-receipts]
        ]
        "Options" [
            "     Appearance     " [change-appearance]
        ] 
        "About" [
            "     Info     " [
                alert trim/lines {
                    Point of Sale System. 
                    Copyright  2010 Nick Antonaccio. 
                    All rights reserved.
                }
            ]
        ]
    ]
    return
    barcode: field #LW tip "Bar Code" [
        parts: parse/all copy barcode/text " "
        set-text f1 parts/1
        set-text f2 parts/2
        set-text f3 parts/3
        clear barcode/text
        add-new-item
    ]
    return
    f1: field tip "Item" 
    f2: field tip "Booth" 
    f3: field tip "Price (do NOT include '$' sign)" [
        add-new-item 
        set-focus add-button
    ]
    add-button: button -1 "Add Item" [
        add-new-item 
        set-focus add-button
    ]
    button -1 #OX "Delete Selected Item" [
        remove/part find pos-table/data pos-table/selected 3
        pos-table/redraw
        calculate-totals
    ]
    return
    pos-table: table (table-size) #LWH options [
        "Description" center .6
        "Booth" center .2
        "Price" center .2
    ] data []
    reverse
    panel sky #XY data [
        after 2
        text 20 "Subtotal:" subtotal-f: field 
        text 20 "     Tax:" tax-f: field
        text 20 "   TOTAL:" total-f: field
    ]
    reverse
    button -1 #XY "Lock" [do login]
    button -1 #XY "New" [clear-new]
    button -1 #XY "SAVE and PRINT" [save-receipt]
    do [set-focus barcode]
] [question "Really Close?"]
do-events


REBOL [title: "Etsy"]
do/args http://reb4.me/r/etsy.r context [
	Consumer-Key: #<type_your_key_here>
	Consumer-Secret: #<typ_your_secret_here>
	User-Store: %etsyusers
	Scope: [listings_w listings_r listings_d]  ; edit permissions here
	Sandbox: false                      ; change to true when approved
]
coupon-text: {
    ** SALE ** Enter the coupon code &quot;893894&quot; at checkout to
    receive 10% off your order &lt;br&gt;&lt;br&gt;
}
replace-items: does [
    found-items/text: copy {}  show found-items
    replaced-items/text: copy {}  show replaced-items
    found: copy []
    x: get in (etsy/listings []) 'results              
    for i 1 (length? x) 1 [  
        if find (get in x/:i 'description) search-text/text [ 
            insert head found-items/text copy rejoin [
                ; {"} search-text/text {" found in:  } 
                (get in x/:i 'title) newline
            ] 
            show found-items
            append found (get in x/:i 'listing_id)
            append found (get in x/:i 'description)
            append found (get in x/:i 'title)
            append found (get in x/:i 'state)
        ]
    ]
    foreach [lstngid dscrptn titl state] found [
        either state <> "active" [
            insert head replaced-items/text copy rejoin [
                titl { was NOT replaced (listing inactive)^/}
            ]
            show replaced-items
        ][
            etsy/api-call/with put rejoin [
                %listings/ lstngid
            ] [
                description: (
                    replace/all dscrptn search-text/text replace-text/text
                )
            ]
            insert head replaced-items/text copy rejoin [titl {^/}]
            show replaced-items
        ]
    ]
    ; alert "Done"
]
sale: func [add-or-remove] [
    coupon-code: copy request-text/title/default"Coupon Text:" coupon-text
    found-items/text: copy {}  show found-items
    replaced-items/text: copy {}  show replaced-items
    found: copy []
    x: get in (etsy/listings []) 'results
    focus found-items           
    for i 1 (length? x) 1 [  
        insert head found-items/text copy rejoin [
            (get in x/:i 'title) newline
        ] 
        show found-items
        append found (get in x/:i 'listing_id)
        append found (get in x/:i 'description)
        append found (get in x/:i 'title)
        append found (get in x/:i 'state)
    ]
    foreach [lstngid dscrptn titl state] found [
        either state <> "active" [
            insert head replaced-items/text copy rejoin [
                titl { was NOT replaced (listing inactive)^/}
            ]
            show replaced-items
        ][
            etsy/api-call/with put rejoin [
                %listings/ lstngid
            ] either add-or-remove = true [
                [
                    title: rejoin ["SALE-" titl]
                    description: rejoin [coupon-code dscrptn]
                ]
            ] [
                [
                    title: replace titl "SALE-" ""
                    description: replace dscrptn rejoin [coupon-code] ""
                ]
            ]
            insert head replaced-items/text copy rejoin [titl {^/}]
            show replaced-items
        ]
    ]
    focus replaced-items
    ; alert "Done"
]
create-listing: does [
    itm: request-text/title/default "Title:" "Item 100"
    desc: request-text/title/default "Description:" "Ring #100"
    prc:  to-decimal next find (
            request-text/title/default "Price:" "$19.99"
            ) "$"
    if true = request "Would you like to see a listing of category IDs?" [
        categories: etsy/api-call get %taxonomy/categories
        cat-list: copy []
        foreach category categories/results [
            append cat-list reduce [
                category/long_name category/category_id
            ]
        ]
        chosen-category: request-list "Categories" cat-list
    ]
    if unset? chosen-category [chosen-category: "69150467"]
    ctgry: request-text/title/default "Category ID:" form chosen-category
    flash "Creating item..."
    etsy/api-call/with post %/listings [
        quantity: 1 
        title: itm 
        description: desc 
        price: prc 
        category_id: ctgry 
        who_made: "i_did" 
        is_supply: "1" 
        when_made: "2010_2012" 
        shipping_template_id: "330"
    ]
    unview
    alert rejoin ["CREATED: " itm ", " desc ", " prc]
]
delete-listing: does [
    itm2del: request-text/title "Listing ID #:"
    either true = request "Really Delete?" [
        flash "Deleting..."
        etsy/api-call/with get rejoin [%listings/ itm2del] [
            method: "DELETE"]
        unview
        alert rejoin ["Item " itm2del " deleted."]
    ] [
        return
    ]
]
get-image: does [
    found: copy []
    x: get in (etsy/listings []) 'results  
    for i 1 (length? x) 1 [  
        append found (get in x/:i 'title)
        append found (get in x/:i 'listing_id)
    ]
    photo-item-id: request-list "Select Item:" found
    photo-list: etsy/api-call/with get rejoin [
        %listings/ photo-item-id "/images"] []
    either error? try [photo-id: first get in photo-list 'results] [
        alert "No photo available for that item."
        return
    ][
        photo-info: etsy/api-call/with get the-code: rejoin [
            %listings/ photo-item-id "/images/ " photo-id
        ] []
    ]
    editor either [] = the-photo: (get in photo-info 'results) [
        "none"
    ] [
        the-photo
    ]
]
etsy/as "<your-username>"
view center-face gui: layout [
    across
    text 80 right "If" 
    cond1: drop-down 100 data [
        "Title" "Description" "Listing ID" "Any Field"
    ]
    cond2: drop-down 150 data [
        "REPLACE ALL" "Contains" "Does NOT Contain" "Equals"
    ]
    cond3: field 454 "ring" return
    text 80 right "Search Text:" search-text: field 720 "ring" [
        replace-text/text: copy search-text/text show replace-text
    ] return
    text 80 right "Replace Text:" replace-text: field 720 "ring" return
    text 805 "" return
    box black 805x2 return
    text 805 "" return
    text 400 "Found Items:" text 200 "Replaced Items:" return
    found-items: area  replaced-items: area  return
    btn "List Raw Data" [editor copy get in (etsy/listings []) 'results]
    btn "Create Listing" [create-listing]
    btn "Delete Listing" [delete-listing]
    btn "Add Sale" [sale true]
    btn "Remove Sale" [sale false]
    btn "View Image" [get-image]
    btn "Replace Description" [replace-items]
]


REBOL [title: "Textual User Interface"]
; ------------------------------------------------------------------------
labels: ["First Name" "Last Name" "Favorite Color" "Address" "Phone"]
answers: copy ["" "" ["Red" "Green" "Blue" "Tan" "Black"] "" ""]
; ------------------------------------------------------------------------
; if system/build/date > 1-jan-2011 [
    newpage: copy {} loop 50 [append newpage "^/"]
; ]
if (length? labels) <> (length? answers) [
    print join newpage "'Labels and 'answers blocks must be equal length."
    halt
]
len: length? labels
lngth: 0
spaces: "    "
foreach label labels [
    if (l: length? label) > lngth [lngth: l]
]
pad: func [strng] [
    insert/dup tail str: join copy strng "" " " lngth
    join copy/part str (lngth) spaces
]
forever [
    prin newpage
    repeat i len [
        either ((answers/:i = "") or ((type? answers/:i) = block!)) [
            ans: ""
        ][
            ans: answers/:i
        ]
        prin rejoin [i ")  " pad labels/:i "|" spaces ans newline]
    ]
    prin rejoin [newline (len + 1) ")  SUBMIT"]
    choice: ask {^/^/}
    either error? try [num: to-integer choice] [] [
        either block? drop-down: answers/:num [
            print ""
            repeat i l: length? drop-down [
                prin rejoin [i ")  " pad form drop-down/:i newline]
            ]
            prin rejoin [(l + 1) ")  " pad "Other" newline]
            drop-choice: ask rejoin [{^/Select } labels/:num {:  }]
            either error? try [d-num: to-integer drop-choice] [] [
                either d-num = (l + 1) [
                    if "" <> resp: ask rejoin [
                        {^/Enter } labels/:num {:  }
                    ] [answers/:num: resp]
                ][
                    chosen: pick drop-down d-num
                    if ((chosen <> none) and (chosen <> (l + 1))) [
                        answers/:num: chosen
                    ]
                ]
            ]
        ][
            if ((num > 0) and (num <= (len + 1))) [
                either num = (len + 1) [
                    prin newpage probe answers halt  ; END ROUTINE
                ][
                    either answers/:num = "" [
                        ans: ""
                    ][
                        ans: answers/:num
                    ]
                    write clipboard:// ans
                    line: copy {}
                    loop ((length? labels/:num) + 1) [append line "-"]
                    answers/:num: ask rejoin [
                        newpage labels/:num ":  " ans "^/" line "^/^/"
                    ]
                ]
            ]
        ]
    ]
]


REBOL [title: "Find All Occurences - Without Parse"]
full-text: {asofuwbhvhfuijshbjiziuvhbwdbhfuyjnvhshgsdifud98wuhdybjnbsheuh
    dijcasbivhfuvu vhsd}
start: "fu"
end-match: "vh"
start-len: length? start
end-len: length? end-match
full-len: length? full-text
found: copy []
marker: 1
print " "
while [(full-len - marker) >= start-len] [
    ; if error? try [
        marker: start-len + index? find/only (at full-text marker) start
        end: index? find/only (at full-text marker) end-match
        append found copy/part (at full-text marker) (end - marker)
        marker: end + end-len
    ; ][break]
] 
probe found
halt


REBOL [title: "Silly Sort - First Letter Example"]
list: [
    "Banana"
    "Hotel"
    "Apple"
    "Car"
    "Orange"
    "Fox"
    "Aardvark"
    "Consequence"
    "Xylophone"
    "Decision"
]
sorted: copy []
repeat i length? list [
    stopper: false
    current: list/:i
    repeat j length? sorted [
        if (first current) <= (first sorted/:j) [
            insert at sorted j current
            stopper: true
            break
        ]
    ]
    if stopper = false [append sorted current]
]
editor sorted


REBOL [title: "Most Complete Table/Grid/List Widget Example - Minimal"]
headers: ["Numbers" "TEXT (Note Sort)" "Dates"] ; REQUIRED COLUMN LABELS
; ALL THESE ADDITIONAL SETUP PARAMETERS ARE *** OPTIONAL ***:
x: [[1 "1" 1-1-2012][11"11"1-2-2012][2"2"1-3-2012]]  ; some default data
colors: [blue black red]    ; column colors
empty-space: 235            ; size of blank GUI area to appear below grid
svv/vid-face/color: white   ; default GUI face color
gui-block: {                ; GUI layout code to appear above grid 
    h3 "RIGHT-CLICK/DRAG HEADERS TO RESIZE COLUMNS.  RESIZE WINDOW..."
    text "Click headers to sort (note that sort is DATA-TYPE SPECIFIC)."
    text "Notice Arrow Keys, PgUp/PgDn Keys, Scroll Bar, and highliting"
    text "Click any cell to edit data. Buttons load and save data to HD."
}  ; the following line automatically fits grid to resized GUI window:
insert-event-func [either event/type = 'resize [resize-fit none] [event]]
do decompress #{
789CC5584B8FDB3610BEEB570CDC43AC048AEC459302EA3ED01F904BAF860FB2
44D9CAD2A22251BB720CFFF7CEF025D2F6369BA4480DECDAA266BE797266C8A1
E1ACEFE129E7037B8037DBA14E365C148FB0723F33389ED6D110128EB01A3328
447B80D57A1D1DCCEF11A242F061DFF41970D66CE5EE01762C2F59D747FADB62
2AF2E329EA58CB720935183E5845809FBC6D595382CF031DFB2CEA0656B3DD0C
E967A964A384D93A5A9F414B6118FCE568539FE3BDE90FBD64FB888BBCD44BAC
CCA01A9A0256652EF3A4AA3983B4635F06D6CBB5D1ACAEC0AC7854995D534FA9
68F82155DC8E62ADCD9228B095068A3ECE73E69B9499B81C59BF13CFC06BF54C
16F7F913FB453A9328F269F80E46D44279AEE2B9FCE56EABD05F2FB86ACA4B98
C8458729B384B94DCA6A8CCF32CE7E485290A4AB75F09EA03EC302E6963D8165
8CD021CA94C2131EB435FEAB4698D7F00E3EC71070845234B3F2086EAA8E9543
C13C2847EBD9E832E9DF93E67F0BD7B5A0B0BCD841875A8E67FE33CEAB9CED48
34193D5948B93959518D93ADA293890E91B5B6AA192FAD81AC963BD68122131D
16850C1A21BD674F215A4C0BB16FF30EF3DEA0E5B041AC39D6AE1C14720CF740
8F1BF3A8B55CFF00CEED551CED381BD375F4C80E495F7482736BA07E4AF2BD18
1A17C93E69055663F5856917D0D850EB97F7D3F6C0DDB1328C6E691D52DFE21E
B0340B5329784AB1B0C2D2002F50DFFCE839DAD1B1BEFECA926D57BB4AD6B2AE
608DCCB7CC5A41DD88C8105B15EDF4A966CF291AC358935479C1D2366F58BA4C
8908FEA44DB918178A95D798B0B49C2E33FF01DEC224E78CF2267312D31B04A3
74466FB72848514AA34C875E2CD14C0FD5B3DAEF36716C5C643873F4515E77B0
FCE88B553443A38C537B1FB500FDD4CA5A60B5217D11934C069E1FC420C16BDA
DA97EBC9AB558D9BBD14ACFF113F2A0E2F3C30774E213B7DAB1378BF8C516C5E
9609AF1B668586A5005BF0A8FA738D466C718FD97A42AD3C95B5C4AA52B22A1F
3836F6BFCA528F1B3D161455247ECB667EF1D8FB48E2A94B8A29A34912DC518A
764C0E5DA313B461CF89860C6BFB457B082247C5DDD4A30940F3CF666657343D
C3BDAD42467B77540AC43EFDB47329387B81A5F83F72D4DF882B0568D06C063F
E7237C21BB81C1EDBDEB006EF0FA5B8B80996E65DA4A983DCCD621865625F084
6FFE85F18A49F032F92EBB3F918CAA13FBEF4A0E0AC92BC41878F2AB078ECE99
CF2D02F92E064C9DB9555DADC4AFF7E7A7D09B0EE6D2A3E4B21495D12EB584B1
B3C66F0C7BAC5443DB721C08825EC79E58F380798B851F9B21ED75EC8F021BDF
F3AE965469FDB59BDF17EFD5DF870F5A03C59719F677BAC45B031BD1E0A1E04B
660DF165904B33BB5B808DB5747E316141AF5D51EA6681C2179E02EAA5EE2F85
6B5E9E0825FB0BA51BA3D9B4E77589CE3ED0D862DCD06CB1D2BB6900FB2DF3BB
734D2B77F06668B1AF4DD38306C48991CE0F6618098E1195923FCD24C5A0CB73
F64A4E5F01CB0BF77770AD168549E16B9D739994E219B3AA97B9521EA7980C70
4AABAA9E79EA913609E683D1F1188C5D5DFF1547038A73557798A90DDBE61237
32D63E8D8885DEC38F0366CC3B150EDB6BC367E4B4E801177A796ECD8E1DEFB5
D5D72060662E6363F3394EF8EEF568D774F2DFE0EFAB48BB17B57AE9CD4B3A9D
D35B8DAEAFBFA48FAA102628E793D81912CD098EF7E47EE1619D13499043709C
22757219FC6A1E25EF04E1F3D5F4A68D792DE13059836597AC53FA87472D0475
34E8AEDBF316683FA508B53E3B80D098C5CA5A064506EB74379518715660E602
721A186DE5C3A650A99A465DC32C6666C946C80AD3A6BDBA848587565323833E
671BA97E199C164323BF3D34AAA93B81C5F86111B9B1709AA1F1D5DC0EBC1F17
FE341D47DF9A887F68D4B6E712080E78AA0F83733375ADC80C76D30CAD0BA2D2
DAA90F399E9A7A9AE14867B0270B1578231A368394A271566825B18BC106D3FF
51F758D860E78EBE75E935E9620705179323FDDB9D90F39859C1271C0EB8BDDA
EAD30CDF41C51887A9039E684EA081CB85F442941264E1DDDD86DA8B972ECAAC
B5DAB6593783E51F23DA1AA4A272F79D9B7A707AC49DF830731787876B19AEF7
A1398EE9F3DA940EFE595AF9BE609C83CA5E43A00C779BD2515FC6EF6783401F
6434A1507A9C3C33D07C7B55AAE699DE1D21266035A5EAB718B5F575E9367057
42763417037AD80337F699836666CEFA74CBC18DFBCCBEF0CFE56FB5A21006C3
84E1F492D44776A0BF4294883AB45884A6EB084896F6B62220A3F12424BC4ED7
62894B2E306F162F135F226BEA53E4DD62BB6B61B7A6EF8427D3EC85F03F5C89
1B7D15170000
}  ; APPEND ANY WIDGETS AND/OR GUI CODE TO APPEAR BELOW THE GRID, HERE:
append gui-block [
    ; REPLACE 'BTN' WITH 'KEY' TO HIDE BTNS AND STILL USE KEY SHORTCUTS.
    ; CHANGE/REMOVE BUTTONS AND/OR KEYBOARD SHORTCUTS AS NEEDED:
    text "" return
    btn "Insert (Ins)" keycode [insert] [add-line] 
    btn "Remove (Del)" #"^~" [remove-line]  
    btn "Move (CTRL+M)" #"^M" [move-line]
    btn "Grow (+)" #"+" [resize-grid 1.333]
    btn "Shrink (-)" #"-" [resize-grid .75]
    btn "Fit (CTRL+R)" #"^R" [resize-fit]
    return
    btn "Load Blocked (CTRL+O)" #"^O" [load-blocked/request %blocked.txt]
    btn "Save Blocked (CTRL+S)" #"^S" [save-blocked/request %blocked.txt]
    btn "Load Flat (CTRL+U)" #"^U" [load-flat/request %flat.txt]
    btn "Save Flat (CTRL+F)" #"^F" [save-flat/request %flat.txt]
    ;  do [load-blocked %blocked.txt]   ; LOAD ANY DEFAULT DATA FILE HERE
]
view/options center-face gui: layout gui-block [resize]


REBOL [title: "Paypal Reports"]
filename: request-file/only/file %Download.csv
lines: read/lines filename
labels: copy parse/all lines/1 ","
foreach label labels [trim label]
database: copy []
foreach line (at lines 2) [
    parsed: parse/all line ","
    append/only database parsed
]
name-index: index? find labels "Name"
names: copy {}
foreach row database [
    append names rejoin ["Name:  " (pick row name-index) newline]
]
editor names
net-index: index? find labels "Net"
amounts: copy {}
foreach row database [
    if find/only (pick row name-index) "Netflix" [
        append amounts rejoin ["Amount:  " (pick row net-index) newline]
    ]
]
editor amounts
date-index: index? find labels "Date"
sum: $0
foreach row database [
    if find/only (pick row name-index) "Netflix" [
        date: parse (pick row date-index) "/"
        month:  pick system/locale/months to-integer date/1
        reb-date: to-date rejoin [date/2 "-" month "-" date/3]
        if ((reb-date >= 1-jan-2012) and (reb-date <= 31-dec-2012)) [
            sum: sum + (to-money pick row net-index)
        ]
    ]
]
alert form sum


REBOL [title: "Simple Presenter"]
slides: [
    [
        at 0x0 box system/view/screen-face/size white [unview]
        at 20x20 h1 blue "Slide 1"
        box black 2000x2
        text "This slide takes up the full screen."
        text "Adding images is easy:"
        image logo.gif
        image stop.gif
        image info.gif
        image exclamation.gif
        text "Click anywhere on the screen for next slide..."
        box black 2000x2
    ]
    [
        at 0x0 box system/view/screen-face/size effect [
            gradient 1x1 tan brown
        ] [unview]
        at 20x20 h1 blue "Slide 2"
        box black 2000x2
        text "Gradients and color effects are easy in REBOL:"
        box effect [gradient 123.23.56 254.0.12]
        box effect [gradient blue gold/2]
        text "Click anywhere on the screen to close..."
        box black 2000x2
    ]
    [
        at 0x0 box 600x400 [unview]
        at 20x20 
        text "This screen is smaller, and as simple as can be"
        text "Click anywhere on the screen to close..."
    ]
]
foreach slide slides [
    view/options center-face layout slide 'no-title
]


REBOL [title: "Presenter"]
slides: [
    "Slide 1 - A Few Basics"  
    [
        text "By default these slides are white and full screen."
        text bold "Adding images is easy:"
        image logo.gif
        image stop.gif
        image info.gif
        image exclamation.gif
        text {
            Press the space bar, right arrow key, or left click screen
            for the next slide.  Press the left arrow key, or right
            click screen to go back to previous slide.  Press the 'X'
            key to quit...
        }
    ]
    "Slide 2 - Colors and Gradients" 
    [
        at 0x90 box as-pair system/view/screen-face/size/1 220 effect [
            gradient 1x1 tan brown
        ]
        at 20x70 text "Colors and gradient effects are easy in REBOL:"
        box effect [gradient 123.23.56 254.0.12]
        box effect [gradient blue gold/2]
        text {
            Left arrow key or right click screen to go back, 'X' key to
            Quit...
        }
    ]
    "Slide 3 - A Simple Window"
    [
        text "This slide is as simple as can be."
    ]
    "Slide 4 - Lots of Stylized Text"
    [
        across
        text "Normal"
        text "Bold" bold
        text "Italic" italic
        text "Underline" underline
        text "Bold italic underline" bold italic underline
        text "Serif style text" font-name font-serif
        text "Spaced text" font [space: 5x0]
        return
        h1 "Heading 1"
        h2 "Heading 2"
        h3 "Heading 3"
        h4 "Heading 4"
        tt "Typewriter text"
        code "Code text"
        below
        text "Big" font-size 32
        title "Centered title" 200
        across
        vtext "Normal"
        vtext "Bold" bold
        vtext "Italic" italic
        vtext "Underline" underline
        vtext "Bold italic underline" bold italic underline
        vtext "Serif style text" font-name font-serif
        vtext "Spaced text" font [space: 5x0]
        return
        vh1 "Video Heading 1"
        vh2 "Video Heading 2"
        vh3 "Video Heading 3"
        vh4 "Video Heading 3"
        label "Label"
        below
        vtext "Big" font-size 32
        banner "Banner" 200
    ]
    "Slide 5 - Live Code"
    [
        h3 "Remember, These Slides Are Live, Fully Functional GUIs!"
        box red 500x2
        bar: progress
        slider 200x16 [bar/data: value show bar]
        area "Type here"
        drop-down 200 data reduce [now now - 5 now - 10]
        across 
        toggle "Click" "Here" [alert form value]
        rotary "Click" "Again" "And Again" [alert form value]
        choice "Choose" "Item 1" "Item 2" "Item 3" [alert form value]
        radio radio radio
        led
        arrow
        return
    ]
]
indx: 1
forever [
    slide: compose [
        size system/view/screen-face/size
        backdrop white [
            if indx < ((length? slides) / 2) [indx: indx + 1 unview]
        ] [
            if indx > 1 [indx: indx - 1 unview]
        ]
        at 20x20 h1 blue (pick slides (indx * 2 - 1))
        box black as-pair (system/view/screen-face/size/1 - 40) 2
        (pick slides (indx * 2))
        box black as-pair (system/view/screen-face/size/1 - 40) 2
        key #"x" [quit]
        key #" " [
            if indx < ((length? slides) / 2) [indx: indx + 1 unview]
        ]
        key keycode [right] [
            if indx < ((length? slides) / 2) [indx: indx + 1 unview]
        ]
        key keycode [left] [
            if indx > 1 [indx: indx - 1 unview]
        ]
    ]
    slide: layout slide
    view/options center-face slide 'no-title
]


REBOL [title: "Minimal Bar Graph Example"]
if not exists? %q-plot.r [write %q-plot.r read http://re-bol.com/q-plot.r]
do %q-plot.r
view quick-plot [
    600x400
    bars [5 3 8 2 10 3 4 9 5 7]
]


REBOL [title: "Another Bar Graph Example"]
if not exists? %q-plot.r [write %q-plot.r read http://re-bol.com/q-plot.r]
do %q-plot.r
view center-face quick-plot [
    600x300
    y-min 0                           ; minimum value to display on y axis
    fill-pen blue                     ; set fill color
    pen green                         ; set outline and text color
    bar-width 80                      ; set bar width
    bars [5 3 8 2 10 3 4 9 5 7]
    pen black                         ; set outline and text color
    label "Fat Bars"                  ; optionally add labels
    y-axis 11                          
    x-axis 10
]


REBOL [title: "Exploded Pie Chart"]
if not exists? %q-plot.r [write %q-plot.r read http://re-bol.com/q-plot.r]
do %q-plot.r
view center-face quick-plot [
    400x400
    pie [10 3 6 1 8] labels [A B C D E] explode [3 5]
    title "Exploded Sections C and E" style vh2
]


REBOL [title: "Simple Line Graph Example"]
if not exists? %q-plot.r [write %q-plot.r read http://re-bol.com/q-plot.r]
do %q-plot.r
view quick-plot [
    400x400
    line [1 2 4 8 16 32 64 128 256]
]


REBOL [title: "Another Line Graph Example"]
if not exists? %q-plot.r [write %q-plot.r read http://re-bol.com/q-plot.r]
do %q-plot.r
my-block: copy [2]
loop 10 [append my-block (2 * last my-block)]
option-font: make face/font [
    size: 30
    style: [italic bold underline]
    name: font-serif
]
view center-face quick-plot [
    500x500
    scale linear 
    line [(data: copy my-block)]
    title style vh1 "Linear scale"
    x-axis 7 border
    y-axis 7 border
    x-grid 7
    y-grid 7
    text font option-font "Formatted Text" color red up 50 over 40
]


REBOL [title: "Paypal Reports Charts"]
transactions: copy []
saoud: copy []
dates: copy []
foreach line at read/lines http://re-bol.com/Download.csv 2 [
    row: parse/all line ","
    append transactions to-integer row/8
    if find row/4 "Saoud" [
        append saoud to-integer row/8
        append dates replace row/1 "/2012" ""
    ]
]
if not exists? %q-plot.r [write %q-plot.r read http://re-bol.com/q-plot.r]
do %q-plot.r
view quick-plot [
    594x400
    bars [(data: copy transactions)]
    label "All Paypal Transactions"
]
view center-face quick-plot [
    495x530
    pen blue
    pie [(data: copy saoud)] labels [(data: copy dates)] explode [1 2 3]
    title "Saoud" style vh2     
]


REBOL [title: "Multi-Plots"]
if not exists? %q-plot.r [write %q-plot.r read http://re-bol.com/q-plot.r]
do %q-plot.r
m-plots: multi-plot/across 594x200 [ 
    [
        title "2 to a Power"
        pen green 
        line [0 2 4 8 16 32 64 128] 
    ]
    [
        title "Rizing"
        pen white
        line [0 5 10 15 20 25] 
    ]
    [
        title "Falling"
        pen blue    
        line [25 20 15 10 5 0] 
    ] 
]
view m-plots


REBOL [title: "Switching Plots"]
if not exists? %q-plot.r [write %q-plot.r read http://re-bol.com/q-plot.r]
do %q-plot.r    
window: layout [
    vh2 "Switching Plots"
    guide 
    pad 20
    button "Sine Wave"   [graph/pane: plot1 show graph]
    button "Parabola"    [graph/pane: plot2 show graph]
    button "Cubic Curve" [graph/pane: plot3 show graph]
    return
    box 2x204 blue
    return
    graph: box 354x204 coal
]
data1: copy []
data2: copy []
data3: copy []
for i -400 400 .5 [
    append data1 sine i
    append data2 (i * i)
    append data3 (i ** 3)
]
graph-size: 350x200
plot1: quick-plot [
    (graph-size)
    line [(data1)]
    title "Sine Wave"
]
plot2: quick-plot [
    (graph-size)
    line [(data2)]
    title "Parabola"
]
plot3: quick-plot [
    (graph-size)
    line [(data3)]
    title "Cubic Function"
]
plot1/offset: 2x2
plot2/offset: 2x2
plot3/offset: 2x2
graph/pane: plot1
view window


REBOL [title: "Simple Encrypt"]
view layout [
    across
    f1: field 
    btn "Select File" [f1/text: request-file/only  show f1]
    return
    f2: field "(enter password)"
    btn "Encrypt" [
        save request-file/only/save/title/file 
            "Enter encrypted file save name:" ""
            to-file f1/text
            to-binary encloak read to-file f1/text f2/text
        alert "Saved"
    ]
    btn "Decrypt" [editor to-string decloak load to-file f1/text f2/text]
]


REBOL [title: "Encryption" author: "Carl Sassenrath"]
request-key: has [pass] [
    pass: request-text/title "Enter a pass-phrase:"
    if pass [checksum/secure pass]
]
crypt: func [
    "Encrypts or decrypts with compression. Returns result."
    data [any-string!] "Data to encrypt or decrypt"
    akey [binary!] "The encryption key"
    /decrypt "Decrypt the data"
    /binary "Produce binary decryption result."
    /local port
][
    port: open [
        scheme: 'crypt
        direction: pick [encrypt decrypt] not decrypt
        key: akey
        padding: true
    ]
    if not decrypt [data: compress data]
    insert port data
    update port
    data: copy port
    close port
    if decrypt [
        data: decompress data
        if not binary [data: to-string data]
    ]
    data
]
if none? op: request ["Select action:" "Encrypt" "Decrypt" "Cancel"][quit]
action: pick ["Encrypt" "Decrypt"] op
if none? files: request-file/title join "Select Files to " action action [
    quit
]
if none? key: request-key [quit]
foreach file files [
    data: read/binary file
    data: either op [crypt data key][crypt/decrypt/binary data key] 
    write/binary file data
]
alert join "File has been " pick ["encrypted." "decrypted."] op


REBOL [title: "Send Encrypted Email" author: "Carl Sassenrath"]
crypt: func [
    "Encrypts or decrypts with compression. Returns result."
    data [any-string!] "Data to encrypt or decrypt"
    akey [binary!] "The encryption key"
    /decrypt "Decrypt the data"
    /binary "Produce binary decryption result."
    /local port
][
    port: open [
        scheme: 'crypt
        direction: pick [encrypt decrypt] not decrypt
        key: akey
        padding: true
    ]
    if not decrypt [data: compress data]
    insert port data
    update port
    data: copy port
    close port
    if decrypt [
        data: decompress data
        if not binary [data: to-string data]
    ]
    data
]
view layout [
    style lab label right 80x24
    across space 0x4
    vh2 "Send Encrypted Email File:" return
    lab "To:"      f-to: field return
    lab "Subject:" f-sub: field return
    lab "Key:"     f-key: field hide return
    lab "File:"    f-file: text 200x24 white black middle
        "click to pick" [f-file/text: request-file/keep] return
    lab
    button "Send" [unview]
    button "Close" [quit]
]
dest: to-email f-to/data
file: to-file f-file/data
key: checksum/secure f-key/data
subject: f-sub/data
msg: enbase/base crypt read/binary file 64
send/subject email msg subject


REBOL [title: "Decrypt Secure Email" author: "Carl Sassenrath"]
crypt: func [
    "Encrypts or decrypts with compression. Returns result."
    data [any-string!] "Data to encrypt or decrypt"
    akey [binary!] "The encryption key"
    /decrypt "Decrypt the data"
    /binary "Produce binary decryption result."
    /local port
][
    port: open [
        scheme: 'crypt
        direction: pick [encrypt decrypt] not decrypt
        key: akey
        padding: true
    ]
    if not decrypt [data: compress data]
    insert port data
    update port
    data: copy port
    close port
    if decrypt [
        data: decompress data
        if not binary [data: to-string data]
    ]
    data
]
view layout [
    style lab label right 80x24
    across space 0x4
    vh2 "Decrypt Email File:" return
    lab "Key:"     f-key: field hide return
    lab "File:"    f-file: text 200x24 white black middle
        "click to pick" [f-file/text: request-file/keep] return
    lab "Data:"    f-data: area return
    lab
    button "Decrypt" [unview]
    button "Close" [quit]
]
file: to-file f-file/data
key: checksum/secure f-key/data
data: f-data/data
data: debase/base data 64
write/binary file crypt/decrypt/binary data key


REBOL [title: "Request-Time Simple"]
request-time: func [/local the-time] [
     view center-face layout [
         across
         text "Hour:" h: drop-down 50 "1" "2" "3" "4" "5" "6" "7" "8" "9"
             "10" "11" "12"
         text "Min:" m: drop-down 50 "1" "2" "3" "4" "5" "6" "7" "8" 
              "9" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20"
              "21" "22" "23" "24" "25" "26" "27" "28" "29" "30" "31" "32"
              "33" "34" "35" "36" "37" "38" "39" "40" "41" "42" "43" "44"
              "45" "46" "47" "48" "49" "50" "51" "52" "53" "54" "55" "56"
              "57" "58" "59" "60"
         p: drop-down 50 "am" "pm"
         btn "Ok" [
             the-time: to-time rejoin [h/text ":" m/text p/text] unview
         ]
         return text " "  return text " "
     ]
     return the-time
]
x: request-time
probe x
halt


REBOL [title: "Request-Time"]  code: {
hours: [
    132x72 12 159x74 1 186x102 2 199x134 3 180x163 4 165x184 5 131x192 6
    103x186 7 79x168 8 71x133 9 77x101 10 103x78 11
]
minutes: [
    185x37 5 225x76 10 240x132 15 228x188 20 188x229 25 127x244 30 73x231
    35 25x187 40 13x136 45 23x77 50 66x39 55 130x22 0
]
the-time: 12:00am
view center-face layout/tight [
    across
    g: at image load (to-binary decompress small-picture) feel [
        engage: func [f a e] [
            if a = 'down [
                foreach location (extract hours 2) [
                    if within? e/offset location 20x20 [
                        h/text: form select hours location show h
                        b1/offset: location show b1
                    ]
                ]
                foreach location (extract minutes 2) [
                    if within? e/offset location 20x20 [
                        m/text: form select minutes location show m
                        b2/offset: location show b2
                    ]
                ]
            ]
        ]
    ] 
    return
    text "Hour:" h: field 30 "12"
    text "Minute:" m: field 30 "00"
    p: drop-down 50 "am" "pm"
    btn "Done" [probe the-time: to-time rejoin [h/text ":" m/text p/text]]
    return text " "  return text " " ; space for dropdown
    at -100x-100 b1: box red 20x20 "h"
    at -100x-100 b2: box blue 20x20 "m"
]
probe the-time
}  small-picture: 64#{
eJwVmXtcy/8Xx9+f3e/7bF0s3dZ9XbAuqISte7m0LmoS1gW5lFUuhfTZam2ly1IR
wipSKYaQ+7rKfXLLfSUU+X6TW8T8vr/z9/nnnMfj9TrP1+MEhQR6esVPhVjQD/D/
giAIhUKh0WgMBoPFYnE4HB6PJxAIRCKRRCKRyWQKhU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wenUB/6aEzJWd2YLXvnnembqTQd1eH9WMWFAToexlGW
Nyh80o5jKnxtBz1sjyArVJykJDuXpCXBge61DGABB+GYgQSGOQRhVRKZtfOz14w+
pSLqyJwdYoDWaYL0im4USozMKzp3rmKBHXPpSKjwZjqDuU3DEEAEqqgIeqielj63
viTe+EvVjbh3XiIBYp+lQ1nNAVMiql58WjFyYMBsjde9xqA0lAoQNZIvbcdfOf9x
V6GnDfvejcf/iBgwmL58xs4vx1//GT9/Tf9nxnQE7aKDDNo0uHlcqUGzDuve1k7b
yc2zcRkgRrZ1GF/l5rs3D1Az2jot9iTyAJjzPxqem1UYNAAA
}
do code


REBOL [title: "File-Request"]
do file-request: [
    y: copy [] append y copy read %. insert head y "../"
    x: copy []  my-file: %none  sort-order: false
    sort-column: func [field] [
        either sort-order: not sort-order [
            sort/compare x func [a b] [(at a field) > (at b field)]
        ] [
            sort/compare x func [a b] [(at a field) < (at b field)]
        ]  
        show li
    ]
    foreach i y [
        append/only x reduce [i (size? to-file i) (modified? to-file i)]
    ]
    slider-pos: 0  slider-val: 0
    view center-face layout [
        across  space 0x0  backdrop white
        h2 460 coal "File:" [sort-column 1]
        h2 90 coal "Size:" [sort-column 2]
        h2 160 coal "Modified:" [sort-column 3] return
        li: list 750x360 [
            across  space 0x0
            text 460 bold [
                if face/text [
                    either #"/" = last (new-dir: copy face/text) [
                        unless %/ = clean-path to-file new-dir [
                            change-dir to-file new-dir do file-request
                        ]
                    ] [
                        my-file: join what-dir to-file face/text unview
                    ]
                ]
            ]
            text 90 purple 
            text 160 red italic
            return box 0.0.240 750x1
        ] supply [
            count: count + slider-pos - slider-val
            if none? q: pick x count [face/text: none exit]
            face/text: pick q index
        ]
	    scroller 16x360 [
	        lst-cnt: to-integer li/size/y / li/subface/size/y
		    value: to-integer value * max 0 (length? y) - lst-cnt
		    if slider-pos <> value [slider-pos: value show li]
	    ]
        return
        btn "Cancel" [unview]
        h3 700 right 0.0.120 form what-dir
    ]
]
probe my-file  halt


REBOL [title: "Simplest Bar Chart Maker"]
data: [12 3 9 38 1 23 18]
gui: copy [backdrop white]
foreach val data [append gui compose [box blue (as-pair (val * 10) 40)]]
view layout gui


REBOL [title: "Simple Bar Chart Maker"]
data: [12 3 9 38 1 23 18]
labels: [Jan Feb Mar Apr May Jun Jul]
gui: copy [backdrop white across]
repeat i length? data [
    append gui compose [
        text bold 30 (form labels/:i)
        button random white (as-pair (data/:i * 12) 40) (mold data/:i)
        return
    ]
]
view layout gui


REBOL [title: "Simple Bar Chart Maker"]
data: [12 3 9 38 1 23 18]
labels: ["Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul"]
height: 11
width: 50
gui: copy [
    backdrop effect [
        gradient 1x1 180.255.255 255.255.100 grid 10x10 220.220.189
    ]
    across
]
foreach val reverse data [
    append gui compose [
        button random white (as-pair width (val * height))
    ]
]
chart: to-image layout gui
gui2: [
    backdrop white
    style txt text bold (width)
    tabs 20
    across image (chart) effect [rotate 180] return tab
] 
foreach label labels [append gui2 compose [txt (label)]]
view center-face layout gui2


REBOL [title: "Time Clock"]
unless exists? %employees [write %employees {"John Smith" "(Add New...)"}]
cur-employee: copy ""
view center-face layout [
    tl1: text-list 400x400 data sort load %employees [
        cur-employee: value
        if cur-employee = "(Add New...)" [
            write/append %employees mold trim request-text/title "Name:"
            tl1/data: sort load %employees show tl1
        ]
    ]
    key #"^~" [
        del-emp: copy to-string tl1/picked
        temp-emp: sort load %employees
        if true = request/confirm rejoin ["REMOVE " del-emp "?"] [
            new-list: head remove/part find temp-emp del-emp 1
            save %employees new-list
            tl1/data: sort load %employees show tl1
            alert rejoin [del-emp " removed."]
        ]
    ]
    btn "Clock IN/OUT" [
        if ((cur-employee = "") or (cur-employee = "(Add New...)")) [
            alert "You must select your name." return
        ]
        record: rejoin [
            newline {[} mold cur-employee { "} mold now {"]}
        ]
        either true = request/confirm rejoin [
            record " -- IS YOUR NAME AND THE TIME CORRECT?"
        ] [
            make-dir %./clock_history/
            write rejoin [
                %./clock_history/ 
                replace/all replace form now "/" "--" ":" "_"
            ] read %time_sheet.txt
            write/append %time_sheet.txt record
            alert rejoin [
                uppercase copy cur-employee ", YOUR TIME IS LOGGED."
            ]
        ] [
            alert "CANCELED"
            return
        ]
    ]
]


REBOL [title: "Payroll Report"]
timeclock-start-date: request-date
timeclock-end-date: request-date
totals: copy ""
names: load %employees
log: load %time_sheet.txt
foreach name names [
    if name <> "(Add New...)" [
        times: copy reduce [name]
        foreach record log [
            if name = log-name: record/1 [
                date-time: parse record/2 "/"
                log-date: to-date date-time/1
                log-time: to-time first parse date-time/2 "-"
                if (
                    (log-date >= timeclock-start-date) and 
                    (log-date <= timeclock-end-date)
                ) [
                    append times log-date
                    append times log-time
                ] 
            ]
        ]
        append totals rejoin [name ":" newline]
        total-hours: 0
        foreach [in-date in-time out-date out-time] (at times 2) [
            append totals rejoin [
                newline 
                "    in: " in-date ", " in-time 
                "  out: " out-date ", " out-time "    "
            ]
            if error? try [
                total-hours: total-hours + (out-time - in-time)
            ] [
                alert rejoin [
                    "Missing login or Missing logout: " name
                ]
            ]
        ]
        append totals rejoin [
            newline newline
            "    TOTAL HOURS: " total-hours
            newline newline newline
        ]
    ]
]
write filename: copy rejoin [
    %timeclock_report-- timeclock-start-date 
    "_to_" timeclock-end-date ".txt"
] totals
call/show rejoin ["notepad " to-local-file filename]


REBOL [title: "Florek Inventory"]
attempt [do load-thru http://re-bol.com/e]
tt: "Florek Inventory"
user32.dll: load/library %user32.dll
gf: make routine![return:[int]]user32.dll"GetFocus"
sc: make routine![hw[int]a[string!]return:[int]]user32.dll"SetWindowTextA"
so: :show show: func[face][so[face]hw: gf sc hw tt]
make-dir %/c/florek-inventory/
datafile: %/c/florek-inventory/florek_mv_inventory.csv
write/append datafile ""
prcnt: .625
scanmode: true
roundmode: false
backup-data3: func [msg] [
    write (
        to-file bak-file: replace form datafile "_mv_inventory" rejoin [
            "_mv_inventory-backup--"
            now/date "_"
            replace/all form now/time ":" "-"
        ]
    ) read datafile
    if msg = "msg" [alert (join "Data has been backed up to " bak-file)]
]
check-errors-f2: does [
    if (
            (f2/text = "0.0") or 
            (f2/text = "") or 
            (error? try [to-decimal f2/text])
    ) [
        alert {
            *** ERROR: Enter a decimal in cost field 
            (set mode to 'key' if using keyboard).
        }
        focus f2 show f2
        return 0
    ]
    return 1
]
check-errors-f3: does [
    if ((f3/text = "") or (error? try [to-integer f3/text])) [
        alert "*** ERROR: Enter an integer in quantity field." 
        focus f3 show f3
        return 0
    ]
    return 1
]
enter-item: does [
    if check-errors-f2 = 0 [return]
    if check-errors-f3 = 0 [return]
    backup-data3 ""
    write/append datafile rejoin [
        mold f1/text " | "  mold f2/text " | "  
        mold f3/text " | "  mold f4/text " | " 
        mold {} " | " mold {} " | " mold {} newline
    ]
    request/timeout/ok "Done" 00:00:01
    set-face f1 ""
    set-face f2 ".65"
    set-face f3 ""
    set-face f4 ""    
    focus f1
]
view-data: does [
    backup-data3 ""
    total: 0
    inv: read/lines datafile
    if error? try [
        foreach line inv [
            ln: parse line "|"
            line-total: (to-decimal ln/3) * (to-decimal ln/2)
            ; probe line-total
            total: total + line-total
        ]
        ; probe total
        alert join "Total Inventory: $" total 
    ] [
        alert {
            ** ERROR: Improperly formed data in database.  
            Check each line.
        }
    ]
    editor datafile
]
calc-percent: does [
    if error? try [
        if scanmode [f2/text: calculate-barcode-price f2/text show f2]
        f2/text: form (prcnt * (to-decimal f2/text))
        if roundmode [f2/text: form (round/to (to-decimal f2/text) .01)]
        show f2
    ] [alert "*** ERROR: Enter a decimal in cost field."]
]
set-percent: does [
    if error? try [
        prcnt: to-decimal request-text/title/default
            "Default Percent:" form prcnt
    ] [alert "*** ERROR: Enter a decimal."]
]
scan-mode: does [
    scanmode: not scanmode
    either scanmode [
        b2/text: "Mode: Scan"
    ] [
        b2/text: "Mode: Key"
    ]
    show b2
]
round-mode: does [
    roundmode: not roundmode
    either roundmode [
        b1/text: "Round: On"
    ] [
        b1/text: "Round: Off"
    ]
    show b1
]
calculate-barcode-price: does [
    scanned-price: to-integer (trim/all copy (at copy f2/text 8))
    final-price: rejoin [
        to-string to-integer((scanned-price -(scanned-price // 100))/ 100)
        "."
        either (scanned-price // 100) < 10 [
            rejoin ["0" scanned-price // 100]
        ] [
            scanned-price // 100
        ]
    ]
    final-price
]
menu: [
    "Options" []
    "_________________________^/" []
    "View Data" [view-data]
    "Backup" [backup-data3 "msg"]
    "_________________________^/" []
    "Quit" [quit]
]
foreach i (at menu 3) [unless find i "____" [insert head i "     "]]
menu-color: 235.240.245  svv/vid-face/color: 253.253.253
; backup-data3 ""
; insert-event-func[either event/type = 'close[backup-data3 "msg"][event]]
view/options center-face layout [
    size 240x400
    ; menu:
    across  origin 0x0  space 0x0  box menu-color 8x20
    choice 190x20 left menu-color data (extract menu 2) with [
        para: [indent: 4x0]  colors: reduce [menu-color 215.220.225]
        font: [style: none  shadow: none  colors: [0.0.0]]  edge: none
    ] [do select menu value  face/text: face/texts/1  show face]
    box menu-color 500x20  origin 20x40  space 10x10  below
    ; /menu
    across
    ; btn ".60" [set-face f2 ".60"]
    below
    text "Barcode:"
    f1: field
    text "Cost"
    f2: field ".65" [calc-percent check-errors-f2]
    across 
    btn "%" #"^x" [set-percent]
    b1: btn "Round: Off" [round-mode]
    b2: btn "Mode: Scan" [scan-mode]  
    below
    text "Quantity:"
    f3: field [check-errors-f3]
    text "Description:"
    f4: field
    text 100 ""
    across
    btn 95 "Enter [CTRL+Z]" #"^Z" [enter-item]
    btn 95 "View Data" [view-data]
    do [focus f1] 
] [resize]


REBOL [title: "Calculator"]
view layout [
    origin 0  space 0x0  across
    style btn btn 50x50 [append f/text face/text  show f]
    f: field 200x40 font-size 20 return
    btn "1"  btn "2"  btn "3"  btn " + "  return
    btn "4"  btn "5"  btn "6"  btn " - "  return
    btn "7"  btn "8"  btn "9"  btn " * "  return
    btn "0"  btn "."  btn " / "   btn "=" [
        attempt [f/text: form do f/text  show f]
    ]
]


REBOL [title: "Currency Rate Conversion Calculator"]
view center-face layout [
    origin 0  space 0x0  across
    f: field 200x40 font-size 20
    return
    style btn btn 50x50 [append f/text face/text  show f]
    btn "1"  btn "2"  btn "3"  btn " + "  return
    btn "4"  btn "5"  btn "6"  btn " - "  return
    btn "7"  btn "8"  btn "9"  btn " * "  return
    btn "0"  btn "."  btn " / "   btn "=" [
        attempt [f/text: form do f/text  show f]
    ] return
    btn 200x35 "Convert" [
        x: copy []
        html: read http://www.x-rates.com/table/?from=USD&amount=1.00
        html: find html "src='/themes/bootstrap/images/xrates_sm_tm.png'"
        parse html [
            any [
                thru {from=USD} copy link to {</a>} (append x link)
            ] to end 
        ]
        rates: copy []
        foreach rate x [
            parse rate [thru {to=} copy c to {'>}]
            parse rate [thru {'>} copy v to end]
            if not error? try [to-integer v] [append rates reduce [c v]]
        ]  
        currency: request-list "Select Currency:" extract rates 2
        rate: to-decimal select rates currency
        attempt [alert rejoin [currency ": " (rate * to-decimal f/text)]]
    ]
]


REBOL [title: "Minimal Cash Register"]
view gui: layout [
    style fld field 80
    across
    text "Cashier:"   cashier: fld 
    text "Item:"      item: fld 
    text "Price:"     price: fld [
        if error? try [to-money price/text] [alert "Price error" return]
        append a/text reduce [mold item/text "    " price/text newline]
        item/text: copy "" price/text: copy ""
        sum: 0
        foreach [item price] load a/text [sum: sum + to-money price]
        subtotal/text: form sum
        tax/text: form sum * .06
        total/text: form sum * 1.06 
        focus item
        show gui
    ]
    return
    a: area 600x300
    return
    text "Subtotal:"   subtotal: fld 
    text "Tax:"        tax: fld 
    text "Total:"      total: fld
    btn "Save" [
        items: replace/all (mold load a/text) newline " "
        write/append %sales.txt rejoin [
            items newline cashier/text newline now/date newline
        ]
        clear-fields gui
        a/text: copy ""             
        show gui             
    ]
]

REBOL [title: "Daily Total"]
sales: read/lines %sales.txt
sum: $0
foreach [items cashier date] sales [
    if now/date = to-date date [
        foreach [item price] load items [
            sum: sum + to-money price
        ]
    ]
]
alert rejoin ["Total sales today: " sum]

REBOL [title: "Cashier Report"]
report-date: request-date
report-cashier: request-text/title "Cashier:" 
sales: read/lines %sales.txt
sum: $0
foreach [items cashier date] sales [
    if ((report-cashier = cashier) and (report-date = to-date date)) [
        foreach [item price] load items [
            sum: sum + to-money price
        ]
    ]
]
alert rejoin ["Total for " report-cashier " on " report-date ": " sum]


REBOL [title: "Simple POS"]
make-dir %./receipts/
make-dir %./inventory/
make-dir %./users/
write/append %./inventory/sales.txt ""
; Here's some sample data to use for testing the program.
; Edit the printed %header.txt file.  Log in to the program using
; "user"/"user" as username/password.  Enter "11111111" and "22222222"
; as bar code items.
; --------------------------------------------------------------------
write/binary %./users/users compress trim {"user" "user" "" ""}
save %./inventory/inventory.txt [
    ; barcode description price taxable cost date qty (8 blank fields)
    "11111111" "Item 1" $1.00 "y" $5.00 "24-jun-2011" 40 
    "" "" "" "" "" "" "" ""
    "22222222" "Item 2" $1.00 "y" $.50  "23-jun-2011" 999 
    "" "" "" "" "" "" "" ""
]
write %header.txt rejoin [
    "Company Name" newline
    "1234 Street Road" newline
    "Townsville, PA  98765" newline
    "800-833-7273"
]
; --------------------------------------------------------------------
users: load decompress read/binary %./users/users
if not find users user: request-pass [alert "Incorrect Login" quit]
database: load %./inventory/inventory.txt
divider: "  |  "
blank-line: 
    "___________________________________________________________________"
pad: func [strng lngth] [
    insert/dup tail strng " " lngth
    copy/part strng lngth 
]
display-qty: does [
    if error? try [idx: index? find database f1/text] [
        alert "barcode error"
        focus f1 return
    ]
    qty: pick database (idx + 6)
    alert join "Quantity: " qty
]
submit: does [
    either f1/text <> "" [
        if error? try [idx: index? find database f1/text] [
            alert "barcode error"
            focus f1 return
        ]
        item: pick database (idx + 1)
        price: pick database (idx + 2)
        taxable: pick database (idx + 3)
        f2/text: copy form item
        f3/text: copy form price
    ] [
        if ((f2/text = "") or 
        (f3/text = "") or 
        (error? try [to-money f3/text])) [
            alert "Data Entry Error" 
            focus f1 return
        ]
        item: f2/text
        price: f3/text
        taxable: either true = request "Taxable?" ["y"] ["n"]
    ]
    insert head a1/text rejoin [
        (pad form item 25) divider
        (pad form f1/text 15) divider 
        (pad form price 10) divider
        taxable newline
    ]
    recalculate-totals
    focus f1
    show gui
]
recalculate-totals: does [
    my-items: copy []
    my-lines: parse/all (copy a1/text) "^/"
    f7/text: copy form length? my-lines
    foreach line my-lines [
        current-line: parse/all line "|"
        foreach item current-line [
            append my-items trim item
        ]
    ]
    subtotal: $0
    tax: 0
    total: $0
    foreach [item barcode price taxable] my-items [
        subtotal: subtotal + to-decimal (replace form price "$" "")
        if taxable = "y" [
            tax: tax + ((to-decimal replace form price "$" "") * .06)
        ]
        total: to-money subtotal + tax
    ]
    f4/text: form subtotal
    f5/text: form tax
    f6/text: form total
    show gui
]
saveprint: does [
    x: now  y: now/time
    write to-file filename: rejoin [
        %./receipts/
        x/year "-" x/month "-" x/day "_" 
        y/hour "-" y/minute "-" to-integer y/second "_" 
        user/1 ".txt"
    ] rejoin [
        (read %header.txt) newline
        newline newline
        "Item:                        Barcode:"
                                          "             Price:       Tax:"
        newline    
        blank-line
        newline newline
        a1/text
        newline
        blank-line
        newline newline
        "Subtotal:  " f4/text "  (" f7/text " items)    Tax:  " f5/text 
        "       TOTAL:  " f6/text newline
        blank-line
        newline newline newline
        "Receipt:  " (replace copy filename "./receipts/" "") 
        "    Payment Type:  " d1/text "  $" f8/text " -" f9/text 
        newline a2/text
    ]
    write to-file rejoin [
        %./inventory/sales--
        x/year "-" x/month "-" x/day "_" 
        y/hour "-" y/minute "-" to-integer y/second "_" 
        user/1 ".txt"
    ] read %./inventory/sales.txt
    write/append %./inventory/sales.txt rejoin [x newline a1/text]
    f1/text: copy "" f2/text: copy "" f3/text: copy "" 
    f4/text: copy "" f5/text: copy "" f6/text: copy "" f7/text: copy ""
    a1/text: copy " " a2/text: copy "" f8/text: copy "" f9/text: copy ""
    show gui
    replace a1/text " " "" show gui  ; eliminate area bug
    call filename  ; call/show join "metapad " filename  ; specify editor
]
delete-item: does [
    my-items: copy []
    my-lines: parse/all (copy a1/text) "^/"
    foreach item my-lines [append item newline]
    a1/text: form copy at my-lines 2
    show a1
    recalculate-totals
]
tend: does [
    f9/text: form ((to-money f8/text) - (to-money f6/text)) show f9
    if (to-money f9/text) < $0 [
        alert "Not enough money tendered to pay for items!"
    ]
]
svv/vid-styles/area/colors: [240.240.240 255.255.255]
svv/vid-styles/field/colors: [240.240.240 255.255.255]
svv/vid-styles/area/font/name: "courier"
svv/vid-styles/area/font/size: 12
svv/vid-styles/field/font/size: 20
svv/vid-face/color: white
insert-event-func [
    either event/type = 'close [
        if true = request "Really close the program?" [quit]
    ] [event]
]
view center-face gui: layout [
    size 1024x550
    across
    style txt text bold right 90x35 font-size 14 middle
    style fld field 100x35 
    box black 984x2 return
    txt 70 "Barcode:" [display-qty] f1: fld 120
    txt "Description:" f2: fld 200
    txt "Price:" 50 f3: fld 100
    loc: at txt 10 "" btn 130x35 font-size 14 "Delete Item" [delete-item]
    btn 145x35 font-size 14 "Save and Print" [saveprint]
    return
    box black 984x2 return
    text "Description:" pad 280 text "Bar Code:" pad 180 
    text "Price:" pad 100 
    text "Taxable:" return
    a1: area 984x300 [recalculate-totals]
    return
    loc2: at txt "" (loc/1 + 20) txt "SubTotal:" f4: fld 160 return 
    txt "" (loc/1 + 20) txt "Tax:" f5: fld 160 return
    txt "" (loc/1 + 20) txt "Total:" f6: fld 160 return
    at loc2 a2: area 400x70 "" font-size 12
    text "" 75 loc3: at txt "Item count: " 100 f7: fld 50
    at (loc3 + 20x50) d1: drop-down 138 "Cash" "Credit" "Check" "Other"
    at (loc2 + 0x80) txt 70 "Tendered:" font-size 12 f8: field 120 [tend]
    txt 60 "Change:" font-size 12 f9: field 120 
    key #"^M" [if form system/view/focal-face/var = "f1" [submit]]
    do [focus f1] 
]


REBOL [title: "Simple POS Sales Report Printer"]
nl: newline
start-date: request-date
if start-date = none [quit]
start-time: to-time request-text/title/default "Start Time:" "12:01am"
if ((start-time = none) or (start-time = 0:00)) [quit]
end-date: request-date
if end-date = none [quit]
end-time: to-time request-text/title/default "End Time:" "11:59pm"
if ((end-time = none) or (end-time = 0:00)) [quit]
flash "Processing..."
files: read %./receipts/
files-within-timeframe: copy [] 
foreach file files [
    if 
    (%.txt = suffix? file) and 
    (file <> %deleted.txt) and 
    (file <> %deleted--backup.txt) [
        parsed-filename: parse file "_." 
        the-date: to-date first parsed-filename 
        the-time: to-time replace (second parsed-filename) "-" ":" 
        username: third parsed-filename 
        if (the-date > start-date) and (the-date < end-date) [
            append files-within-timeframe file
        ]
        if (the-date = start-date) and (the-date < end-date) [
            if the-time > start-time [
                append files-within-timeframe file
            ]
        ]
        if (the-date > start-date) and (the-date = end-date) [
            if the-time < end-time [
                append files-within-timeframe file
            ]
        ] 
        if (the-date = start-date) and (the-date = end-date) [
            if (the-time > start-time) and (the-time < end-time) [
                append files-within-timeframe file
            ]
        ]            
    ]  
]
total-items: 0
total-sales: $0
total-tax: 0
total-sales-plus-tax: $0
total-taxable: 0
total-nontaxable: 0
total-cash: $0
subtotal-cash: $0
tax-cash: 0
total-credit: $0
subtotal-credit: $0
tax-credit: 0
total-check: $0
subtotal-check: $0
tax-check: 0
total-other: $0
subtotal-other: $0
tax-other: 0
a-line: copy {}  loop 67 [append a-line "_"]
items-sold: to-string rejoin [
    {REPORT PERIOD:  } start-date {, } start-time { to } end-date {, }
    end-time nl nl a-line nl
]
foreach file files-within-timeframe [
    sale: read/lines join %./receipts/ file
    items-start: copy next next find sale a-line
    items-end-index: (index? find items-start a-line) - 2
    items-in-sale: copy/part items-start items-end-index
    either items-in-sale <> [] [
        num-of-items: length? items-in-sale
        totals: parse (pick items-start (items-end-index + 4)) none
        other-info: parse (pick items-start (items-end-index + 8)) none
        subtotal: totals/2
        current-tax: totals/6
        receipt-grand-total: totals/8
        filename: other-info/2
        parsed-filename: parse file "_." 
        the-date: to-date first parsed-filename 
        the-time: to-time replace (second parsed-filename) "-" ":" 
        username: third parsed-filename 
        payment-type: other-info/5
        append items-sold "^/--------------------------------------------"
        append items-sold rejoin [
            nl the-date ", " the-time ", " username ", " payment-type
        ]
        append items-sold "^/--------------------------------------------"
        foreach i items-in-sale [
            append items-sold rejoin [nl i]
        ]
        total-items: total-items + num-of-items
        total-sales: total-sales + (to-money subtotal)
        total-tax: total-tax + to-decimal current-tax  
        ; (to-decimal replace (to-string current-tax) "$" "")
        total-sales-plus-tax: 
            total-sales-plus-tax + (to-money receipt-grand-total)
        switch payment-type [
            "Cash" [
                total-cash: total-cash + (to-money receipt-grand-total)
                subtotal-cash: subtotal-cash + (to-money subtotal)
                tax-cash: tax-cash + (to-decimal current-tax)
            ]
            "Credit" [
                total-credit: 
                    total-credit + (to-money receipt-grand-total)
                subtotal-credit: subtotal-credit + (to-money subtotal)
                tax-credit: tax-credit + (to-decimal current-tax)
            ]
            "Check" [
                total-check: 
                    total-check + (to-money receipt-grand-total)
                subtotal-check: subtotal-check + (to-money subtotal)
                tax-check: tax-check + (to-decimal current-tax)
            ]
            "Other" [
                total-other: total-other + (to-money receipt-grand-total)
                subtotal-other: subtotal-other + (to-money subtotal)
                tax-other: tax-other + (to-decimal current-tax)
            ]
        ]
    ] [
        if true = request rejoin ["Delete empty receipt " file "?"] [
            delete rejoin [%./receipts/ file]
        ]
    ]
]
total-taxable: total-tax / .06  
total-nontaxable: 
    (to-decimal replace (to-string total-sales) "$" "") - total-taxable
items-sold: rejoin [
    items-sold nl nl a-line nl nl
    "        Subtotal:  " total-sales "  ("  total-items " items)" nl nl
    "         Taxable:  $" total-taxable nl
    "     Non-Taxable:  $" total-nontaxable nl nl
    "             Tax:  $" total-tax  nl a-line nl nl
    "     GRAND TOTAL:  " total-sales-plus-tax nl a-line nl nl
    "   Cash Subtotal:  " subtotal-cash nl 
    "        Cash Tax:  $" tax-cash nl 
    "      Cash Total:  " total-cash nl nl
    " Credit Subtotal:  " subtotal-credit nl 
    "      Credit Tax:  $" tax-credit nl 
    "    Credit Total:  " total-credit nl nl
    "  Check Subtotal:  " subtotal-check nl 
    "       Check Tax:  $" tax-check nl 
    "     Check Total:  " total-check nl nl
    "  Other Subtotal:  " subtotal-other nl
    "       Other Tax:  $" tax-other nl
    "     Other Total:  " total-other
]
unview
; editor items-sold
write %temp.txt items-sold
call/show rejoin ["notepad " to-local-file what-dir "\temp.txt"]
wait 1 delete %temp.txt


REBOL [title: "Group Reminder System"]
group-url: ftp://user:pass@site.com/public_html/reminders.txt
menu: request-list "" ["Create New Reminder" "Listen For Reminders"]
write/append %reminders.txt ""
if "" = read group-url [write group-url {""}]
if menu = "Create New Reminder"  [
    view center-face layout [
        h3 "Add a new reminder for the group:"
        a: area wrap
        btn "Submit" [
            if error? try [
                write/append group-url mold a/text
            ] [alert "ERROR: Not Saved (check Internet connection)" quit]
            alert "Saved"
            quit
        ]
    ]
]
if menu = "Listen For Reminders" [
    print "Listening for reminders..."
    forever [
        wait 5
        attempt [
            reminders: read group-url
            if reminders <> read %reminders.txt [
                write %reminders.txt reminders
                remind: copy {}
                foreach reminder (reverse load reminders) [
                    append remind rejoin [reminder newline newline]
                ]
                view center-face layout [
                    h3 "Reminders for the group:"
                    area remind
                ]
            ]
        ]
    ]
]


REBOL [title: "Group Notes"]
url: ftp://user:pass@site.com/public_html/Notes
beep: false   autoupdt: false   call ""
write/append %notes.txt ""
update: does [
    if error? try [notes: copy read/lines url] [write url notes: ""]
    if ((beep = true) and (notes <> read/lines %notes.txt)) [
        loop 4 [call "echo ^G" wait 1]
    ]
    write/lines %notes.txt notes
    display: copy {}
    count: 0
    foreach note reverse notes [
        either note = "" [
            note: newline
        ] [
            count: count + 1
            note: rejoin [count ") "note]
        ]
        append display note
    ]
    a/text: display
    if a/text = "" [a/text: copy " "]
    show a
]
autoupdate: does [
    either autoupdt: not autoupdt [
        time: request-text/title/default "Refresh display (seconds):" "10"
        b/text: join "Auto Update:  " autoupdt  show b
        forever [
            either autoupdt = true [wait to-integer time update] [break]
        ]
    ] [
        b/text: join "Auto Update:  " autoupdt  show b
    ]
]
submit: does [
    if f/text = "" [focus f  return]
    if error? try [
        write/lines/append url rejoin [
            "^/^/" now " (" n/text "):  " f/text
        ]
    ] [alert "ERROR: Not Saved (check Internet connection)" return]
    update
    f/text: copy ""  show f  focus f
]
erase: func [arg] [
    if true = request rejoin ["Really erase " arg "?"] [
        write/lines to-file replace/all replace form now "/" "--" ":" "_"
            notes
        if arg = "all" [write url ""]
        if arg = "" [
            indx: (
                3 * to-integer request-text/title/default "Index:" "1"
            ) - 2
            remove/part at notes indx 3 
            write/lines url reverse notes 
        ]
        update
    ]
]
changeurl: does [
    url: to-url u/text  
    update
    focus f
]
setbeep: does [
    beep: not beep  
    p/text: join "Beep: " beep
    show p
]
insert-event-func [either event/type = 'close [quit][event]] 
view center-face layout [
    h3 "Current notes for:"
    u: field 600 form url [changeurl]
    a: area 600x260
    h3 "Name:"
    n: field 600
    h3 "New Note:"
    f: field 600 [submit]
    across
    btn "Update" [update]
    b: btn join "Auto Update: " autoupdt [autoupdate]
    p: btn join "Beep: " beep [setbeep]
    btn "Erase" [erase ""]
    btn "Erase All" [erase "all"]
    do [update focus f]
]


REBOL [title: "Group Notes (Console)"]
u: ftp://user:pass@site.com/public_html/Notes
if "" = form url: to-url ask join u ":  " [url: u]
name: copy ask "^LName:  "
forever [
    if error? try [notes: copy read/lines url] [write url notes: ""]
    display: copy {}  count: 0
    foreach note reverse notes [
        either note = "" [
            note: "^/"
        ] [
            count: count + 1
            note: rejoin [count ") "note]
        ]
        append display note
    ]
    message: ask rejoin [newpage display "^/Message:  "]
    case [
        message = "" []
        not error? try [indx: to-integer message] [
            remove/part at notes (3 * indx - 2) 3 
            write/lines url reverse notes
            ; write/lines/append join url "-bak" reverse notes
        ]
        message = "erase" [write url ""]
        message = "name" [name: copy ask "^LName:  "]
        message = "url" [
            u: url
            if "" = form url: to-url ask rejoin ["^L" u ":  "] [url: u]
        ]
        true [
            if error? try [
                write/lines/append url rejoin [
                    "^/^/" now " (" name "):  " message
                ]
            ] [print "ERROR: Not Saved" quit]
        ]
    ]
]


#! ../rebol276 -cs
REBOL [title: "Group Notes"]
print {content-type: text/html^/}
submitted: decode-cgi read-cgi
url: ftp://user:pass@site.com/public_html/Notes
print {
    <center><table border=0 cellpadding=10 width=600><tr><td>
}
if submitted/2 <> none [
    if error? try [
        write/lines/append url rejoin [
            "^/^/" now " (" submitted/2 "):  " submitted/4
        ]
    ] [print "ERROR: Not Saved" quit]
]
print {<pre>}
if error? try [notes: copy read/lines url] [write url notes: ""]
display: copy {}
count: 0
remove/part notes 2
foreach note reverse notes [
    either note = "" [
        note: {<br>}
    ] [
        count: count + 1
        note: rejoin [count ") "note]
    ]
    append display note
]
print display
print {
    </td></tr></table>
    <FORM ACTION="http://re-bol.com/notes.cgi">
        <table border=0 cellPadding=0 cellSpacing=4 width=600>
        <tr><td width=10%>Name:</td>
        <td><input type=text size="65" name="username"></td></tr>
        <tr><td width=10%>Message:</td>
        <td><textarea name=message rows=5 cols=50></textarea></td></tr>
        <tr><td></td><td>
        <input type="submit" name="submit" value="Submit">
        </td></tr></table>
    </FORM>
    </td></tr></table></center>
}


#! ../rebol276 -cs
REBOL [Title: "Etsy"]
print {content-type: text/html^/^/}
print {<HTML><HEAD><TITLE>Etsy</TITLE></HEAD><BODY>}
read-cgi: func [/local data buffer][
    switch system/options/cgi/request-method [
        "POST" [
            data: make string! 1020
            buffer: make string! 16380
            while [positive? read-io system/ports/input buffer 16380][
                append data buffer
                clear buffer
            ]
        ]
        "GET" [data: system/options/cgi/query-string]
    ]
    data
]
submitted: decode-cgi submitted-bin: read-cgi
if ((submitted/2 = none) or (submitted/4 = none)) [
    print {
        <STRONG>W A R N I N G  -  Private Server:</STRONG><BR><BR>
        <FORM METHOD="post" ACTION="./etsy.cgi">
            Username: <input type=text size="50" name="name"><BR><BR>
            Password: <input type=text size="50" name="pass"><BR><BR>
            <INPUT TYPE="SUBMIT" NAME="Submit" VALUE="submit">
        </FORM>
        </BODY></HTML>
    } 
    quit
]
myusername: "some-user-name"  mypassword: "some-password"
username: submitted/2   password: submitted/4 
either ((username = myusername) and (password = mypassword)) [][
    print "Incorrect Username/Password." 
    print {</BODY></HTML>} quit
]
do-etsy: does [
    do/args http://reb4.me/r/etsy.r context [
	Consumer-Key: #<my-key>
	Consumer-Secret: #<my-secret>
	User-Store: %etsyusers
	Scope: [listings_w listings_r listings_d]
	Sandbox: true
    ] 
    etsy/as "<my-user-name>"
]
if submitted/6 = "sale" [
    do-etsy
    coupon-code: submitted/8
    add-or-remove: submitted/10
    print "FOUND ITEMS:<br><br>"
    found: copy []
    x: get in (etsy/listings []) 'results
    for i 1 (length? x) 1 [  
        print copy rejoin [
            (get in x/:i 'title) <br>
        ] 
        append found (get in x/:i 'listing_id)
        append found (get in x/:i 'description)
        append found (get in x/:i 'title)
        append found (get in x/:i 'state)
    ]
    print "<br><br>REPLACED ITEMS:<br><br>"
    foreach [lstngid dscrptn titl state] found [
        either state <> "active" [
            print copy rejoin [
                titl { was NOT replaced (listing inactive)<br>}
            ]
        ][
            etsy/api-call/with put rejoin [
                %listings/ lstngid
            ] either add-or-remove = "add" [
                [
                    title: rejoin ["SALE-" titl]
                    description: rejoin [coupon-code dscrptn]
                ]
            ] [
                [
                    title: replace titl "SALE-" ""
                    description: replace dscrptn rejoin [
                        coupon-code] ""
                ]
            ]
            print copy rejoin [titl {<br>}]
        ]
    ]
    print "<br>Done<br><br>"
    quit
]
if submitted/6 = "replace" [
    do-etsy
    search-text: submitted/8
    replace-text: submitted/10
    print "FOUND ITEMS:<br><br>"
    found: copy []
    x: get in (etsy/listings []) 'results              
    for i 1 (length? x) 1 [  
        if find (get in x/:i 'description) search-text [ 
            print rejoin [
                ; {"} search-text {" found in:  } 
                (get in x/:i 'title) "<br>"
            ] 
            append found (get in x/:i 'listing_id)
            append found (get in x/:i 'description)
            append found (get in x/:i 'title)
            append found (get in x/:i 'state)
        ]
    ]
    print "<br><br>REPLACED ITEMS:<br><br>"
    foreach [lstngid dscrptn titl state] found [
        either state <> "active" [
            print copy rejoin [
                titl { was NOT replaced (listing inactive)<br>}
            ]
        ][
            etsy/api-call/with put rejoin [
                %listings/ lstngid
            ] [
                description: (
                    replace/all dscrptn search-text replace-text
                )
            ]
            print copy rejoin [titl {<br>}]
        ]
    ]
    print "<br>Done<br><br>"
    quit
]
if submitted/6 = "create-listing" [
    do-etsy
    itm: submitted/8
    desc: submitted/10
    prc:  to-decimal next find submitted/12 "$"
    ctgry: submitted/14
    print "Creating item...<br><br>"
    etsy/api-call/with post %/listings [
        quantity: 1 
        title: itm 
        description: desc 
        price: prc 
        category_id: ctgry 
        who_made: "i_did" 
        is_supply: "1" 
        when_made: "2010_2012" 
        shipping_template_id: "330"
    ]
    print rejoin ["CREATED: " itm ", " desc ", " prc]
    quit
]
if submitted/6 = "delete-listing" [
    do-etsy
    itm2del: submitted/8
    print "Deleting...<br><br>"
    etsy/api-call/with get rejoin [%listings/ itm2del] [
        method: "DELETE"
    ]
    print rejoin ["Item " itm2del " deleted."]
    quit
]
if submitted/6 = "view-raw" [
    do-etsy
    print {<pre>}
    probe copy get in (etsy/listings []) 'results
    print {</pre>}
    quit
]
if submitted/6 = "get-image2" [
    do-etsy
    photo-item-id: submitted/8
    photo-list: etsy/api-call/with get rejoin [
        %listings/ photo-item-id "/images"
    ] []
    either error? try [photo-id: first get in photo-list 'results] [
        print "No photo available for that item."
        return
    ][
        photo-info: etsy/api-call/with get the-code: rejoin [
            %listings/ photo-item-id "/images/ " photo-id
        ] []
    ]
    probe either [] = the-photo: (get in photo-info 'results) [
        "none"
    ] [
        the-photo
    ]
    quit
]
default-coupon-code: {
    ** SALE ** Enter the coupon code &quot;982u3445&quot; at 
    checkout to receive 10% off your order.&lt;br&gt;&lt;br&gt;
}
print rejoin [
    {<h2>Add or Remove Sale:</h2>
    <FORM METHOD="post" ACTION="./etsy.cgi">
        <INPUT TYPE=hidden NAME="username" VALUE="} myusername {">
        <INPUT TYPE=hidden NAME="password" VALUE="} mypassword {">
        <INPUT TYPE=hidden NAME="subroutine" VALUE="sale">
        Coupon Code:<BR>
        <TEXTAREA COLS="50" ROWS="18" NAME="couponcode">}
            default-coupon-code 
        {</TEXTAREA><BR><BR>
        Add or Remove: <select NAME="addorremove">
            <option>add
            <option>remove
        </option></select><br><br>
        <INPUT TYPE="SUBMIT" NAME="Submit" VALUE="submit">
    </FORM>
    <BR><HR>
    <h2>Replace In Description:</h2>
    <FORM METHOD="post" ACTION="./etsy.cgi">
        <INPUT TYPE=hidden NAME="username" VALUE="} myusername {">
        <INPUT TYPE=hidden NAME="password" VALUE="} mypassword {">
        <INPUT TYPE=hidden NAME="subroutine" VALUE="replace">
        Search Text:<BR><BR>
        <input type=text size="35" name="searchtext">
        <BR><BR>
        Replace Text:<BR><BR>
        <input type=text size="35" name="replacetext">
        <BR><BR>
        <INPUT TYPE="SUBMIT" NAME="Submit" VALUE="submit">
    </FORM>
    <BR><HR>
    <h2>Create Listing:</h2>
    <FORM METHOD="post" ACTION="./etsy.cgi">
        <INPUT TYPE=hidden NAME="username" VALUE="} myusername {">
        <INPUT TYPE=hidden NAME="password" VALUE="} mypassword {">
        <INPUT TYPE=hidden NAME="subroutine" VALUE="create-listing">
        Title: <BR><BR>
        <input type=text size="35" name="title" value="Ring 100">
        <BR><BR>
        Description: <BR><BR>
        <input type=text size="35" name="description" 
            value="Ring 100.  A very pretty ring."><BR><BR>
        Price: <BR><BR>
        <input type=text size="35" name="Price" value="$19.99">
        <BR><BR>
        Category: <BR><BR>
        <input type=text size="35" name="Category" value="69150467">
        <BR><BR>
        <INPUT TYPE="SUBMIT" NAME="Submit" VALUE="submit">
    </FORM> 
    <BR><HR>
    <h2>Delete Listing:</h2>
    <FORM METHOD="post" ACTION="./etsy.cgi">
        <INPUT TYPE=hidden NAME="username" VALUE="} myusername {">
        <INPUT TYPE=hidden NAME="password" VALUE="} mypassword {">
        <INPUT TYPE=hidden NAME="subroutine" VALUE="delete-listing">
        Listing ID #: <BR><BR>
        <input type=text size="35" name="listing-id"><BR><BR>
        <INPUT TYPE="SUBMIT" NAME="Submit" VALUE="submit">
    </FORM> 
    <BR><HR>
    <h2>View All Raw Listing Data:</h2>
    <FORM METHOD="post" ACTION="./etsy.cgi">
        <INPUT TYPE=hidden NAME="username" VALUE="} myusername {">
        <INPUT TYPE=hidden NAME="password" VALUE="} mypassword {">
        <INPUT TYPE=hidden NAME="subroutine" VALUE="view-raw">
        <INPUT TYPE="SUBMIT" NAME="Submit" VALUE="submit">
    </FORM> 
    <BR><HR>
    <h2>View Image:</h2>
    <FORM METHOD="post" ACTION="./etsy.cgi">
        <INPUT TYPE=hidden NAME="username" VALUE="} myusername {">
        <INPUT TYPE=hidden NAME="password" VALUE="} mypassword {">
        <INPUT TYPE=hidden NAME="subroutine" VALUE="view-image">
        <INPUT TYPE="SUBMIT" NAME="Submit" VALUE="submit">
    </FORM> 
    </BODY></HTML>}
]
quit


#!./rebol276 -cs
REBOL [title: "CGI Forum"]
print {content-type: text/html^/}
switch system/options/cgi/request-method [
    "POST" [
        cgi-data: copy ""  cgi-buffer: copy ""
        while [positive? read-io system/ports/input cgi-buffer 16380] [
            append cgi-data cgi-buffer clear cgi-buffer
        ]
    ]
    "GET" [cgi-data: system/options/cgi/query-string]
]
submitted: decode-cgi cgi-data
if submitted/2 = "rss" [
    write/append %bb.db ""
    bbs: load %bb.db
    reverse bbs
    stickycount: 0
    foreach topic bbs [foreach item topic [
        if find item {<i>STICKY:} [stickycount: stickycount + 1]
    ]]
    print trim {<?xml version="1.0"?>
        <rss version="2.0">
        <channel>        
        <title>REBOL Forum</title>
        <description>Recent REBOL Forum Topics</description>
        <link>http://rebolforum.com</link>
    }
    count: 1
    foreach item (at bbs (stickycount + 1)) [
        rss-title: copy item/1
        rss-title: replace/all rss-title {&} {&amp;}
        rss-title: replace/all rss-title {"} {&quot;}
        rss-title: replace/all rss-title {'} {&apos;}
        rss-title: replace/all rss-title {<} {&lt;}
        rss-title: replace/all rss-title {>} {&gt;}
        rss-description: rejoin [
            (copy/part (pick item ((length? item) - 2)) 4096) 
            ", Posted by: " (pick item ((length? item) - 1))
            "  " (pick item (length? item))
        ]
        rss-description: replace/all rss-description {&} {&amp;}
        rss-description: replace/all rss-description {"} {&quot;}
        rss-description: replace/all rss-description {'} {&apos;}
        rss-description: replace/all rss-description {<} {&lt;}
        rss-description: replace/all rss-description {>} {&gt;}
        print trim rejoin [
            {<item>
            <title>} rss-title {</title>
            <description>} rss-description {</description>
            <link>http://rebolforum.com/index.cgi?
                f=printtopic&amp;topicnumber=}
            ((length? bbs) + 1 - count - stickycount) 
            {&amp;archiveflag=new</link></item>}
        ]
        count: count + 1
        if count > 10 [break]
    ]
    print trim {
        </channel>
        </rss>
    }
    quit
]
print {<HTML><HEAD><TITLE>REBOL Forum</TITLE>
    <link rel="alternate" type="application/rss+xml" 
        title="rebolforum.com rss feed" href="./index.cgi?f=rss" /></HEAD>
<BODY bgColor=#808080><CENTER>
<TABLE border=0 cellPadding=20 cellSpacing=2 height=100% width=85%>
<TR><TD bgColor=white vAlign=top>}
footer: {</TD></TR></TABLE></CENTER></BODY></HTML>}
unless exists? %index.html [
    write %index.html {<html><head><title></title>
        <META HTTP-EQUIV="REFRESH" CONTENT="0; URL=./index.cgi"></head>
        <body bgcolor="#FFFFFF"></body></html>}
]
if submitted/2 = "downloadreader" [
    print trim/lines {
        <center><a href="./index.cgi?f=home">Home</a></center><br>
        (Open the REBOL console and "do" this page URL)<br><br><pre>
    }
    print decompress #{
789CC5544B8BDB3010BEFB570C82425C70B4CE52167C6B69F7B4A5901E430EB2
3DD9A8B525571AC7D996FEF74AF2234EB2DBC7A9821069E69BC7F78DA5F58777
9F1E6043922ACC80ADC3F15E9BB686358A120DDB46912D0CA2CAC03E59C29A1F
2476BCB7253B5120B7F23B4202E9CDCDD1FD22D28D2C6C06856E9E60B3052805
895C589C4C51D436CEE80CA5460B9B08DCBA080BB68BC84A8BD2E1929DAC100C
7E6BD15238F04080FB6D88F38B3D78F447B4563CA2CD183006AF0CE6BADA797E
4B3A52C0BA138A62DFD79F2A0E4DF9259A065539F4073B692CF58780E81BA594
FBC8A1CF1E1A1C76AF3BE70D7B9172C2230DA01F3F4F0091464E142F2C14A808
4D10162AF1A45B1A5A092A2F7ADDE33E5F61B4B543FD0C7CEEA492AEBBC542D8
A411D2C0C2E856959CF418C953780DCBD59B18D278B2ADE2D8CD6F757BBCBB8D
830223D99308F5A863DF3C639367D46F334040891A81648D5B58080297E8EB49
562754A10856F12CF74CE4B18C9BEE172DD50568D60828EC2AA966FFBE2A7363
0FA52FDD576958F277CB65FC5DAA6D74BD3B1FF3C868728F033F0509373CE144
84CE88E6CFC3BB7B7978219D416A8D0ADB9C14B0F7BA53E1E6ACD17F5CD39560
33753B23099FBF5A561C9EBD5F41C5CFCE392574F170EF202FDFB57139B225EC
899A8CF319ACD035CFF36599CFC439A7F0D6147B79C0F23F9048445FFB5FC88C
21D78CFCEB0A23AD733EFDDBE8DECD68FB0BE01DA7BF9F050000
}
    print {</pre>}
    print footer
    quit
]
if submitted/2 = "api" [
    print {<pre>}
    print decompress #{
789CB5503D0BC23010DDFB2B8E0E3A15F74217C14E82E01A3AC4F62A912629F9
4044FADF4DD3D8D6A238883784BCBB07EFE3B8DB1EF6400C330DA6101F3DCCA5
B21C722B4AC3A4D0711145B4AA14EAD62147ABDD0548DDB312AB1A187E46B6AC
14969F50858DD5A804E5182047ADE9190B2010811B7E4B5AA94D0A0A2F920920
7EDBCFBD0EDAD94CB79BCEAB9956D6BDD19F517B032367743423045B232760CF
28FCAB90569BD26A23394CA91556B64420EB3EC4334C110D6509BC7EEA69D18A
B7FD5B434EACFB967859DE6B6D7FEDE30149C2C94C64020000
}
    print {</pre>}
    print footer
    quit
]
if submitted/2 = "source" [
    print trim/lines {
        <center><a href="./index.cgi?f=home">Home</a></center><br>
        (Open the REBOL console and "do" this page URL)<br><br><pre>
    }
    prin {REBOL []  editor decompress }
    print compress read %index.cgi
    print </pre>
    print footer
    quit
]
write/append %archive.db ""
write/append %bb.db ""
bbs: load %bb.db
displaylength: 49
captchacheck: does [
    if submitted/10 <> (trim/all submitted/12) [
        print {<strong>Incorrect Captcha Text</strong><br><br>
            Click the [BACK] button in your browser to try again.
            <br><br><a href="./index.cgi?f=home">Home</a><br>
        }
        print footer
        quit
    ]
]
random/seed now/time  password: copy []  wrds: first system/words
foreach ch mold pick wrds (random length? wrds) [append password ch]
if submitted/2 = "addnew" [
    if (submitted/4 = "") or (submitted/6 = "") or (submitted/8 = "") [
        print {
            <strong>Incomplete submission</strong><br><br>
            Click the [BACK] button in your browser to try again.
            <br><br><a href="./index.cgi?f=home">Home</a><br>
        }
        print footer
        quit
    ]
    captchacheck
    make-dir %./history/
    save rejoin [
        %./history/ now/year "_" now/month "_" now/day "_" 
        (replace/all form now/time ":" "_") ".db"
    ] bbs
    entry: copy []
    append entry submitted/6  ; topic
    submitted-message: replace/all submitted/8 {REBOL [}
        {R E B O L [}
    submitted-message: replace/all submitted-message {REBOL[}
        {R E B O L [}
    append entry submitted-message  ; message
    append entry submitted/4  ; name
    append entry form (now + 3:00)
    append/only tail bbs entry
    if (length? bbs) > displaylength [
        write/append %archive.db mold bbs/1
        remove head bbs
    ]
    reverse bbs
    foreach topic (copy bbs) [ 
       foreach item topic [
           if find item {<i>STICKY:} [
               move/to (find/only bbs topic) 1
           ]
       ]
    ]
    reverse bbs
    save %bb.db bbs
    print {<strong>New Topic Added</strong>}
    print footer
    wait :00:02
    print {<META HTTP-EQUIV="REFRESH" 
        CONTENT="0; URL=./index.cgi?f=added">}
    quit
]
if submitted/2 = "printtopic" [
    if submitted/6 = "archive" [bbs: load %archive.db]
    current-topic: copy pick bbs (to-integer submitted/4)
    print rejoin [
        {<center><a href="./index.cgi?f=home">Home</a> &nbsp; 
        <a href="./index.cgi?f=printarchive">Archive</a></center><br>
        <center><table border=0 cellPadding=0 cellSpacing=0 width=90%>
        <tr><td><hr><br><font size=5>} (current-topic/1) {</font><br><br>}
    ]
    foreach [message name timestamp] (at current-topic 2) [
        replace/all message newline {  <br>  }
        message2: copy message
        append message { } 
        replace/all message2 {    } {&nbsp;&nbsp;&nbsp;&nbsp;} 
        parse/all message [any [thru "http://" copy link to { } (
            replace message2 (rejoin [{http://} link]
        ) (rejoin [
            { <a href="} {http://} link {" target=_blank>http://}
            link {</a> }
        ]))] to end]
        print rejoin [
            message2 {<br><br><font size=1>posted by: &nbsp; }
            name { &nbsp; &nbsp; &nbsp; }
            timestamp {</font><br><br><hr><br>}
        ]
    ]
    if submitted/6 = "new" [
        print rejoin [
            {<FORM method="post" ACTION="./index.cgi">
                <input type=hidden name="addresponse" value="addresponse">
                <input type=hidden name="topicnumber" value="} submitted/4
                {">
                Name: <br>
                <input type=text size="60" name="username"><br><br>
                Message: <br>
                <textarea name=message rows=5 cols=50></textarea><br><br>
                Type this quoted captcha text below: "<strong>} password 
                {</strong>"<br><br>
                <input type=text size="60" name="pass"><br><br>
                <input type="hidden" name="password" value="} password {">
                <input type="submit" name="submit"
                    value="submit response">
            </FORM></td></tr>
            <tr><td align=right><a href="./index.cgi?f=home">Home</a></td>
            </tr></table></center>}
        ]
    ]
    print footer
    quit
]
if submitted/2 = "search" [
    print {<center><a href="./index.cgi?f=home">Home</a></center><br><hr>
        <br>}
    search-all: does [
        foreach topic bbs [
            foreach [message name timestamp] (at topic 2) [
                if any [
                    (find message submitted/4) (find name submitted/4)
                ] [
                    replace/all message newline {  <br>  }
                    message2: copy message
                    append message { } 
                    replace/all message2 {    } {&nbsp;&nbsp;&nbsp;&nbsp;}
                    parse/all message [any [
                        thru "http://" copy link to { } (
                            replace message2 (rejoin [{http://} link]) (
                                rejoin [
                                    { <a href="} {http://} link
                                    {" target=_blank>http://} link {</a> }
                                ]
                            )
                        )
                    ] to end]
                    print rejoin [
                        {<font size=5>} archive-note topic/1
                        {</font><br><br>}
                        message2 {<br><br><font size=1>posted by: &nbsp; }
                        name { &nbsp; &nbsp; &nbsp; }
                        timestamp {</font><br><br><hr><br>}
                    ]
                ]
            ]
        ]
    ]
    archive-note: ""  search-all  
    bbs: load %archive.db  archive-note: {(Archive) }  search-all
    print footer
    quit
]
if submitted/2 = "addresponse" [
    if (submitted/6 = "") or (submitted/8 = "") [
        print {
            <strong>Incomplete submission.</strong><br><br>
            Click the [BACK] button in your browser to try again.
            <br><br><a href="./index.cgi?f=home">Home</a><br>
        }
        print footer
        quit
    ]
    captchacheck
    save rejoin [
        %./history/ now/year "_" now/month "_" now/day "_" 
        (replace/all form now/time ":" "_") ".db"
    ] bbs
    topicnumber: to-integer submitted/4    ; topic number
    submitted-message: replace/all submitted/8 {REBOL [}
        {R E B O L [}
    submitted-message: replace/all submitted-message {REBOL[}
        {R E B O L [}
    append bbs/:topicnumber submitted-message    ; message 
    append bbs/:topicnumber submitted/6    ; name
    append bbs/:topicnumber form (now + 3:00)
    move/to (at bbs topicnumber) (length? bbs)  ; sort by most recent
    responded-topic: (first last bbs)
    reverse bbs  ; move sticky messages to top
    foreach topic (copy bbs) [ 
       foreach item topic [
           if find item {<i>STICKY:} [
               move/to (find/only bbs topic) 1
           ]
       ]
    ]
    reverse bbs
    save %bb.db bbs
    print rejoin [
        {<strong>Response added to "} responded-topic {"</strong>}
    ]
    print footer
    wait :00:03
    print {<META HTTP-EQUIV="REFRESH" 
        CONTENT="0; URL=./index.cgi?f=added">}
    quit
]
either submitted/2 = "printarchive" [
    archiveflag: "archive"
    bbs: load %archive.db
    head-text: "Archive"
] [
    archiveflag: "new"
    head-text: "REBOL Forum"
]
print rejoin [{
    <center><font size=6>} head-text {</font><br>
    <FORM method="post" ACTION="./index.cgi">
        <input type=hidden name="search" value="search">
        <input type=text size="50" name="searchtext">
        <input type="submit" name="submit" value="search">
    </FORM>
    <table border=1 cellPadding=5 cellSpacing=0 width=90%>
}]
counter: 1
reverse bbs
foreach bb bbs [
    print rejoin [
        {<tr><td width=65%> &nbsp; 
            <a href="./index.cgi?f=printtopic&topicnumber=}
        ((length? bbs) + 1 - counter)
        {&archiveflag=} archiveflag {">} bb/1 
        {</a></td><td width=5%>} ((length? bb) - 1 / 3)
        {</td><td width=30%><font size=1>} (last bb) 
        {, } pick bb ((length? bb) - 1) {</font></td></tr>}
    ]
    counter: counter + 1
    if counter > displaylength [break] 
]
message-count: 0
try [foreach record bbs [
    message-count: message-count + ((length? record) - 1 / 3)
]]
either submitted/2 <> "printarchive" [
    print rejoin [
        {<tr><td> &nbsp; <a href="./index.cgi?f=printarchive">
            ARCHIVED MESSAGES</a></td>}
        {<td colspan=2 align=center><strong>} message-count 
        { active messages </strong></td></tr>}
    ]
] [
    print rejoin [
        {<td colspan=2> &nbsp; <strong>} message-count 
        { archived messages</strong></td>}
        {<td align=center>  &nbsp; 
            <a href="./index.cgi?f=home">Home</a></td></tr>}
    ]
]
print rejoin [{
    </table><br>
    <FORM method="post" ACTION="./index.cgi">
        <table border=0 cellPadding=0 cellSpacing=4 width=50%>
        <input type=hidden name="addnew" value="addnew">
        <tr><td width=10%>Name:</td>
        <td><input type=text size="65" name="username"></td></tr>
        <tr><td width=10%>New&nbsp;Topic:</td>
        <td><input type=text size="65" name="subject"></td></tr>
        <tr><td width=10%>Message:</td>
        <td><textarea name=message rows=5 cols=50></textarea></td></tr>
        <tr><td width=10%>Captcha:</td>
        <td>Type this quoted captcha text below: "<strong>} password 
            {</strong>"<br>
        <input type=text size="65" name="pass"><br>
        <input type="hidden" name="password" value="} password
             {"></td></tr>
        <tr><td></td><td>
        <input type="submit" name="submit" value="submit new topic">
        </td></tr></table>
    </FORM>
    <table border=1 cellPadding=5 cellSpacing=0 width=88%>
            <tr><td align=center><font size=2>
        <a href="./index.cgi?f=home"><strong>Home</strong></a> &nbsp; 
        <a href="./index.cgi?f=rss">RSS Feed</a> &nbsp; 
        <a href="./index.cgi?f=downloadreader">Reader</a> &nbsp; 
        <a href="./index.cgi?f=source">Source</a> &nbsp; 
        <a href="http://synapse-ehr.com/forums/forumdisplay.php?3-Rebol"
            target=_blank>Graham's Forum</a> &nbsp; 
        <a href="http://www.rebol.org/aga-groups-index.r?world=r3wp"
            target=_blank>AltME</a> &nbsp; 
        <a href="http://mail.rebol.net/cgi-bin/mail-list.r" target=_blank>
            ML</a> &nbsp; 
        <a href="http://www.rebol.net/cgi-bin/r3blog.r" target=_blank>
            R3 Blog</a> &nbsp; 
        <a href="http://translate.google.com/translate?hl=en&sl=fr&
            u=http://www.digicamsoft.com/cgi-bin/rebelBB.cgi&
            ei=te4HTNCBGsKBlAfdnIyZDg&sa=X&oi=translate&ct=result&
            resnum=1&ved=0CCsQ7gEwAA&prev=/search%3Fq%3Drebelbb%26hl%3
            Den%26client%3Dopera%26hs%3DF5Z%26rls%3Den" target=_blank>
            RebelBB</a> &nbsp; 
        <a href="http://www.rebol.com/community.html" target=_blank>
            Community</a> &nbsp; 
        <a href="http://re-bol.com" target=_blank>Tutorial</a>
    </font></td></tr></table></center>
}]
print footer
quit


#!./rebol276 -cs
REBOL [title: "CGI Sitebuilder"]
print "content-type: text/html^/"
print [<HTML><HEAD><TITLE>"Sitebuilder"</TITLE></HEAD><BODY>]
read-cgi: func [/local data buffer][
    switch system/options/cgi/request-method [
        "POST" [
            data: make string! 1020
            buffer: make string! 16380
            while [positive? read-io system/ports/input buffer 16380][
                append data buffer
                clear buffer
            ]
        ]
        "GET" [data: system/options/cgi/query-string]
    ]
    data
]
submitted: decode-cgi submitted-bin: read-cgi
; if no data has been submitted, request user/pass:
if ((submitted/2 = none) or (submitted/4 = none)) [
    print [<strong>"W A R N I N G  -  "]
    print ["Private Server, Login Required:"</strong><BR><BR>]
    print [<FORM METHOD="post" ACTION="./sitebuilder.cgi">]
    print [" Username: " <input type=text size="50" name="name"><BR><BR>]
    print [" Password: " <input type=text size="50" name="pass"><BR><BR>]
    print [<INPUT TYPE="SUBMIT" NAME="Submit" VALUE="submit">]
    print [</FORM>]
    print {</BODY></HTML>} quit
]
; check user/pass every time - end program if incorrect:
username: submitted/2 password: submitted/4 
either ((username = "username") and (password = "password")) or (
    (find submitted/2 {Content-Disposition: form-data;}) <> none) [
    ; if user/pass is ok, go on
][
    print "Incorrect Username/Password." 
    print {</BODY></HTML>} quit
]
if not exists? %sitemap.r [
    write %sitemap.r {%Home []} 
    write %Home {}
]
if not exists? %upload.cgi [
    write/binary/allow %upload.cgi to-binary decompress 64#{
eJyFV21v2zYQ/m7A/+GqoYUDTFHaAV2h2A7aNVsHpEixZhgGwxsoibbZSqJKUs2M
LP99d3yRZNnFBFgv5N3xubvnjvR3T84TxTNZvvjxJcS5nk5+u35zewOr9XTSKFEb
eMhlbXhtYrNveAqG/2OSnanKv5LHILKav7t7f7Ocv7t+/XY5v/v17uZ6GX0Uhmet
KAuuonniBueJE3lz+/bPJa4wnSjOijjfihQ2bZ3DKillzkoomGGQtZsNV+vVdAJ4
6Xth8h3ovTa8SmRjhKx1gqqI/0vLtYkrbnayAC9PV/Th9uNdNByhi4ynULHPHLRB
B7ZP4PnFi4tDIbf4WOzlD69Gcvc7UXJYNVILI77yK7AeCRmANlIZnYi6aY236ays
R6DoYk3D62Lo/LFMXnKmTs6u+8/Ba/TLNUXA+XwieBg6tY+dg17NP0hlOrFZKngu
Cx5XbWlEw5SJN1JVsbPp8uZUmnhIljCGsTGxs0YDPsWl0AZyDAo6zEtRxRnf+jcK
Qi3rOFf2UW78F75UouIxQUBkYVWylEIum72lLQ0JUjGwkW1dXMFGoMFDbBB1ziSd
MxgnTJ9pVe3QWd9t0IP9Uw5mRQqfpKghiuPIidGCiWGiJAejjFAwtV9EPrDBXa+H
ESDfhpMYAT9pvc6KgMQFInVUkFVT8grRQL5jSnOD6Is2RzqiWkiji+D/a9T8vhQ1
H6rR2qS4Ctn4F/qUeLkuISg4oPQMPY8LoRtJkbMhS0mT07jrJJFtJU3JRB3BWa/a
s+Gyt44lSHc7h41lQP0oZMSuRlUoazTuEhFAAKv3PYn6aNOF1YAeRodtrte3bDlS
H5aY/b4Mbp7C6Gy5+X7UyAHfvZHeYdsJjk3NYMfqosRi7CQ7JwPagOSsq2f3MtY8
LF5fwN7YaKyn+0Gd90O+qk3VQM0qDl9Z2dp73HgUp9dJoSEiDkbg4XIRPQbMloto
EHceGSNh43upCphpXnKsrYFWRFLRgEdcmB122xmx7oqAYf871tpg+x5r+gujBbNR
CwndY8Dds/H+Yl1Pj/O9/oag3WJk9gmhPRmL0BUg+h6EnhzLONaGHjXOV7i6SvSx
caHpsukKnRPQUbsb0t26crDXHMXcpj11QbOdlOAfWlhRB6q3PJF1ibWF4XRatkdJ
TR1pthGKdLu5M5jZkJ0hwvXYnN883bbS2xiyhlCcsNF50FqVb5bTIYOJtQkry+EG
h9paIvn72nR7wqBhdIsRUL+9dvophPPQdIK32JHCUgl36Dan5vKtnfjU5n6w47mM
9nvxdHIJjZIZznRLYQci30u212B9wyU0yA1gWkG3GTYjwwvolve0JVN/KGxUlqvU
2DRXX5EIrcZjhVWWSmxFjR0isPl7W1+4S4vN3kpg9FVKsPAjJqkUSobJRDjCYDTN
jlqAXcD10w510uykkUmwPJ3cE5Ykw/WUte21xgpdhfqT7jzHL66WcwY7xTeL6DzR
/Sn2HPWvyP6CkNLLs4ZpvaAb0euZi8/CPaLlG5Z/plAMDsLzhC3nmVo+9ksaliG0
e1GY3eLVxVPI0BJXi+cHMgjJFF7o+cXFU2skoO0FHbHmSBVZb5e/f7i5ff0Wfrp9
/+Hm+u56nvhxq4u/Q+mfMUIa8lYptIoViUcPsxMaj1AEPD2hjev6SSS9Mpa68PSc
RvEVj+o26E6kOyC6/wuK27PN6mEQ6Ucn/xAB7vRbbhZ/ZyWrPy/9eBRiF63XtmxC
cAhPYgq62TeKJz7tXwz8v0F/TBDpl1aY/wDPpuhm7AwAAA==
} [read write execute read write execute read write execute]
    if error? try [call {chmod 755 ./upload.cgi}] [
        print {
            <center><table border="1" width=80% cellpadding="10"><tr><td>
            <strong>./upload.cgi</strong> has been created, but there was
            apparently a problem setting permissions for it.  Please be
            sure that upload.cgi is chmod to 755.<br><br><center>
            <a href="./sitebuilder.cgi?name=username&pass=password
                &submit=submit">
            Continue</a></center></td></tr></table></center></BODY></HTML>
        } quit
    ]
]
; if only user/pass has been entered, print main start page :
if submitted/6 = "submit" [
    ; write/append %sitemap.r ""  ; make sure it exists
    print rejoin [
        "<center>Path: " what-dir 
        {<br><table border="1" width=80% cellpadding="10"><tr><td>}
    ]
    print rejoin [
        {<br>
        <FORM ACTION=
        "./upload.cgi" METHOD="post" ENCTYPE="multipart/form-data">
        Upload File: <INPUT TYPE="file" size="50" NAME="photo">
        <INPUT TYPE="submit" NAME="Submit" VALUE="Upload">    
            <a href="./sitebuilder.cgi?name=username&pass=password
            &subroutine=listfiles">Files</a>  
        </FORM>
        <FORM method="post" ACTION="./sitebuilder.cgi"> 
        <INPUT TYPE=hidden NAME=username VALUE="} submitted/2 {">
        <INPUT TYPE=hidden NAME=password VALUE="} submitted/4 {">
        <INPUT TYPE=hidden NAME=subroutine VALUE="edit">
        Create New Page: 
        <INPUT TYPE=text size="50" name="file" value="">
        <INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit">
        </FORM>}
    ]
    pages: sort read %.
    ; dont-show-suffixs: [
        %.html %.jpg %.gif %.png %.bmp %.rip %.exe %.pdf %.cgi %.php
        %.zip %.txt %.tpl %.r %.tgz
    ]
    ; remove-each page pages [find dont-show-suffixs (suffix? page)]
    remove-each page pages [find to-string page "/"]
    dont-show-files: [%rebol276 %sitemap %.ftpquota] 
    remove-each page pages [find dont-show-files page]
    print "<hr><br>Edit Existing Pages:<br><br>"
    foreach page pages [
        if ((suffix? page) = none) [
            print rejoin [
                {<a href="./sitebuilder.cgi?name=username&pass=password
                    &subroutine=edit&file=}
                to-string page {">} to-string page {</a> &nbsp; &nbsp;
                } ; <br>}
            ]
        ]
    ]
    print {<br><br><hr>}
    print {<a href="./sitebuilder.cgi?name=username&pass=password
        &subroutine=cleanedit&file=sitemap.r">Edit Site Map</a>    }
    print {<a href="./sitebuilder.cgi?name=username&pass=password
        &subroutine=buildsite">Build Site</a>    }
    print rejoin [
        {<a href="./} (to-string first load %sitemap.r)
        {.html" target=_blank>View Home Page</a>    }
    ]
    print {<a href="./sitebuilder.cgi?name=username&pass=password
        &subroutine=console">Console</a>    }
    print {<a href="./sitebuilder.cgi?name=username&pass=password
        &subroutine=instructions">Instructions</a>}
    print {<br></td></tr></table></center></BODY></HTML>} quit
]
; if constructed edit link has been submitted:
if submitted/6 = "edit" [
    write/append to-file rejoin [what-dir submitted/8] ""
    if not exists? %./openwysiwyg/scripts/wysiwyg.js [
        write/binary 
            %./openwysiwyg.rip read/binary 
            http://re-bol.com/openwysiwyg.rip
        print {
            <center><table border="1" width=80% cellpadding="10"><tr><td>
            <center><strong>INITIAL SETUP: PLEASE RELOAD THIS PAGE AFTER
                FILES HAVE BEEN UNPACKED...</strong>
            </center></td></tr></table></center></BODY></HTML>
        }
        do %openwysiwyg.rip
        print {
            <center><table border="1" width=80% cellpadding="10"><tr><td>
            <center><strong>FILES HAVE BEEN UNPACKED: PLEASE RELOAD THIS
                PAGE NOW</strong>
            </center></td></tr></table></center></BODY></HTML>
        }
    ]
    ; backup (before changes are made):
    cur-time: to-string replace/all to-string now/time ":" "-"
    document_text: read to-file rejoin [what-dir submitted/8]
    make-dir %edit_history
    write to-file rejoin [
        what-dir "edit_history/" 
        to-string (second split-path to-file submitted/8) 
        "--" now/date "_" cur-time ".txt"
    ] document_text

    ; note the POST method in the HTML form:

    prin rejoin [
        {<script type="text/javascript" 
            src="openwysiwyg/scripts/wysiwyg.js"></script>
        <script type="text/javascript">
            var full = new WYSIWYG.Settings();
            full.ImagesDir = "openwysiwyg/images/";
            full.PopupsDir = "openwysiwyg/popups/";
            full.CSSFile = "openwysiwyg/styles/wysiwyg.css";
            full.Width = "85%"; 
            full.Height = "250px";
            WYSIWYG.attach('all', full);
        </script>}
        {<center><strong>Be sure to SUBMIT when done:</strong><BR><BR>
        <FORM method="post" ACTION="./sitebuilder.cgi"> 
        <INPUT TYPE=hidden NAME=username VALUE="} submitted/2 {">
        <INPUT TYPE=hidden NAME=password VALUE="} submitted/4 {">
        <INPUT TYPE=hidden NAME=subroutine VALUE="save">
        <INPUT TYPE=hidden NAME=path VALUE="} submitted/8 {">
        <textarea id="textarea1" name="test1" cols="100" rows="15" 
            name="contents">}
        replace/all document_text "</textarea>" "<\/textarea>"
        {</textarea>
        <a href="./sitebuilder.cgi?name=username&pass=password
            &subroutine=listfiles-popup" target=_blank><FONT size=1>Files
            </FONT></a><BR><BR>
        <INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit">
        </FORM></center></BODY></HTML>}
    ]
    print {</BODY></HTML>} quit
]
; non-wysiwyg edit:
if submitted/6 = "cleanedit" [
    write/append to-file rejoin [what-dir submitted/8] ""
    ; backup (before changes are made):
    cur-time: to-streaaaeading replace/all to-string now/time ":" "-"
    document_text: read to-file rejoin [what-dir submitted/8]
    make-dir %edit_history
    write to-file rejoin [
        what-dir "edit_history/" 
        to-string (second split-path to-file submitted/8) 
        "--" now/date "_" cur-time ".txt"
    ] document_text

    ; note the POST method in the HTML form:

    prin rejoin [
        {<center><strong>Be sure to SUBMIT when done:</strong><BR><BR>
        <FORM method="post" ACTION="./sitebuilder.cgi"> 
        <INPUT TYPE=hidden NAME=username VALUE="} submitted/2 {">
        <INPUT TYPE=hidden NAME=password VALUE="} submitted/4 {">
        <INPUT TYPE=hidden NAME=subroutine VALUE="save">
        <INPUT TYPE=hidden NAME=path VALUE="} submitted/8 {">
        <textarea id="textarea12" name="test2" cols="100" rows="15"
            name="contents">}
        replace/all document_text "</textarea>" "<\/textarea>"
        {</textarea><br>
        <a href="./sitebuilder.cgi?name=username&pass=password
            &subroutine=listfiles-popup" target=_blank><FONT size=1>Files
            </FONT></a><BR><BR>
        <INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit">
        </FORM></center></BODY></HTML>}
    ]
    print {</BODY></HTML>} quit
]
; if edited file text has been submitted:
if submitted/6 = "save" [ 
    ; save newly edited document:
    write
        (to-file rejoin [what-dir submitted/8])
        (replace/all submitted/10 "<\/textarea>" "</textarea>")
    either (submitted/8 <> "sitemap.r") and (
        submitted/8 <> (to-string first load %sitemap.r)
    ) [
        print {<center><strong>Document Saved</strong><br><br>}
        recurse-sitemap: func [page] [
            append sitemap-pages page/1
            if not (page/2 = []) [
                foreach block page/2 [recurse-sitemap block]
            ]
        ] 
        sitemap-pages: copy []
        recurse-sitemap load %sitemap.r
        prin {<table border="1" width=80% cellpadding="10"><tr><td>
            <center>Now ADD this page as a SUB-PAGE of another in
            your site map:<br><br>
        }
        foreach page sitemap-pages [
            prin rejoin [
                {<a href="./sitebuilder.cgi?name=username&pass=password
                    &subroutine=addsitemap&newpage=}
                submitted/8 {&existingpage=} page {">} page {</a>    }
            ]
        ]
        print {
            <br><br>If you've ALREADY added this page to your site map,
                or if you do not want it in your site map
            <a href="./sitebuilder.cgi?name=username&pass=password
                &submit=submit"><strong>click here</strong></a>
            </center><br></td></tr></table></center>
        } 
    ] [
        print {<html><head><META HTTP-EQUIV="REFRESH" 
            CONTENT="0; URL=./sitebuilder.cgi?name=username&pass=password
            &submit=submit"></head>}
    ]
    print {</BODY></HTML>} quit
]
; If page has been added to site map via link:
if submitted/6 = "addsitemap" [
    recurse-add-sitemap: func [page] [
        if page/1 = (to-file submitted/10) [
            new-block: copy []
            append new-block (to-file submitted/8)
            append/only new-block []
            insert/only page/2 new-block
        ]
        if not (page/2 = []) [
            foreach block page/2 [recurse-add-sitemap block]
        ]
    ] 
    recurse-add-sitemap new-site-map: load %sitemap.r
    save %sitemap.r new-site-map
    print {<html><head><META HTTP-EQUIV="REFRESH"
        CONTENT="0; URL=./sitebuilder.cgi?name=username&pass=password
        &submit=submit"></head>}
]
; If file upload has been submitted:
if ((find submitted/2 {Content-Disposition: form-data;}) <> none) [
    decode-multipart-form-data: func [
        p-content-type
        p-post-data
        /local list ct bd delim-beg delim-end non-cr non-lf non-crlf
            mime-part
    ] [
        list: copy []
        if not found? find p-content-type "multipart/form-data" [
            return list
        ]
        ct: copy p-content-type
        bd: join "--" copy find/tail ct "boundary="
        delim-beg: join bd crlf
        delim-end: join crlf bd
        non-cr:     complement charset reduce [ cr ]
        non-lf:     complement charset reduce [ newline ]
        non-crlf:   [ non-cr | cr non-lf ]
        mime-part:  [
            ( ct-dispo: content: none ct-type: "text/plain" )
            delim-beg ; mime-part start delimiter
            "content-disposition: " copy ct-dispo any non-crlf crlf
            opt [ "content-type: " copy ct-type any non-crlf crlf ]
            crlf ; content delimiter
            copy content
            to delim-end crlf ; mime-part end delimiter
            ( handle-mime-part ct-dispo ct-type content )
        ]
        handle-mime-part: func [
            p-ct-dispo
            p-ct-type
            p-content
            /local tmp name value val-p
        ] [
            p-ct-dispo: parse p-ct-dispo {;="}
            name: to-set-word (select p-ct-dispo "name")
            either (none? tmp: select p-ct-dispo "filename")
                   and (found? find p-ct-type "text/plain") [
                value: content
            ] [
                value: make object! [
                    filename: copy tmp
                    type: copy p-ct-type
                    content: either none? p-content [none][copy p-content]
                ]
            ]
            either val-p: find list name
                [change/only next val-p compose [
                    (first next val-p) (value)]
                ]
                [append list compose [(to-set-word name) (value)]]
        ]
        use [ct-dispo ct-type content] [
            parse/all p-post-data [some mime-part "--" crlf]
        ]
        list
    ]
    cgi-object: construct decode-multipart-form-data 
        system/options/cgi/content-type copy submitted-bin
    ; probe cgi-object ; displays all parts of the submitted object
    ; Write file to server using the original filename, notify the user:
    the-file: last split-path to-file copy cgi-object/photo/filename
    write/binary the-file cgi-object/photo/content
    print {<center><a href="./sitebuilder.cgi?name=username&pass=password
        &submit=submit">Back to Sitebuilder</a><br>}
    print {<table width=80% border=1>}
    print {<tr><td width=100%><br><center>}
    print {
        <strong>UPLOAD COMPLETE</strong><br><br>
        <strong>Files currently in this folder:</strong><br><br>
    }
    folder: sort read %.
    foreach file folder [
        print [rejoin [
            {<a href="./} file {" target=_blank>} file "</a><br>"
        ]]
    ]
    print {<br></td></tr></table></BODY></HTML>}
    quit
]
; List existing files:
if submitted/6 = "listfiles" [
    print {<center><a href="./sitebuilder.cgi?name=username&pass=password
        &submit=submit">Back to Sitebuilder</a><br>}
    print {<table width=60% border=1 cellpadding="10">}
    print {<tr><td width=100%><br>}
    folder: sort read %.
    foreach file folder [
        print [rejoin [
            {  <a href="./sitebuilder.cgi?name=username
                &pass=password&subroutine=cleanedit&file=}
            file {">(edit)</a>  }
        ]]
        print [rejoin [
            {<a href="./} file {" target=_blank>} file {</a><br>}
        ]]
    ]
    print {<br></td></tr></table></center></BODY></HTML>}
    quit
]
if submitted/6 = "listfiles-popup" [
    print {<center><table width=80% border=1>}
    print {<tr><td width=100%><br><center>}
    folder: sort read %.
    foreach file folder [
        print [rejoin [{<a href="./} file {">} file "</a><br>"]]
    ]
    print {<br></center></td></tr></table></center></BODY></HTML>}
    quit
]
; Run REBOL console (for file and OS operations):
if submitted/6 = "console" [
    if not exists? %rebol276 [
        print "<center>REBOL version 276 required!</center><br>"
    ]
    print {<center><a href="./sitebuilder.cgi?name=username&pass=password
        &submit=submit">Back to Sitebuilder</a></center>}
    entry-form: [
        print {
            <CENTER><FORM METHOD="post" ACTION="./sitebuilder.cgi"> 
            <INPUT TYPE=hidden NAME=username VALUE="username">
            <INPUT TYPE=hidden NAME=password VALUE="password">
            <INPUT TYPE=hidden NAME=subroutine VALUE="console">
            <INPUT TYPE=hidden NAME=submit_confirm
                VALUE="command-submitted">
            <TEXTAREA COLS="100" ROWS="10" NAME="contents"></TEXTAREA>
            <BR><BR><INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit">
            </FORM></CENTER></BODY></HTML>
        }
    ]
    if submitted/8 = "command-submitted" [
        write %commands.txt join "REBOL[]^/" submitted/10
        ; The "call" function requires REBOL version 2.76:
        call/output/error 
            "./rebol276 -qs commands.txt"
            %conso.txt %conse.txt
        do entry-form
        print rejoin [
            {<CENTER>Output: <BR><BR>}
            {<TABLE WIDTH=80% BORDER="1" CELLPADDING="10"><TR><TD><PRE>}
            read %conso.txt
            {</PRE></TD></TR></TABLE><BR><BR>}
            {Errors: <BR><BR>}
            read %conse.txt
            {</CENTER>}
        ]
        quit
    ]
    do entry-form
]
; Build site:
if submitted/6 = "buildsite" [
    if not exists? %menu.tpl [
        write %menu.tpl decompress #{
        789CB556DB4EDB40107DE72B0623A456AA63C7691E00AFA5247649A484A46129
        E2A9F265B15D8C9DAE9D00ADFA41FDCBCEAEED90847015355292DD999D3D73E6
        CC1873D71EF7E8C5C4813E1D0D6172D61D0E7AA0A89A76DEEA699A4DEDD2F0B9
        A103E56E9AC7459CA56EA269CE8962ED98C268997DA7635B261DD0A163EDE063
        EEAA2AA02BF3E6711230FEBD888B8481AA5A20CD5AE96A8E1CDA81A828662AFB
        398F17A497A5054B0B95DECD18F8E5822805BB2DB4A8B84E8EC08F5C9EB382DC
        C46990DDE46AD3681B02860CD4A774A23A5FCF06DF88327143A63A18802BD01B
        9F50E7841265CA16CC4D641A1FC09E7357E4428C4FF78991A6F151C43BA51743
        07042FD5F57E9EE3BE7B18650BC6E137824B327E085E326747203CD480F95919
        F110E629269DC429DA3CD7BF0A79863B87B0F7E5C0B11D1BFE2003F206BC4993
        DCED98DDB17D015ED81371C99E2E1FDCA69D2E027193384C89CF443E2B1189A2
        809771BC8BE8E0B32499B84110A72131E4EA74E6FAE52A62711821934D5DDF57
        E0260E8A882807ED7D912A15378BEFA9F8B037C35788121120E4EC0E161D09A6
        C8664B78EF85482EDE00A93A6EB4CAD3DB3055676E2214658DB0B986B0A9BF1C
        220868880C6F9BAC15072D5F506DA53C48374110D807BF1869A1E5944EC727C7
        F8C38588B34BA2A088D96D43285BB1FAD9353335D712CAA8DC34114A7C4F7017
        2FC30F418826132CB79EA0C79397574934756B13A96CC41A49435BC5620E46C7
        95B3E7E64C0819974885D0AA3385C1A873ECAC143ACA9134863F72EE8B581173
        D1D0F8310B3116E654F6FC7A16756D9F97D35A3EFF5B5CD551437F58DAD5CA96
        3A929535ACBAB02396CE97E5ABAAB72D6DC1C6EB1AED0194AE909F24ABCC0E7B
        D9326BE3E6F0C5FA5DE562F89A5AEDB2D45085AE1ECB5321B792A1DA074C8F57
        4E0F51BFB87A7B97F279DFFA9945F02C8BF7055DF273CF4211BCB81ACB38CBF1
        29E0949AA83AFCD102CCDC22DAE0FF125F6E2B00DE21918DBE5A0F87AA457A53
        D25AE7F63513BCD97E6B976D657855DD9B7C556FFE923231E56A716E6AF3BEB3
        1EB73CF71AD90B5AE2AF4EA7BD6DA6D76DF25498F295FD449847E647D3EA65B3
        3B2E4EC15F3074FD006814E770CE3C3845AF06749204A43D07CE72C6172C686C
        1D2F2FA747125A954893FFC3EDFC039C3D1A760A0A0000
        }
    ]
    if not exists? %nomenu.tpl [
        write %nomenu.tpl decompress #{
        789CAD556D6FDA3010FECEAFB8A6AAB4490B09B47C288D235192162468197557
        F5D3E4246E92CD4B9863A0DDB41FB47FB973121874636DA7FA83E397E3B9E79E
        3B1FCE9E77D9A7B7131F06743C82C9F5E968D807C3B4AC9BC3BE6579D4AB2E8E
        9A3650C9B22255699E316159FE85E1361C7DE93A03BFE7B90E1DD291EF420387
        B3679A80B63C98A722E2F2A34A95E0609AF5B555D9369CB14F7B90283533F9D7
        79BA20FD3C533C53267D987108AB0D3114BF5756A2BE88130813260BAEC832CD
        A27C5998AD76A76DAC8006944E4CFFFDF5F00331262CE6A68F00D280FEE505F5
        2F2831A67CC19928037903DE5C321D0D69BFFB1D1A691DBDD57857F476E48356
        A6761F16059EB36E922FB884EF484EE4B20B8198F313D01666C4C3BC42ECC23C
        C3A8459AE15DC0C2CFB1CCF1A40BFB67C7BEE77BF00325283DA027AB54AFE19C
        5E7AB710C47D8D4BF6ED72E031ED9D221126D2382321D7F16C2012C3802097E8
        8BD8107221262C8AD22C26ED7277356361B54B781A27A864CBB60F0C58A6914A
        8871DC39D0A152ED597FA77AF21EC3D78C840688257F8045AF24A3F2D99ADE6B
        312A37DB9476330A041EAF705AB6EB4CB66472CB4A6390487E478CA68505C3EF
        9BBA8A0CD7198ECF6BE380155C270AB7C846E7C29FC270DC3BF73702490AE4CD
        7151C89018096778DCFC348B11C96295236B826BEAE969BA53CCA7A55BE5FFAE
        1CAF2B253C2BBD355A1B05AD8574ACF5424565B42F016AD9EB7AD38CD6A08F5B
        C48CA94477880D6F28E74BBDEDA6FDCFC4E06B463D3372B82DE64B0ABCD5F9CF
        B4FC3DC28D52F943AABA31566AD52295E1E154E2E257D3DEA8C8DD374F3DFCBA
        15ADC2E9A0EDA387E69C617FAD1A225926C813C97EE3A4E5F6F3D983D4BF829F
        D0B6ED63A0495AC00D0FE00AAD9A003D21A0342840F282CB058F9A8EA5E1DCED
        07F5FCC050885A5AABFC736AFC02A1651F4AE3060000
        }
    ]
    homepage: to-string first load %sitemap.r
    current-path: rejoin [
        {<a href="./} homepage {.html">} homepage {</a>}
    ]
    begin-recurse: true
    recurse: func [page current-path][
        either begin-recurse = true [
            print-path: (to-string page/1)
        ] [
            print-path: rejoin [current-path { : } (to-string page/1)]
        ]
        begin-recurse: false
        either (page/2 = []) [
            constructed: replace (read %nomenu.tpl) 
                {<!-- sitebuilder_content -->} (read to-file page/1)
            constructed: replace constructed 
                {<!-- sitebuilder_title -->} (to-string page/1)
            constructed: replace constructed 
                {<!-- sitebuilder_path -->} print-path
        ] [
            constructed: replace (read %menu.tpl)
                {<!-- sitebuilder_content -->}(read to-file page/1)
            link-list: copy {}
            foreach item page/2 [
                link-list: rejoin [
                    link-list
                    {<TR><TD style="border: solid" }
                    {onmouseOver="this.bgColor='#FFFFFF'"; }
                    {onmouseOut="this.bgColor='#D3D3D3'";> }
                    {<CENTER>
                    <FONT face="Arial, Verdana, MS Sans Serif" size=1>}
                    {<A HREF="./} (to-string item/1) {.html">}
                    (to-string item/1) {</A>}
                    {</FONT></CENTER></TD></TR>}
                    newline
                ]
            ]
            constructed: replace constructed 
                {<!-- sitebuilder_links -->} link-list
            constructed: replace constructed
                {<!-- sitebuilder_title -->} (to-string page/1)
            constructed: replace constructed
                {<!-- sitebuilder_path -->} print-path
        ]
        write (to-file join page/1 ".html") constructed
        print page/1 print { ... DONE<br>}
        if not (page/2 = []) [
            if (to-string page/1) <> homepage [
                current-path: rejoin [
                    current-path
                    { : <a href="./} (to-string page/1) {.html">}
                    (to-string page/1) {</a>}
                ]
            ]
            foreach block page/2 [recurse block current-path]
        ]
    ]
    print {<center><table border="1" width=80% cellpadding="10"><tr><td>}
    recurse mymap: load %sitemap.r current-path
    print {</td></tr></table><br><a href="./sitebuilder.cgi?name=username
        &pass=password&submit=submit">Back to Sitebuilder</a></center>}
    if not exists? %index.html [
        write %index.html rejoin [{
            <html>
            <head>
            <title></title>
            <META HTTP-EQUIV="REFRESH" CONTENT="0; URL=./}
                (to-string mymap/1) {.html">
            </head>
            <body bgcolor="#FFFFFF"><div id="divId">
            </div>
            </body>
            </html>
        }]
    ]
    quit
]
;  Print instructions:
if submitted/6 = "instructions" [
    print {<pre>}
    print instructions: {
    REBOL WEB SITE BUILDER:

    This script enables you to easily create, edit, and arrange HTML pages
    on your web site.  The first step is to create and/or upload page
    content.  The built-in WSYIWYG HTML editor allows you to layout pages
    visually, without having to write any code.  It works just like a word
    processor, except it runs directly in your browser, right on your web
    site.  You can adjust fonts, colors, and all essential formatting/
    layout options.  You can add tables, images, links, and other
    elements, all without writing any code.  Of course, if you prefer to
    write your own HTML code or copy/paste from other sources, you can
    switch instantly between visual and code view, for complete control
    and instant preview.  The built-in file upload allows you to upload
    any HTML files, scripts, images, or binary files of any sort, from any
    computer.  The template system automatically builds menu links to
    other pages, using a simple and quick site map layout that you
    specify, and the generated pages are all wrapped in templates that you
    can upload or create/edit directly online (2 generic templates are
    included to get you started).  Because this whole system runs in your
    browser, you can add pages, upload files, and edit site content
    instantly from any location, using any OS, without installing any
    software.


    CREATING AND EDITING PAGES:

    To create a new page for your web site, simply type in a name for the
    page and click the "Create New Page" link.  The visual editor will
    open, and you can begin editing content.  You can create new pages
    from scratch or copy/paste content directly into the visual view.
    Page names should NEVER CONTAIN SPACES (use underscores instead), and
    should not have any file extensions.  It's suggested that title case
    be used for page names (every important word capitalized).

    To upload images, scripts, or any other content that you've created on
    your local computer, simply click the "Choose" button and then the
    "Upload" button. 

    You can edit any text or code on a page, whether it was created using
    the online editor, or uploaded, by simply clicking the file name in
    "Edit Existing Pages".  To add an image to a page, simply click the
    image icon and type in the file name of any image that you've
    uploaded.  Adding, editing, and previewing scripts is as simple as
    clicking the HTML/Text button, and using the built-in preview button.
    Centering and aligning content, changing font sizes, styles and
    colors, creating bulleted lists, and all typical operations function
    just like they do in most word processors.  Just select items and
    click on the icons to adjust your layout.  It's all very easy and
    intuitive, even for absolute beginners.


    THE SITE MAP:

    When you are done editing/uploading content pages, you will be asked
    if you want to add them as SUB-PAGES of other pages on your site.  A
    site map is automatically generated, and published pages contain
    automatically generated menus which enable users to easily navigate
    around your site.  The site map can be edited to easily arrange page
    links on your site, based on the simple sub-page layout.  Any page
    content added to the site map is also automatically framed in nicely
    designed templates, to give your entire site a consistent look and
    feel.

    If you want to edit the order of pages in your site map, or add/remove
    pages from your site, click the "Edit Site Map" link.  Starting with
    the home page, every entry in your site map is simply a BLOCK
    containing 2 items: 
 
    SOURCE FILE NAME:

        This is a file name containing page content that you've created,
        which you want to appear in an .html page of the same name on your
        site.  Content file names should be listed exactly as they were
        named when creating or uploading them, as they appear in the edit
        list.  In the site map, all source file names MUST BE PRECEDED BY
        A PERCENT SYMBOL ("%").

    SUB-PAGE LINKS: 

        Each page entry in your site map must be followed by a pair of
        square brackets.  These brackets contain a block of links to other
        pages on the site, to appear in a link menu on the current page.
        The home page can contain as many sub-pages (menu links) as you
        want, and any sub-pages can contain as many sub-page links as you
        want, and so on, for as many levels deep as you want.  

    Your site map must have one and only one "home" page.  It can be any
    file name you've created - typically "Home" (a %Home file is
    automatically created when this script is first run).  This script
    automatically creates an index.html page that forwards to your home
    page, if no index.html exists.  It's recommended that you keep your
    home page file named "Home".

    Here's an example of how your site map would look if you only wanted
    one page to appear on your web site, labeled "Home.html":

    %Home []

    The file name (%Home above) contains the name of a source file to be
    processed (a content file that you've previously uploaded or created
    with the built-in editor).  The block following it (empty above)
    contains the names of any SUB-PAGES that will be processed and
    automatically linked to it (none in the case above).

    Below is an example of how the site map would look if you wanted a
    site made up of a home page and two sub-pages.  Home.html, 
    Page_One.html and Page_Two.html would all be created from the source
    files listed, and a menu bar would be automatically generated and
    placed on Home.html, linking to the 2 other pages.  Neither
    Page_One.html nor Page_Two.html would contain any menu bars with
    links, because they don't contain any sub-pages:

    %Home [                         
    ; your home page (index.html forwards to it)
        [%Page_One []]              
        ; Page_One.html appears in the menu bar of Home.html
        [%Page_Two []]              
        ; Page_Two.html appears in the menu bar of Home.html
    ]

    The next example site map below contains a home page with 5 sub pages,
    the 3rd of which contains 2 sub pages, and the 2nd of that contains 3
    sub pages.  In the generated .html pages, link menus are only placed
    on pages which have sub-pages (i.e., only Home.html, Page_Three.html
    and Page_Three_B.html below would contain link menus):

    %Home [                      
    ; your home page
        [%Page_One []]           
        ; Page_One.html appears in the menu bar of Home.html
        [%Page_Two []]           
        ; Page_Two.html appears in the menu bar of Home.html
        [%Page_Three [           
        ; Page_Three.html appears in the menu bar of Home.html
            [%Page_Three_A []]   
            ; Page_Three_A.html appears in menu bar of Page_Three_A.html
            [%Page_Three_B [     
            ; Page_Three_B.html appears in menu bar of Page_Three_B.html
                [%Page_3_B_1 []] 
                ; Page_3_B_1.html appears in menu bar of Page_Three_B.html
                [%Page_3_B_2 []] 
                ; Page_3_B_2.html appears in menu bar of Page_Three_B.html
                [%Page_3_B_3 []] 
                ; Page_3_B_3.html appears in menu bar of Page_Three_B.html
            ]]
        ]]
        [%Page_Four []]          
        ; Page_Four.html appears in the menu bar of Home.html
        [%Page_Five []]          
        ; Page_Five.html appears in the menu bar of Home.html
    ]

    The key to understanding the site map is that any source file names
    followed by a link block will contain an auto-generated menu of links
    to those sub-pages in the created .html file.  Pages without link
    blocks do not contain any sub-page links.  They are simply wrapped in
    a template.  Of course, you can manually link to any page that you've
    created, if you don't want any auto-generated link menus or template
    design to appear on your site.  You can use this script to simply
    upload content, or to create/edit HTML/script files.  If that's the
    case, you don't need to create a site map.

    Once you've finished creating content files, and have arranged them
    into a site map, simply click the "Build Site" link.  You can then
    view the generated web site by clicking the "View Home Page" link.


    OTHER FEATURES:

    If you need to perform any file or OS operations, click the "Console"
    link.  You can run operating system commands using the following
    format (replace "dir" with any OS command):

        call {dir}

    You can also use the console to run any REBOL functions/scripts (for
    any sort of batch file operations, text searches, to download
    file/directories from other FTP sites, etc.).  This adds enormous
    power to the system:

        rename %oldfile.txt %newfile.txt
        delete %unwanted_file.txt
        foreach file (read ftp://u:p@site.com/) [
            write file read (join http://site.com/ file)
        ]
        (You can perform almost any non-interactive operation possible
        in the REBOL console)

    During use, backups are automatically created of any file which is
    edited using the built-in editor (saved in the %./edit_history
    subfolder), so you can always easily fix mistakes or revert to
    previous versions of a page or site map.  It's all extremely SIMPLE
    and QUICK to implement and use.  New users can learn the system in a
    matter of minutes (the syntax pattern for editing the site map is the
    only thing that requires any thought whatsoever, and that's only
    necessary if you want to make _changes_ to the site layout).


    INSTALLATION:

    To install, just copy this script and an appropriate REBOL interpreter
    to your web server, (version 2.76+ is required for console
    operations), set permissions and the shebang line of this script, then
    start adding/editing pages to your site.


    TEMPLATE FILES (for advanced users):

    Two generic page templates are built into this script, but ANY HTML
    template can be added and used on your site.  Template files are
    simply HTML files that act as a "frame" for new content that you
    create with this script.  They can be edited to radically change the
    look, feel, and design of destination .html files generated by this
    script.

    Templates are extremely simple to create.  They can be created/edited
    directly online using the built-in editor, or uploaded and edited
    later using this script.  IMPORTANT:  Code files such as templates
    should be edited using the plain text editor (with no visual WYSIWYG),
    available by clicking the "Files" link, next to the "Upload" button on
    the main page of this script.

    NOTE:  The built-in templates insert a header image at the top of
    every page (%header.jpg by default).  If you want to use the built-in
    templates, you can simply upload a header image to appear at the top
    of every page in your site.  Just create your own image, save it as
    "header.jpg" and use the built-in upload facility to upload it to your
    web site.  That's all you need to do to create a minimally unique
    design for different sites.  If you do this, try to keep the
    header.jpg image download size small.  You can reduce the .jpg quality
    and number of colors in your image editing software.  The shape of a
    header image should be like a banner - avoid letting it get too wide
    or too tall, or it will take up too much screen real estate on your
    site (500x100 pixels is a good ball park size for the built in
    templates).

    Templates contain 4 short lines of code that indicate where the source
    file text/code should be placed on your destination pages, and where
    the link menu should be placed on pages with sub-page link blocks.
    You can use existing HTML pages to create templates or create
    completely new designs for every web site.  To make them work with
    this script, simply insert the codes below where you want the content
    to appear on generated destination pages:

    sitebuilder_title     
    ; Page title in head tag  * By default same as the source file name *
    sitebuilder_links     
    ; Link menu(s) generated by this script (as defined in your site map)
    sitebuilder_path      
    ; Links through the hierarchy of sub-pages, back to your home page
    sitebuilder_content   
    ; All of the data contained in the source file of each content page

    There are two main types of templates:  those with menu bars, and
    those without.  The built-in template %menu.tpl displays a menu of
    links on the left side of the page (each with a text rollover effect).
    The %menu.tpl file is used for any source pages that have ONE OR MORE
    sub-page(s) in the link block.  The built-in %nomenu.tpl template is
    used for pages with EMPTY link blocks.  You can edit the built-in
    template files, or create new HTML templates from scratch.  It
    literally takes just a few seconds to create template files from
    existing HTML pages.  Examine the built in templates to see how it
    works - it's very straightforward.  Simply name your templates
    menu.tpl and nomenu.tpl, then upload them to the folder on your server
    which contains this script.  
    }
    print {<pre>}
    quit
]
quit


REBOL [title: "Sitebuilder Makedoc"]
editor decompress #{
789CED9DFF72DC4696A5FFD753606AC26D71961481C46F5952470248B4B5634B
1E89EE0E8757EB28B240B15A6415BBAA689AE3D0BBECA3EE7733011400526D77
B727663676D46D89AC02129937EF3DF79C9B5959FFFC4F4F9E1C6F9AD3F5A54A
13EFE86CFBE88D295E7FE57DFFEED1F566B9DA79B3B3F56AD7AC7647BBBBEBE6
A9B76B7EDA1D5FECAE2EFFF7F1ACBDE2FB675F9E7CFDD58B675F1A5DBD7876F2
F2E42BF362F676B96B4E6F96978B66337B76EC5E7C76EC2E295E57DFBD78F768
D3CC174767EF974FBDF39BD599F7FDF1E5FA6C7EE92DE6BBB9777A737EDE6CDE
7DFFC8E3CFF676B93BBBF0B677DB5D7375BCBEDE2DD7ABED3177D2F1BFDC34DB
DDD155B3BB582F3C77B9FC997DF3FAEDC96CF082FC91969F7A57F30F8DB7DDD1
F5F7FFE405BEF247D7B8074FAF4AC26C7CD9EDC5F2B2F1BEBF5E6F97BBE58FCD
EF3D3B98E5BAEBE4F57AB3DB1E2F57D737BBB649D7C8BB718FE4CFFCFABA592D
86C3BE77C9D96533DF3CF4E6BB47F77F9AFDC1C8C8DD601FB01916DBDC1DB9A1
B9BBDCDF72C3A3778F1E6D6F4EAF96BB5DB378EA2D9AB3F5A29139F2FA578F4E
97ABA75E37778F1E7DE12DCFBDD5DAF5FF62BEF54E9B66B5BFFCD06BE7C8BBD9
369BE3EBF976FBF4D1236E79FCB8BFE65879CF6962D51C78EB8D37783DEA5E3F
6867B273387ABF5EBD7F31FB93A7BD37DE2BEF25FFFDC1F38E18FDBBE185B36F
36CB1FE7BBC67BDB6C7E6C3687DE57EBF7CB95F7862E2D378C10D76C9B7A56BC
B1FF8D6E7F56BF7EF3B5F7B539F9F275F57CC664EF669E2E4F5EBE7EF57CF6E4
78BB77F127986236BE77E67DCB8057F32B8266E63D73AE2031F45C42C8DB2EFF
BD793E8BFD9927973C9FC9DFB3877B31F3BEC16AB7EBCDE257B52426FE444BCF
5EBEFAE6DB13EFE4BB6FCCF3D9DB6F8BAF5FE229AFF4D7F29B35FACCFBA3FEEA
5B7E75733019D2B363B1C7E8B59F9F1DDB6826B405033E7A1876275EF4857776
D19C7DD8CFBAD7300177DE6E79D5304FE2F1D79BF5FBCDFC4AFC67B93A5B6F36
CDD90EDF7874B3B7DBD915EE2B56F7AEF726E85EB4DD787475B7BF7EE851DED5
DDFE9E814B3D6A96BB0BC2F1F1E3EE3E9C6CDFC88137A76B8FBB5BED7BDD2F07
CE3F1F9F2FB964F8AC9FCB1623ABE5D641C29A18395F6FAE8E242CBEF878E03D
7BD17A780B00366CF6C6596EBDF58743EFFDDA5BAF1E7520D102F0CBCE38BD47
1D770EF16436BCF21393E1D9785BAD775EF3D372BBDBFEDEFB4C5CF76A7EFD64
D376E776C30BC3977FFEECCB3596F9FEDD476F78817DF1E78F32C134B9374182
9D3A9F699BFCC2DD73DCC2DBA0EDD94CDE75007BB369BC65D7B1815F6D9A3FAF
09D43D5AFEFCEC74F3E2D919466EF877373F057E4FB140B3793E0B66DEED72B1
BB789EF99F7967CDE5E5F57CB100DD78C727127672C3E28534D037E722DBA58D
5F11D9DEFEC641085D2C170BB0CE0650EF4C6D007D1C3BC8ECC52FB6D0BBDC03
2D44BFAA05AEDFAC6F76CB55DF8B662141DCDF5802DB4CE3ABE61648794FC03C
D8E483A8724EBE9B793FCE2F6FF8E5137DF9EB90D2FE3AB8D5C1C9C7410EBAA6
575BC295EC69538CF7D913979B88AFA3EDC5FAF6684B125CFEC435DF7FF64468
0857FCF9FA3D7FBFC7213F7B72BD929F4FAFAEF97BB394BF9B9F1A797D21EF4A
22E3E70B79FDDFEDBB3B86CADFD7D2CE467E7AFFEFF2B7BDFF6AE13AB569AED6
3F3647CD1C0E221D74BDF4BEB73070AF6792BFE487DFDBCB0E7E4513BB759B8D
DD5BB3E3D93B09105AFE9C79A0696FB194F05F6F96CD76620E99166B8C9EC275
81C600CE77D77FB959EFE6B63981B5B977CED4AF2DFEAD170BCFDEEDFD2D8374
77C87BC32C307B76B1B1F165F037CF4830CB70BEB1B3690397FF1C54018AF79E
D17BC42762DFC53FEC62D39C3F109EBFB71EFAD1EB43F0E7DF492CF14A1F523F
FF6E1F1BCF25287E270379FE71F488C93C10711FEFBDF6EC78FEC2FBDDEA747B
FD45FBCFA8898F185AC6BA6F78C8B03A946E0D2246FBF800E6FD864315E2B8DA
8FB7C7E0999B2921E9DED7F3EBC1A8FECFBD7F3FBEFB8FEDA3BD55DA98BD28E4
47DBAB7FAC471FBDC7FB893B5F6E609F97EBF930091D783F5BF89879BBF9E67D
B37BFEC3E9E57CF5E1C51F970488CD72E2BCFFA97659AE18C0CD9925EEB3172F
07BF49B73EDE77A9634972C73BFB93E447FEEDF2E527491AA089BE734D370B4F
5CC5BB5CAE3E3CC0E49F3E94F36D821992882EDF637F71B9DE30B717F3DD1138
3668207BD7528133979656985EB8E00EBC69B6027E9616B46CE2747EF6E1E6DA
7B7CDA0884C02EE72B018F393F5FCD17CDC1537BDDD9CDE64828E6D341E46E9A
EBCBF9193DBBBC1CBCBA5ADF1E5B323A7B3AF36647B31658CF6EAEB0D90F9203
9DCAF97523B1770BA5B1EF7C2666F9E182CEAF377703FE346DAA4789BECDD9F0
CEE3D93E41EF3BFE788B2A13027A7DB9DC1D5DCF77177DBB831E1DEC6F9D1D1D
CDEC701762E5D90FB3DE4ADE4C12A01BFABBF1E01FB5668736D2EF0BE20141DD
1226E8BA7D49BCC9B2DCA78F7A677C88B9755ED84AADA2E57DBBB5E70803C3C7
D14832CDD37B7AECFF37C6B69DFFD8FCAA4733ED0F3C361B3F56669208997B4B
6CD6FD12749C4E5414BF9CAD2FB74295E17A9BF5ADFC187757B4B51FF0679FD1
86E134721968C071F78C17C4D4B3FF35F875E00EFB57EF4FF23FCC263F85790F
A4E14F822242EDE8F66EBBBCBD7B6F11F17EC1C2625F9F5C67AD681C4E83E8A1
3EDBF6F58BDF0222ED3DFF8D93FF8D93FF8D93FFC138A98640A9FE53817254BB
F8CD28E625F16315DDD1F5FAFAE67A4A8671A55727AE1210BCA8E53A01D95727
2F8480FE17C56E8051A0A171E2D62E57FC5A2E6B5DCAFBDE6B235A7E15C0BDBC
EB5AEC26F1E900AA1EFF2AD83BF01E0FBD61FF56E04FA67FEC1B07F6495DC572
E8BECF5E8C12CCFD04C405BF28820EEE69EF7B2054B563F6DE628EC51E765A0D
3BF476D072DB1CB5AD778B3AB65430D1F26DFE6BAF3C725500F9FB38185DD756
2D1FDBB7648DE07B0CF97D574138BD5C9F7DF0DAF7BE9F3CDEBDFB6EB03EB207
BAD1739F12D5D777B2DCF589814C8D363218F6FABB4A91AD915FAD6F3D5D5524
89A5338087A7CE05ED8FBED17F30DEFA9C7975E51A9E75B7BED9D8CE7B62DFFB
33302AAD8C8D3BB6FFC3F9678F3BBF19BE30F6B61FBF2390A42B93928B9D8E21
28FFAE698B47EEE24125E65EFDE50145FE8B6B6313B13EBABE33E8CB73B1F4E7
04BFFEEA8DD1D5771EC320FAF79344421ECDC5A12C0B2CED6D6084F5D9DB39CF
81A14DA76DFCC47FD8D018EE79B754D345ECD9E592B8C0679A7DB462B5F1937B
A4FDEB8583FEA6B6DCF0EE93C5BA9F9F4939E5C5B30BA8E08B675F9B130DED39
F9E6C8FCDBB72FFFF87CF6C6D46FCCDB2F675E49FE30AF4E9ECFFC2FBC6FDF7C
F5FCB719FAB17DECC7878A6D9FCC14CCB39DCD3E3BB4D3BCEE27CBFB7139B7D5
9007D3C5DEB9BB0248871CBCF34B30B83C6F018F961EDFA7A5817F30894CE2E7
C862DA7DC0923F2DA4F6573DD46876F0C02DC7EB15096E7FDFA4DDE58A69D8B9
8B5AA8EDAF7D20BEFE1EC41E586B84DAEFBC4F19D576417E3EB2167E08A06DF2
1EAC390DEF78B06CF75FC27BAD5FBA22A8B4FBA0DBEDCBA5AD874CD7F6445DC1
54861DDB0C25945BC97BF02A59EFBFBADE34DBADF7CF63704CB3BCCCE3B0488A
34346191E54155D7B92A0ABF8EA2CA24516E8A2428EB248AD22AD1619D844951
C4719AE67155EA78D45892846999FB6960749A69A55490E5611A44659EFB5554
66B149D2DAA445ADFD20F37D3FCAD33C494C5CA828F655558D1A8BFC34D56115
A8BAF4833A35B52E6BFE5445E86761E507791DD745182679EA1726A86B15D746
45751D472A499432A3C67C5507A688824CFBB51FD5615404459026795CEAD457
858E4C94C679111945F75468CA24A91446C9EBCAA7E97163A650892AB2228BF3
8C3ED44595727B5485759E547114E695E12E556565A9B158A9741E46611C1886
1A9A3C1C3596557946038C8CB7B2A8D66952A779C69023632A1D68197D54A645
569A3256751A546189713353157E58A7A3C66A93972A4899AFCC447E5CC65A25
B45BE43AD6751D44455AF9213F2561ED573415055198E6CC795AEA24CCC7B3C9
5BB841120651CD0099FD2CAB3148AA354EA1B4CAFD3AD61821CA18A6CAE33A55
748909C8ABA42A0A359E80C0F8A92AD23A8C5591875808F3AB34553A5041A093
34088A2855AA2CD32452659065858FF142E3E726648E468D152A2D8CAF8DCA98
FA1C670C824A1765AAA308974C7552C6B9D67594976511574161CA5AA5595907
0C318EAB62D4982A23FC22CD4DACF90F37D32AF6F340A57E8A83AB38C5A94D1C
073ED358A60AE317356E5DE28978AD1E371627659686B9F183300BF1CA24F22B
A2AB52BE4F0499CC4FA300D3A701B352D32BE652F9695D1A9DC88EA5683CCCC4
8F5498263133542B7C4865756CA4ADBAA637651527DAC4254F0AEAB2F4555807
8A20AB711E1FDB8C6733C4A593AAF2CBCC8F921C57087D7AA99324C0E940003F
AB79852EC70677CCCAD4AF99F9524555968A29C6A85195959F156954ABA02A13
4D48D5461B5D6A66B552B98A52823B0443B2285655ACFC98C057455CFB404158
8F1AD34121C30A8352F3AFC9555E2438659E8ABB67551163CFB2C0948974B820
78932CCA02AC1304B956E3C694D18ABEA54916A43E9842D864819F62A740453A
8D7C53FB090E136ADFE89C48571126604679DB8F82896BC47E56452A1780CCA3
B036992EE244F959ACA350279A4E9A803857BA88309A4F206401014F30330B65
3E8E001D63AD0CFFCF545CF979A14A457CEA92008A194DA5F0BDBA602263E6BD
4CD3C44F8B92F1A7750EE295E3D98CB31A8C2B4D01EE319FA136197E4228FAE2
6544AE4E8D5F67491594855F96511DA56518E0BA05D8925713D750694C70F859
9E6529D0A88AC044A14F00C6384B00CAD6BE06DA1550981114607799A8806888
0C2E3A760DB0176C0C8933AC22FE5906B1EF875919FB65A0FC10B02042492B06
CFCDF2A82E7C13548121CC19C93802B04286B3975598A755159B3C4DD218CC00
5EFD84D8F171B82A232DA5CA1401B811614D00CE8FC33AAA82710428B108B782
4405A30257990A7ECF13C2B9AE749696824F3A4C82342CE23C01F74D982725F0
A8827C9C03F2B2E0E939781BD455402E0C535215AE5599308A990152514676AA
4C5CE746C7CA48C40509A6512A0CC77896076916047825B09556755428838533
9586F202468C485F55CD4BCC05310ABE06F43F232FE0B3E97802B28C449714CC
5212031E599D310558BAC87400848745146620711C1795292546A28C9EEBB852
442A683E6E4CD51A4BE0978AFF639222D4DA8013C08B0E089D0408CB12322BBE
2DF9BECAC2C417FCADF3BCAA27E0181574D75459A4AB089C080D2E1B034325F0
552564AAAC76C058D6601DCE1AC4451C9145D30A041C3BAD627492F4416F2309
29801128310F664905EAC1D9A2020CA234655A63131204A9C9C0AB90E4391926
CFE389898962C240F24F58457086D02F243B717D926B6C07122AA231F70D38EE
678AA674A1AA72425C1252274C0382845B93FCFD1C502D4B93629E3C24692A26
A18C63C5DF15A84B52E6F9519E63117F8C670061059F08540835A8E80C8118F8
A05B1EE478430AD49631C859F13C92A002235360B9CA201FBC36EE19EE9F0A2F
81EE04922A419C288225F83AE1152C18D16CC15486421488BB8C5733489C6F32
063B765ADA374C5D20548C70326596E152210F4F4C12E409DE4E27881F6801E9
8D440883C11EC472A0B22819A7BA94A90304E3AC1256A923ED33D890E41B1971
323FD6898D333F2617405FF2382713063C57A0454DF26698C66427986316E54A
F955813D147912E81522AB014AC2218B40616005FAE8930EF0243847914DC011
FE9B0525A626BFC646A93803E37555C0BF8A92FC820170AD384F31619A1363CC
A1C62C1AE7098A89CD0499486E51A6F34CFE357912910E027A95553842A6207B
B52441E1BAB130D38810C59E44663E6E2C08E1CF381299032F2F70777C22F14B
F025F241C23C0C60A798BDA22318348B41DD50E186290925CAC61004E6909CB3
248852A63A2DE99A8D719CB706D5E21082AC7C533003351201A641B4073509BF
82458E7B9624D823AA034179688BD855824B91C893183FD5E0535EA551296FE5
51C1F590FB5C928ED2261F170B7930FA20D2B01C7E22188B22AAE32C65F6813A
B8518D76810FE5404A4A8379A2D0195946800246753219664102F18B2CC92039
9132E223752EC0436242B790B922D825F19B4355CB2A4F723F82A1102ECCDC38
A190FE8860B25B96FA49129B94BFF0F5D04409E4282F4AD824C4027647EA015E
511C8544066E02DDC8F4A8B18A4949C32C2F62EC5F3089840B5C343735AC0918
2EC90E10C4843E31823CAB21F2B89B21BACA222AC7A222AC5011CA2F527C1122
95AB84A4E49784565197415EA44989C9924CA48A1F630E98765585CACF091A42
6B2C7712110D103B8220533E841D1CF3F15E1C34419EC1D4610E70352DF9D887
0842C7117F29E985C81843105116A30EE3921C9B97094C8F5154489E429792B3
4877F84590DA49A7E782CA3AC9A0068150BA71128E0218A0C411710D470F8971
B80D4E9B544C018F267F94051049B3D02FD208B311973E9042DE3613D7D0A2C4
B4F285F58669482E841CE69911C18318CC4B249C246A3279A9E0EE498933477E
98247E85281E47401EE369390E0EDB825998CCE06D01F10A8FC506E01A0E81B1
6179CA84426E80A30A56423E35C558D589AF1A12120415FE2AF11E92DC49BA29
302662045D47E0026415C988B155E457A617314AE04D9C3614161AA431830A12
F403610EB9CA72B27F44E24B1816D988275609B99AB916818E6B0A9C407EC7B3
1980C6293E9387E83F482D9430CCE22C29A3AA12E200A921E718900AF69F302E
1C511738AD5FE89C091DF74CA525E141F246EF94F44361C0402399E1A501AE49
9CE1CE581222A42149118E4B94071074C2601C01C84BE85389A80B092BB29170
5BA22997F4EF8B10C6B1321FD6E7E35ACCB129AB28C425EBA08CB2E930494E91
944442459E238260DE6515F836D3090BB73FD3B9324EE298C823F5126D113661
FE27AA4ED2770882C6883126BE068A2B68478193886645BBA7759042ED249786
800EDDD68110DA30CCA209DB16DA846D35040696480EA8C8A0712ECC446BD828
9204690D530B21C831FAA4CC6BB814142D8F101FE370020EC84344710C420B89
8981085824BFA70C90D950053901288138FB892AF3A8A255A4AED417CA316C47
1282F859CC3B26A42B4599E460385984194911AA3061E684A0E0FD58BCBA008A
A032F00D94D93836E34CA86C09358C8903E42D609341BA49BE704A121F4E4BE2
243C54CA6809A400FBC752240808FEF13083A0261041C3B880A130D0A2CA35BC
2A826FC77929521C4AC4E402F9C4565594211283B00AA55435E667151949A047
6A0BA83126B40812A00CCA5CA1336D88E6A8391C312228405D8D978750DD0ABB
6593C2520611106B947959A2754804115165D0761076F41BBC08C0817714E01E
C89D29B2A8D6A5847CE28F21880C039C407F806C9C1054AB33281D2189AFA11B
733446441842D6C99D105A4424616C7C8528CD8A680241C81BE13F6887083902
CE1ADA40E148F5A80040C80159081CD15D8838818772D605A90F015E8C299578
13530C438D82CA1037958ED22A24C39A38CE6C3E2D42520DE43D2C48A1C025EC
B6E2DF08A5E7FB9384E2E382058A8D9186127F28604847AC6BD2103EE6E38818
2B8871695498C8FDA030E014BF2067C70439CDF17DF84E16F164F806E0850646
B58686948C201024C6CDF2145190124AA5E4629809316126750D296C4243C8C4
64F5A04661C624E420F56996CB43BF346871262F242A2BB22B6441DAF285CA17
93621C49DB804B10A72A216B8B2A8619AB2A27A1202B91429978824991D71078
A9DDA28343E43F7A05A137B699CFCD68359D55107B082919857B4AF0D2401D73
2950A4252A4CF9A930455340FE134D2E51269816E398C098342EC5C84225B580
1F976710173F8229275028894BF1330DB94963A97130D9602FACBEAA27195D4B
2D061542C2204C6362D297526B9601E3C02263E5FF6865F2206CB28AD33285BC
3096148C1FCFA6C850C934262FC2B0409ED6842F7E0AF216688412F64677203C
F87D09D94ED117C02E38C27F553AC63380A448491335ECA9AC083D1118E8E03A
627211E799513E218986817CD4A812C87CCDD4223AFCA29C50F72465BE10CEE0
2DB41E158C628176C641E62B7030AB91F09A044A3E26E1C102E9AD2FB386300D
4D38E6673876104ACD8D304F997B2810A197936618180826623C2C74E04B4EC0
2DF05AA9AAC7647BF06A52D76014A412D2AFD81C67F37D61D799405B2505CC98
4C03812F0D3F1B34852F25307E159C0DFC740C41F81D941F6EC7E3A088CC6D02
E040FB91AB703932484C0A4E35385ED404661A55C0233E9E61BC6AE267618131
192619A22CA59815329E9CC8AED0BF702D5FE7356901E206ED0031A2943C8F60
872A0470B6710E206DA67E2AC5C414859E00B0558D326078B8B316C92205509F
945AD595A00AE32D9130C41D2C71821A46B02A89602C358F2D24FFD77E2A9953
500DEA2C3AD32F8B9A6C5F48C4A2BFA5FA0A094069EBB10E084C0111210874A0
7127A98C1564EE3405BA91A7BEEF4330D0DD0028041B1A11930D19BB02DD30E4
1869019238A843E83BDD2089D29EC9213CCC2A44B2465426C8469CB5222AE23A
945A5C12DB5487EB4C343A8442458C151501162742BC24CB711F2A0834933442
6247BF20178985023208CA214F50EED1E4E3B862AD0C860D9746C964752AE8A2
4D65C81EA54FB62318C9F08544945F964099F88EAFF18D0CFF9DC81DAB0D8A32
4276090DAA740E57E7FF4404D1C95C430FFC18E924BD01BB0B83DA257956B914
AFC6482BC57AC418720B61820A2497ABAA0EC01BF4363F64FC6B3509485B9146
2AC837AA4AC419196BE2B43028344D5469CD5D215EA01358A782AB63C23C0419
A3000B0875635C44782A7402C7C013B3B81E27614C91C9D24BA4650DA52C1935
DAB4347441DC94EC49722F918F10A4DC474A43F3606C264E229C319F64744453
5417A14F7E4C311C38894BF8B2085007C2D6A586428CF82964193642EED2B1C1
69425C88989B94098102C2868089E95194612AC42192097F2840B2AAA077157C
51F01B660F41C5C3B568D0180899F0B35AA45A20048A8623A6A9C813A68C44CA
CB01362B712BA2C2673EC9E5051859021F21E39C222DD847C044B2F203394733
49951CA25DC4B0EA84D1326FF0875401AC451C1546C414A3C62B8A645AC04CB9
B708A03439A91655216143EFF0765CA5424E1B4D5283B8413B0949419D804802
AD8CA9A16AE3098044A1A2B17CE64B8D29E717B801088DAD41FE5AD8202CD595
6F64258BCC2A1A52D62E6068E3C622C0546A57558D20885421C5071F21471266
2C3AB6D51785CA86155625FE418A455715C4298C6A2211B5A49C3CAAEB028E06
22FA2A960A9E89512668421F760B0E68A45989F8912537B282810CF94444594F
F859C55BF0BDA202D2143A0BCA01F180B5D2C38840523AD5708C18DE6C64ED0D
BFC381A15C7E00A71983A38F3E14859F87B92FC902EA9FC1008066C867902336
7180D0802D049686E365759C3119889038992CFC41F60B457E4CA1E9552A0B02
C280E995AE0105D48E0CA6081561282ABD80B1A009844D7221EA7ADC1811C754
332AD11F46D63D82BA4818536C0A21C3F81D198C2E63AABC824FF1C88C6041F7
25713459C422826AA430919862B604650C072D93A486F7F8A52F8C8C8043182B
D2540E621160E85D846582D41B8323045057320749CC68007E920BE09D0B8B24
8356F83D911B88E880A7088F894B8D7121CF64E809DBC63AA8223F0EA5D29862
259527167660E6B2181F4050C8B732569D5409710BBD876BF95267CA27A801C7
2563E8CC8451621D35173A9AD14D9D050AA60FC113590C37936845DAF9C8A104
8C548AEC370EA734115C6470606852E722744C50113D253AAE963527A49ECA51
D105FE0E61D1B25461D0C70A0799AC56478C3F0C70995A8A52912C2754B22580
5947E2244959291504924E25EA21F3402963866F135F6138CEE8515A903E040E
B5142E8C0C97A1891E8670AADC871CF30FAA8921CB33901EB1521513020C5663
3F53B05E59EBD304B192522FFD0364839A09418FC0210121428E7E27358E1884
242CF01A92C6B4E931D98B4557421E138014EB20484D5CA704818861E317A435
B02694F791AF31BABA9222425556798DEC50131654C98AAF1F8A92D12438E47D
0D8F039E4571A52800A93E67FC5B905B71E6284078403401AA6092D199B980A4
036B256390080CA108B7C864A3485613B5A2A6B16426B431C07D2B21B74033C9
3AACFD7142A965353F4E544A1CC11DD18A393E9212F24A6656475064D9E180D2
C9751986CA8408C714089465E9496C1AD8B1CFEB3081081C0EE31A3F87F58BFE
F063B4BEAC7C983A51D09702BF8D85622406462DF0A4C6FC8CE880D3108221C6
333CD048250261A97596A4E29E2828922D0245971A94CDA536A7233AAF63D2FB
7898515A06BCCBE80468EB1C6707DA605A6454051F422D26E4405226E29F2982
E8A06C615796498CE58ED479C891C871217A982711C196D3705449795D893256
41416AA9C830846E58C26864E45A85E118B6F10504A140561027F8184E5BA595
2CF2A56920F501E81ABE8B8448984DE419BA388921A6225193496955CA65A432
6EC2E7258100E22AC81829591845C504D708625315A1488A40C5222CC8EDB16C
F899B806ACA4B61AD3C07603301EAA06FB4735079057F259887231455C612360
C54046000CAE482A45D04FB59314975329DEFBF0FF0ABF83F721F9A318115705
00AE2C05A2217D65722BAA64C78962E0B1AA827104E85A6016456221CA270533
4659A993C7CABF588FE85068BE5AC46892A7518DCF3143B930F0C95A5D20E394
353E7C5DB63084314957AA719606400F8924594B15B68D472445013D444EC26D
9374CC35B0179107798124D780569C2A85D74A83A0A1C905D5755E44D83CCD61
2D6400DCA854241F38D1A48019222C61860C3414E515CBC26B9449393C953A54
5493C349AA6827208429402FC052D144AA4A70E0093DC88B022828D0961A41E8
97B24986648B1B57D824B13F45188EA67272930AAB5A16AD039C045A39E16751
C954C14C509AC89818E3C1961260C26832640E6D32CC63091D56891039D02E4E
646D16A9A5268BF281AC6216B40341417B96E29012501961186020304C3369B9
210FE611920D4FD54247450A1613ED94C30D21E25246CEA486A5C116787F095E
E3A011F30A0413ED6918A21A610805B2AD0A508AA4B46C9237F1CA322A60EEB0
6B80078D04470C0168E22F0A11E7AA527020A937C5852C7A13B1064107250D4C
3A59DDC94D98A6119E8824672E2A526D18930BF0735F760C41CF6B29C18525F6
8A4039020E118229F34216D12610944B2CE6D006D9F5141137A98123CA868D08
EC353064A286C113EDA4E54CC9DE151ACF02E4503D212EA444183D4333B28701
14045D8164A60E519502E23E4C95D42702CB573503914A98902E38D864C34C4E
5B4A169E6BE87382FF54D203D9A723DBCB545290A565479DA8BC3AABA5140771
2799270A2408C6A80191806BE048F05920AFAAA4701D8857205C33E02C8B756D
EA1055178BE690E25A207B4A125FD4EC181C6B1F5004873338AC6F77C7653510
9EE942C3D570285D26650EB621B5CBB8D6A126BB56626818456226E51B245520
650059DF20E36B910FC6C8BE47A947098C24C4554DDF193168267BA8E42DE04C
D6BAC63DB3C5CB0864E1F1C407A92493253ED003B307D828561982A0A822D948
901761922A9386509A4A6C3D267B05F0C0E3C06512A2C6AF2117A8701043E1C8
787A9E87017EE1CBE606888431C27753DC37035726D50353323335FC9EF88611
0512E055161538708882AD99CF0055823370A9EC425339098D870781460B4D2A
2ECC1DB728A488445F463A282364357034E0D2C38F3EDDDBE7DBAC6EECC925F7
F7F676EFFCF5FDBCD00EB40E8C9FB0A6E395C1563E6007854BA4105192070348
97AD30CA52640ECA011B24C0C9CA2F34BB56490C5F432BE49536393EAAAB1A8A
5FE37B52F683B1F804101C013DA572A9A910B1004738595F2507654C671A4818
6725C946B80DFC0EFA840F24FC244BAD0824686F5249592EA7631511A1646FC3
D8CC012A0F510B5F036C906AFCAC893AC425B04E9FB212DA93E7A9AD0BA3F368
1EED6579810138C7C3440C28A96E15B52421B2013CD6C89E91AC909D86085D8D
FC2227C15D912B410970071A7199205E27358290880B4885792A843B2AE8795C
012D0181880E84EFC212C95E45A4A5759319D9C805D7271166D3AD44789B6C9D
AE0C3407C002D86423852C2D6A701630D3715DCA5638B01B721BC8AE448229CB
180BC479DCB31C4621243760464B4C815FCA1A2F0880F225D2D09690C5AC44F7
E34570170404384E06222DA7D1D8663EF8ADEA2A16454A742159D22290B54274
07A2438A504867D42A04268402483536A4DF992FFB0B8209418797A035016349
46441732BC4235F96471D42FA941541D92DA9752BB5D1B20B1D4C00FF9239F6C
A8AE4A99FE4A5800262073E066290001AE1BF15ADC4A0045AAFDB2A00A318588
4621D2219095C7C9663A1F9D19C05E614908224038CF65D139A06B0A6D6590FA
6904E420F8954662D006D01742925108F118027968E29B4C6799B036244D8530
91A55D48167C3C979D14615A3211D07ED282F2A5EAEC9B406223D79370C2F964
DDDFD4B2035B895B43AF987F03C84A21B8908A27D4027E49528401892B6649C1
5510E4B19F41586180B80DA2119E2E3B3609492617D7922A0F2428954157F4BB
901228E86DA079742F5528B309D297B2094076D2902F20FD19BA03CE8EA4280A
9186B07D140F9A02FD85D041BAD1361E2D1BF4FC60DC984282FA28456C064752
52E837C8E83477759B5CB625A1274359C72C71E6288F08F75272134133E9591E
4336E110112147864825D354769B791697043498553278A2087E17489937AC65
91072107474CA73B0C2ABF96E5BA42328D91224E524BF527A1470864B007EE03
DDA863B81E1C46F6DA43D52BF810CD4FCA4750C61C0485E96A625C769D9A5C16
8D0B2D89BB929A1D815504E46DD96F0712919195ACB0E220D365979C882B0C58
56FB92E4C11FEC51DB557A235B444444F36340DE8E436577119281B50F9DCBA6
4E1B19BF4624D40421F91FC64FEA86D5487D3046C7C86EF814478348A7A1283A
587259808E2570264A6C3C9BF0401432931EEA5A7650A8B2AC64AF13AC4EF694
21A68943788D50B30097C502185976E0202FE2C90428C640AA95523F821273C1
2DC81C89AC4088882C52D13A752D5B5CA0B41841A73253B29800DA4E975DA4FF
69807BFA085F525F2DB15D607A881CCDCA466BB05D3EE88044C9C9793812734C
9E8A278DC1D12472D15CA12F9B317DD9B0199934F5112F04872C4EA318A25CF9
C2D62B3F2DC9D1A5E4C132B9B7F984F487DA0641B18FCE09F63CAC890A5381DB
615E8615CC32F1B55D1BFA750C63B5FE34C718BCF7D759066E8C9F27B56C740C
C89790019C44C330907ED8104A1FA5A522FA9188B237375191EC5B4DE38987D5
C83FD12D6473A9700B48859AA4279B8A69A26652E1C7520B4E422623ADF11E43
F89374485B93F5CBB090FD76BC0EB8327BA9DD078CA9C33253888F980C9E098A
952109582A9EB842222B3D84923293FD18428B6354806C2D60B0A49050D69ED1
3064B540AA9D90AB5C4A64857CAC29978DEC95825B1107A883F13085D0E61A4E
0E01839F239A0D138BE0604E8D5450B400058E9B23FE4A844C2D2DAA4CC0B2CE
278B07086B28490D3FE55DFE23C392F484DF021FC889202A08641C5E15B68604
DE852275B429210AE5649510088F732951A452C6AA7499F9B2412832917C9481
3C564B391EDEA04A232B5FFC2A850754A8EC069DECB2AFE9B27CA007BE97E74A
3E8B90FB61259F535196EC917DEA822C4E1E46AAA3F489D6544AEC862C134FD8
34F92BA883C48F851E8983A85AF65418F960893111CA18AC212AD129B2B484B2
8E98513884294B35F9CC4489C4862B827B221B640B5F1194652D7B9D80373A9C
1606BF2964B00A311282882AD5451CA1BF827CDC580C57C5BBFC1208C8705A59
194845A704462A0E92BD659F5EA664D4294328954FBA0B6166500A33AEA86470
4D883A7789899907A5A0AFD2600A2D93A2BE2C4DA5A02AFD4147A1FA125FB03D
132346E372330A47AAA1B9D05D546A1583D9B0455DCBDEB5503EDA9345B2AF4B
61F5CC1728228D40A6E0EDBA3293621B93AE654F936CAE0D4320260A0873005F
179668C8D65D408B584A644526930FC26550AC0CC700A2C6A5D3BC287446F226
F1E7D0DE5A725406458B4B95FA58938E2506C840C0F2026320B584A90FE7F235
AE38F9089270D32C970F12E6499AC222C0C4282BAC1604A455981499A44121ED
440B2CA6D4E490989C42FA1A07BA7CF448C96250A944F4C5B18669C7BA92AAA2
2E65AB04D2292E60BC381919826401C5CACA2AD142DEC7362BE50371440F9DCA
F077E2C1A48849848CEC61A79BA45459880CAB30449941FA4924B2F31C9250E7
93E5B3226258A4C8AC928D2A3013184118C409BD4064831C81EC6C82DA2AD96C
5019CDF45676177E487E28267B0B1852A9104D3E7D019F0C4043D2911A9406E1
7259930F4027A9EFE9083B25B4921308B23CCDB48CD32F48662A816A44BC2E81
0400413E3324256C225E218EE5236B885F59EEC59E590DFEA1AD414938FA444E
0032F2D127D8620C4D917DCA6948A62E7DA84922D5392DBB083F99E22E485BD7
F6E8D35F381BC35E7D76B3D9C8B1BE728ACCD3874EEC191E39D835DD9D2CF862
F8923DB26FD08FD3E6FD7275D47EB699CE6C6E1AFB7AFFCAFE63E3A35E0CCE0F
6F4F0519B5E43DB74D3D70DE433788C7E3132D8F83FD87C2A7C7740C6FEBC63E
EC8BF7B3F7D4FBF8408B0F9DBC3019F0F9FC72DBF46F2ED6C7F3CDFBED273E95
DC7F947DDAE1EE5C94F1A7CD4763181C6EF8B43B9047CE6291B9DE53980326E8
9F8E8EBCC1737F684FF4F18E8E9848778735C1B833DEECC9D56276F0CBCF1C9E
B278FF61BBE58E26DDA33E3D417F67E376AE6CDBFB19FDE4A4FF3583F5E6FAEB
D6FA9B8C25C72B1CC93944EDB9063F8F0FF1E88E0E90B0EC4F0E185D3169E493
C79A8CAE7BF0DD9F9F9DBC79F1ECA4F2B6BBBBCBE6F9CC9DE922A7115F2E1733
EFFEC925F6A6F5EA6A7DB36D5EFF28C7BFC819214F4EDF97EBCBF5E6F9E7FF5C
DB3F9FCFBEF8A59B6F76F7EE05A5F91FF7BEF8D4CDCF4AF3EAC4BC698F693A67
A29ECFF46639BF3CF4FED86C16F3D5FCD0FBFAADF776BEDACAF9F7CBF3597796
D3A71AD4DE976F4C7DEF0455313E7E3800B687DE7C76AC3FD970776C54D7E3E3
934AFE7AF3891BE4D4A5E5AAB9F7DEF86C8A77FF6860883B6C5D643CEC19FF6F
45F244A2F5B06903A28F403B8507C307F5F7B93331DA2BDBF353BC274F9E78D5
EB57667CD6D0C3077D8CC6274726DEB3801C4BD567C5FB41FA0B09F753973EEC
7564A74F9D09DCF5E6418FEEDFDC27ED4FBBDDBB07E1EAC1934EDA5747E97C32
7BE3A36BFE91D3EE3F0EE9847775F7D04929F76D383D15E5FEC940725ED06F7A
6C5131C72672C4E1BE297BBC5C7704D1C7876B13CBD5A2F9C99D007FAF363178
EF13473DD9D35E262FC9192CE3976C2CCBD0EDBFE3F7FE96336246DE65A762E8
7BE3768F1FE8C7E97A71E79DBE3FB39961D66615A67AB1FCD11E58C8BF2F17F7
1AE2D5E94BD2D0BDE78D4C313A42697F5692F78D758CE191D40F1E4E333AB37A
F49D2D3F3FBBDE34A3E3CE478D796E82DC770FFDC914DEDB9727C62BBE7DF955
65DEB4C7669EC8015CDBB3CDF21A3F58893B6EED915B384F33DF2E2FEFDA5352
0FED797D87EEC4FBCD46CE3F754770BAB3D0D6ED915CB7CDA96D567CF889B4DE
B44A60BB6BAEE50B3968B73D76752EE7246DBC9B6B1B408E943BC2D3DE288EBB
3BC2D16C8B7F7AFBDDCB3F7DF707F750E90BF7CE2F2FD7B77D7F2FE7FCB06B3B
F4E3727BC3DB7787C4F5EE425EBF98FF28AEC285D6A36DA3F315E35B2FA4AB2F
771EB144EAFAF38D0897E5077AE8D9E8BADEACCF9AED76BDC1063F9D35D7F60C
B2CD0D04C07D8500366A4F24732A448EB194AFC5D92CDF5FEC8696E9ACF21DFD
3D9BCBD958F659E78C7A7BE8594FDCB616BEBCF47824B68079D856E5A4D3F94E
0E713B6EC7D97EFDD0A8BD856711855696576286439B83DB46DD9977CD652347
0F6E0F9D0178506720318B58686094D77292B980DD6177141B0E27DFBBD459D1
8D6D7DBB72F322B7D976991C619EF23D2C5C74BE595FB58FDF72FD9974ECAEED
74FB3D54E2B8F395D8F2B4D9DDCAC9616E066DCFFB667F5C36B787620B4FAAA3
97CDCEF9CC66EDAE6B1B914ECA95533FB289BBF537E73AB6D1D67DBA3718BD3B
5B76690DE9626360511E7EBA5CCD3777ED373DD8F304EFECD76B389BDAD13A23
5E5DDF00B76D3F4810F011BAECBE3FCA9BDFECD6CCE9F24CFCD4734750792207
DCA4499FACCD5C78BB87DF6CED0CE149327C3B680005B0EF8F576BBD637731DF
D9916DAF9BB3E5F99D73013938F77DB36A36F38EA2B86891838CAD2B6CE40033
77C66EDBDBEDBE2999AED64A3203368C8FEDE9F67D20AC573DC77CACDCA39667
83B6E441CBD5D9E54D7B2ADCFBA6EDE56EBEA14B0798AA68CEE6E43A7734E0ED
C5FAB233984BBE1277DD01807DA8DD0D22A0B394EB683B8B3278DB536BA71667
5C0EEC1DAF9F37F9CA3489ADDEDCBCF6FAED1E49EC2D9797DD5BDBF5F9EE9681
3D79E420B57C63F4C9CB577FF0F4ABCA33D54BFBB31C3DF9B6C3DC3D06DAC3A7
2DF689538F80E2D04DF29DFD562A19F2DC1E8B6B2F947974475B4A74C8D984B6
61797936F93E9A99F5A6D605DB986AE1F376C994AFAF9B95B34F67445B55B0D7
304257B2E971B9839AC1D1D9CE83ACF18895B904F338FA3B193B40CBDDBAEF6F
DBA5365EA5C776985BF992969BCB85F7CAFCD1BCB1F95FBF7CE5BDFD4697E6AD
275F33E5DDC04836DB33D8E1D64E0939FEA045353908D5DD2EFCE642CEAD9399
B200D0FC446FB62D74BEDC7DCE936EDE33849D3D8E1257776AE36C2EE4B211DA
B5109BF7D1D276EFB1FBEA2DA688C017D0B1B9E26C7EBDC4375084F8723FDBAD
2F7608D2438AA430BAE590B13353176E7258A633F3A24F22EECBFCDA3971E0D2
BB893BA2D2B9C0C57ABD65E64F6F763B6E6D23DF9D9B3DFBD676A67BF389E77A
D94DAC0D12E9943DE4D74EE4A291E7CFEDE00FE5B86C7776AA9CC7B9ED7BE822
451EE020A0F5B1C32E1B3813C857D79DDE8D7ADCDD66E7C63A38CE377BE03B6F
664FAC2D25C4E72B17BA57EDC1A15DDFEE59C25DB13CEB8CD046D2F8792D80DB
6B5BB7DCCF40D76F1EAEAD2238EC22C3054D9B6AA497EDB40ACBC1301D426FFB
61F62E2FE9E5F844ECEBE6C0B5B4B7609FB0DAC6FBA9F24A4BDF1DF0480E5BBE
5F4D62F4D01D4E6F4BB0BC628B13E272527DD9B6C9D4F10C3B7372DDE9CDA564
D28527527D40405C7FEFAE2541094C6C2C286E6D15557E1A30257A7D27A7B4D2
67EF6ABDDD4D889344DAFF948BB7B08FB3167741F4ED1EBFC4C5EC8C8986B673
EAC891737B9BD3BA7095BED9D883A0DEB5797F7763BF32D2B91B91B9B230393F
DDAE2F09120769E4A26D87D1275F1AC786BFD6DFB4A8FC278910C140C951721E
7C37D1C7CE07C4545D8CB63946AEB6207A2A13FD4112A76349F6A45A3B884537
EB57E20ADD21C46FC5E95CD88FF973CB10F53E9F8B378D88429FBFF758777D73
CADC5D346DF2B3DD9C4BC678F8464B3224B72EC16A47FAADBADCEE59BF6D7A05
637E6FD3D4667DE312C466C8ECFB3EBAACD19DE8BD970E9D50B0B0E948CD7AD5
71AE4D9BE54EE75B87703BDBA48D1A14D091BBA99B79BDBA1B6984FDC1B2BB41
4F9C67898B6CD793D19F6F8875CB6C564B043EEEDA6C091F69A36327879691E0
46AE7BC2BE376DDBF32EC6B6C4883CFE72BDFE606D7FDE34972DD2BF1C4FBE85
528B885263901977B3333DBED8E581C5E2D87D5DD830A1F6A2C2996A00F1A3AF
9AEA73FC5BA151E2A84255EC8552176AD1D1252C3ABF190B96A1ABB5083AF78A
AF5E97FFDA3992B4A85CC4CAD7DBD9BBDEBEFEF64D69BCFAE557C61E48DF4651
AF29651606203B6869348D0F64BBC3D6333B5BF6ED4A40414FE7F6E06E5CCE55
236C7318D7FA813CCA81FA38A0DAEF92DC77A8E31783B5148B7FF27D4D3FCD2D
4D996F1DAEDD361B77CFC27D57440F9C7D5A6B81FBEAB0BFC7F5735FD973DEDD
7E13D4D642D96AE4B98716D69C3A1AF6F2EB6FDF9E7885F1BE7923479D98CA2B
BEF3F60B8BDF983752FDF5DE7EF7B568FCC7B3CF661DEDE8CF3BFFEAE5AB7F7D
FBD4DB4F8FE9CF331FF9C2DE0FAE04784F85698A4862D8A77736C52EAD136FFF
72230879BA999F7D6876DB2783696FB6FBD7F720D496E8B875AC6BF6D0D719E2
7032C57DD3F6DBB3AC346AAF6E8B6CB689168D7A4F7704B57B3A92CA92F41651
206EB69D51D3DB03B9AEF3B736038E6EFA6B4DB6C31AB6D0B76E99A87CFFA853
ADDDAD97C4E2E516086AAE87F731929E8D4DE7C39258C94A56CAAFACD6020764
D4B3CE0C2F771D14F76CD706838B2F07612D5F3BEA323B0DCDBEB48D3C9EB7DF
45EABE0C679A77BA3B6F1D93DC978D964E46BB3A0FFAECE0C9B8ACF4503392F9
BD4149D11D012F58809910530B71937DA618A098FB62E4C1ADAE7AD991838DEC
9B6286171D9B17DB7E103B8F1B6ABB7CD945B6B3411B3B5F12F19FDB2E820536
21E1BCF29D91E338B9B50AC3668236EFDB799199B419ADE94FB61FC0C1B41E74
488E3B8516B55D70F5CB164CBBEF8BED4A7543D6FAD8BD393F25651C74BE69D1
67CF6A47784237708C9693F138A67B481CDB8B06706CD9E7FA66CB903A16BCD7
FD8B7D8AE9E9AAA3FC074FFADEBAC07730E296B5904D57D7BBBB4F76BB2FA7EC
9992ED92B0AC472D4CEF8760E374E45D128A8E16C8B3E4CB813BECB57ACE3DB6
9DE5A2A15BD6CFEFCDF310991F98E67686E7DD350BD109B6E7B6E13D1259D171
BBDE03096EDACFF2A1D5353FBC5EB95FEDC5F69593DBB57BC53D796E09E6287A
2D39B09DDC4FF0B6CD5F2D7C39B83C05495D2B020A0FD3C13D8D94D5324BC506
7D148BB6755379A01A6237A379D5EE17180F65D5EAE58786D3C328B3DCF571EB
BCA92D569EF61520AB2AE4CBB8063739CED219741C29DEA7FE7C31097FEFF100
41069083DBEC1714BFFFAC1B1531F86EDAE064F26C846F3B6FEB8D8F53F4C69C
368C613ED9706FB45FDDF0002556A22D3B97EEFDF8D4FA7B1F72F38135ACF563
B16A276DE459211A6E7D6E5B758CACBF570D2FED0A8B4A12D3B98BD7FECA707F
654F7A6C8B7B35B2CF006DBDBAD527C232DC7724F47EE992B1EB8C4D8883B4BE
7CD23C69CB0D72D334CC4E2E36CDBD4093D77E28DCABCE3C631FDDF7E6E0D738
DAD4CB7ED993FE63DCE8EFF6A161AB629BD140BFB86FC8BFA5DD69DB3FE8B6D7
C3767FD0BFD8F2BD8B3FFD84A2EDFF170F4CF7AF7B4271FF0983A7843F143F04
7614ED13EC0BBF6DFB6ADABEFA6DDB0FA7ED87FF60FBC3EF877A37F5AA5AE263
E4ACED93E58DBFDF596B11ED0F36CB1B7F3F8E7E20FFC8CA902D34EF808DAE42
3794CC16EFDC3AC054BC8D05946DD6228AE345B672B44F6C363D1F8D8B3423D1
B4BB586F8788B7DC8369C70BDA7C460FDA5AFAB65FB4D83F78DB7D9FD230138F
C54C4FE1EE2C0AB75581C1EAD0BCAF9A8C5709BB350454CE4D4FC82C036EEB37
F70AACBDE8EFBFEB49F2BDADA1C83D13A30CD2832C83B47DB08DBA7ACE40414E
4A005D85BB5F5B6AE589FD6E223BBEB64CDF5552BBD275BF64EDD6BA6CF5B6BD
D7F2AE27B6F22363FA7CDB53CDC3C160568DA3A4AE1547B77A176AC9E8EBD559
A7D36875E5AA797DA561C8D1DB8CEB16355C816DE10A8CB2AE3268F9B0ADEE4C
5707F65F08DED78D3ADBD855025B721EAD14F662054776FE36ACDCCFC6DFEFDD
36DA165A5F9F7C69DE78B5D127DFBEE917C0DA42596797EB6623CBDB7BD18AD1
5FBF1D949C4795AF9217D697F7FADEAD0E76B74941DEADB38A20C462DB41857D
2F49DCBA7AFF4D82DE6CB1DCCC1C1F72CB7EDD628B34713028720989F67EE6EA
8FE305145B7A6CD9AB2D18AE9DF692AE498B6E37465743DF1E77AB068FCFDBD5
20594896B83F95A5B4BD4C1D5AC3AECD6CF1F1B38BB66AB958DFAEFAF5CE63B7
D2B6DE2CBB3AA2E3ECF5C9377616B9A5D99D3DE9859A48A005F669A0EDB275D2
BB06B4367D6DD55A7130F24D6305E667EBCB85459A1D9DF96CD5DC76BFF4172E
1ABB42FFD9CDCA09A61FEE5DD16DEDB223745B5CCF77D74F8F8F6F9E7E767DE4
BE5CEA08E31F1F78DFBBFD06EDD74272E163BB09E96267AFB7312E17DA0B069B
A51F77F3D23BD9A55DA0104BCB57122F6541657E268B077B136380ED762965F1
365BB8496B67F3C099A2BAB10B31375B5BC396EF076ED7D11FAC9AB4B2D676DF
F157ACDE16CC7BBF740A772CA7BDC7F2B55BFDD7DE7EF6E478F82DBD82DB3833
F9E9E0500A4DFD42F8E5EDFC6EDBD5E1CF973FD9A6AFB869FEA1B1D8B99172B0
45BF4EE7CBA28A5D1775B5035757DD973B86CB2FF8DFA6B9922AFADB975F7FF3
95E925E4BF7DFBB2FC57ABA3447BD8EFB8746B5B8DD58AB7ED3A8374F112FF5D
0D3CCCA515D9E4E28AE557CBD50DBEEAF612B8CB48573FD12FB9C22DF0B42B34
0FE4E4563A00F4F6EDB96CC0FBCBCD72632B4FF2FAFAE6FDC5AED536F3DD762D
E6E8B48C45F2F63BDCA4D4209B3D262B3BB2A9DEFBA1FD22E81F46EB106ECDE2
A043C097AFDE9EE8AFBED2F26DC1FB0D00ED1E8243B7886677690F9392AB404A
26DBACAF374B5984713E68FD9519DBB900DD97929A8D0CC059AB9D484F3D4993
FF21F668C7BE68B7CE3850DA238AF84EB39310C1439C0B74A28E3C74CA18BD7E
5B8755787D470F5DCAB0DB373CB765F2B89B14C75286DFEBD8AFBE199C469FB8
D583B72DF42D7E9CAFCE6C34D0FB0E6945DB74BB485C316DB495C4C68ACB7BA3
4E9D4278F4ABEFDC469E7EDF4D571B9595A3DE636FB683F5F56E71ABBBC3D555
061468BF33A8E57D673BF7F5A233BBBE34B306060B4795B5FD061AB76BA2AD9C
F5FD7DD252AD7BCB689BF9A28311EB687646A41075E8C8A4AC3D399F6DC90F93
C34F58DFC1D89E0E6E07C9FC74E46ADD2E85915DF7F1DD2EC8F5EC65D2D716DE
8EBB2FF31DEF0372C8D6AF7B4F90ED70B82FA0DFA123246F2EDEDDA1E2D04C80
CDEB3727FAD5C95359D259B413D45684C054597EE907D2EE00D95B749FFFB9C2
6E719232498BB2765256EB6E3FCA9FBE7B2BDB0DBB0D253FCE97976EC3F064DB
C2CC7E85B3232387AEF0D262C164A345B77271356F378E7791E47A3F9C8B57AF
4FCCD3C9DEB5FDB0DCB7474AF9862C281B31EC1E87B95B6ADCAD6D1DD22DF5B9
42D767EEBA277FBE7633712A4B9FE7F39BCBDDC1937B6B961D71B9FFDCC18EBD
115BEEFA31D991E128F8277BB51C079CDD1CD04647BFA3D03676E8BE7572E9A0
9AF99DED8733EB0278DCE56EE7D7FC6C79B9DCDD0DF6F62D7763CCEC96B205EF
5DFBE4B6213345280D36AC4A4AA253128F37ABE55F6E9A2EEC24E817CBF3F3C6
AE49598AB537EDC261937324596FA345BB20619767FBC1B4B6EB899C6CDCF0B6
F2B4013F07C26FCEDC70ED3D7FC1556588D8C1ADD8DF5C9DBAECE97679F47676
8D77C8DCEF586BD7F12FE6D7ED82C1C8A7F601249B3C5ADD42360048BC236262
BD24561BBB29554C2B7BF976EBB56CA46F9C6E62E436C7ADDD7621D1BBC23FA4
582E6F5E49C8E2F94DD3B2F746F6A6914B76E3F55BEF71ECFB3F05BEEF5D2F7F
927533BBB6FC7EBDA66F3263D7F3CD0767AF6E6F5C9717F6EE7B700FE73AF51B
C938375620BBE507BBE3C962F67225F82B882DDFFC3B2DB85BFC38B6570FD692
4F9B41BDD20E6188C88392E9BECDFDEAE6DEE2F76A9ECBF6D30423A1DE0AFA89
BAEDBEEE79B8417BEFC67B24E91773FA0D65C2D7DD37D7B6AEBD7534CB06EE30
645A026465A76C9BBE97D3FACD580EAEFA1C20E6DA76B5566B813DFC5C0CB605
0C55FC3E75DD33654B13EE7F5848FEB81A50BB9F4FB482C886DDFCBDE7FDCBBF
78450F836ED7805BB9BF57C4E1D27B4F701519F784AFBAB97BBC3DF8648EF51E
CF65B1175DEF88FC6819F1E05EFBF6134983F6A5671BE1AB0E32963C03E57767
17E3BB6A90D3203DBC8D4BD00F7DA8501AD7B2FFD3ED9C58CC77F32E24F66A63
680D01F079BB08D02DBDF7A532D13DE2CDB76B97E064A79D0DA6DEDB9E7A6D01
CB7A4ABFF0D351EEEE1DB7DB679FFA5C5AD907F2F020AEE59697EEB6DD5A575F
2B6B33ED65732E60BCE87787B87C6807E104BE8D60073D5210F851B6C783E267
BB83B60FFB87756BE2DD76D061C5AF8D30410C5B9579FDCA78AFDF785FBF7E63
EC04D927C845E223AD65F7D13BDDA53E3C05A41FF5F0C97B40F0E0D127DF4DEA
8A4334E8B720DDCBE75D29A9C7001BF423BEDCD60E3A7E22E508B7C78094830B
4A1A746AD24A98396CF41619817B2C1E829B9686DA264700D55B473A6E7E9A5F
09717C18C46DADAE69EC12EDB2FBBCC6113F7EBE753B02B7BBCD5C3E75D1AEE8
B902C75B0744DD4E88CDA0BDDED0E2847BBBB7AAA6650D16E45A52E7B47607ED
CE3456794D57C8C6BCD55E38FC9CCEF0933BDD2782E4DFFF0B8956716B3A9C00
00
}


REBOL [title: "Rebface (SDK) GUI Web Cam Example"]
do %gfx-colors.r
do %gfx-funcs.r
do %view-funcs.r
do %view-vid.r
do %view-edit.r
do %view-feel.r
do %view-images.r
do %view-styles.r
do %view-request.r
do %view.r
;WM_CAP_START: 0x400
;WM_START: to-integer #{00000400}
WM_CAP_START: 1024
WM_CAP_UNICODE_START: WM_CAP_START + 100 
WM_CAP_PAL_SAVEA: WM_CAP_START + 81 
WM_CAP_PAL_SAVEW: WM_CAP_UNICODE_START + 81 
WM_CAP_UNICODE_END: WM_CAP_PAL_SAVEW 
WM_CAP_ABORT: WM_CAP_START + 69 
WM_CAP_DLG_VIDEOCOMPRESSION: WM_CAP_START + 46 
WM_CAP_DLG_VIDEODISPLAY: WM_CAP_START + 43 
WM_CAP_DLG_VIDEOFORMAT: WM_CAP_START + 41 
WM_CAP_DLG_VIDEOSOURCE: WM_CAP_START + 42 
WM_CAP_DRIVER_CONNECT: WM_CAP_START + 10 
WM_CAP_DRIVER_DISCONNECT: WM_CAP_START + 11 
WM_CAP_DRIVER_GET_CAPS: WM_CAP_START + 14 
WM_CAP_DRIVER_GET_NAMEA: WM_CAP_START + 12 
WM_CAP_DRIVER_GET_NAMEW: WM_CAP_UNICODE_START + 12 
WM_CAP_DRIVER_GET_VERSIONA: WM_CAP_START + 13 
WM_CAP_DRIVER_GET_VERSIONW: WM_CAP_UNICODE_START + 13 
WM_CAP_EDIT_COPY: WM_CAP_START + 30 
WM_CAP_END: WM_CAP_UNICODE_END 
WM_CAP_FILE_ALLOCATE: WM_CAP_START + 22 
WM_CAP_FILE_GET_CAPTURE_FILEA: WM_CAP_START + 21 
WM_CAP_FILE_GET_CAPTURE_FILEW: WM_CAP_UNICODE_START + 21 
WM_CAP_FILE_SAVEASA: WM_CAP_START + 23 
WM_CAP_FILE_SAVEASW: WM_CAP_UNICODE_START + 23 
WM_CAP_FILE_SAVEDIBA: WM_CAP_START + 25 
WM_CAP_FILE_SAVEDIBW: WM_CAP_UNICODE_START + 25 
WM_CAP_FILE_SET_CAPTURE_FILEA: WM_CAP_START + 20 
WM_CAP_FILE_SET_CAPTURE_FILEW: WM_CAP_UNICODE_START + 20 
WM_CAP_FILE_SET_INFOCHUNK: WM_CAP_START + 24 
WM_CAP_GET_AUDIOFORMAT: WM_CAP_START + 36 
WM_CAP_GET_CAPSTREAMPTR: WM_CAP_START + 1 
WM_CAP_GET_MCI_DEVICEA: WM_CAP_START + 67 
WM_CAP_GET_MCI_DEVICEW: WM_CAP_UNICODE_START + 67 
WM_CAP_GET_SEQUENCE_SETUP: WM_CAP_START + 65 
WM_CAP_GET_STATUS: WM_CAP_START + 54 
WM_CAP_GET_USER_DATA: WM_CAP_START + 8 
WM_CAP_GET_VIDEOFORMAT: WM_CAP_START + 44 
WM_CAP_GRAB_FRAME: WM_CAP_START + 60 
WM_CAP_GRAB_FRAME_NOSTOP: WM_CAP_START + 61 
WM_CAP_PAL_AUTOCREATE: WM_CAP_START + 83 
WM_CAP_PAL_MANUALCREATE: WM_CAP_START + 84 
WM_CAP_PAL_OPENA: WM_CAP_START + 80 
WM_CAP_PAL_OPENW: WM_CAP_UNICODE_START + 80 
WM_CAP_PAL_PASTE: WM_CAP_START + 82 
WM_CAP_SEQUENCE: WM_CAP_START + 62 
WM_CAP_SEQUENCE_NOFILE: WM_CAP_START + 63 
WM_CAP_SET_AUDIOFORMAT: WM_CAP_START + 35 
WM_CAP_SET_CALLBACK_CAPCONTROL: WM_CAP_START + 85 
WM_CAP_SET_CALLBACK_ERRORA: WM_CAP_START + 2 
WM_CAP_SET_CALLBACK_ERRORW: WM_CAP_UNICODE_START + 2 
WM_CAP_SET_CALLBACK_FRAME: WM_CAP_START + 5 
WM_CAP_SET_CALLBACK_STATUSA: WM_CAP_START + 3 
WM_CAP_SET_CALLBACK_STATUSW: WM_CAP_UNICODE_START + 3 
WM_CAP_SET_CALLBACK_VIDEOSTREAM: WM_CAP_START + 6 
WM_CAP_SET_CALLBACK_WAVESTREAM: WM_CAP_START + 7 
WM_CAP_SET_CALLBACK_YIELD: WM_CAP_START + 4 
WM_CAP_SET_MCI_DEVICEA: WM_CAP_START + 66 
WM_CAP_SET_MCI_DEVICEW: WM_CAP_UNICODE_START + 66 
WM_CAP_SET_OVERLAY: WM_CAP_START + 51 
WM_CAP_SET_PREVIEW: WM_CAP_START + 50 
WM_CAP_SET_PREVIEWRATE: WM_CAP_START + 52 
WM_CAP_SET_SCALE: WM_CAP_START + 53 
WM_CAP_SET_SCROLL: WM_CAP_START + 55 
WM_CAP_SET_SEQUENCE_SETUP: WM_CAP_START + 64 
WM_CAP_SET_USER_DATA: WM_CAP_START + 9 
WM_CAP_SET_VIDEOFORMAT: WM_CAP_START + 45 
WM_CAP_SINGLE_FRAME: WM_CAP_START + 72 
WM_CAP_SINGLE_FRAME_CLOSE: WM_CAP_START + 71 
WM_CAP_SINGLE_FRAME_OPEN: WM_CAP_START + 70 
WM_CAP_STOP: WM_CAP_START + 68
avicap32.dll: load/library %avicap32.dll
user32.dll: load/library %user32.dll
get-focus: make routine! [return: [int]] user32.dll "GetFocus"
hwnd-hide-console: get-focus
hide-window: make routine! [
    hwnd [int] 
    a [int]
    return: [int]
] user32.dll "ShowWindow"
hide-window hwnd-hide-console 0
view/new center-face layout/tight [
    image 320x240
    across
    btn "Take Snapshot" [
        sendmessage cap-result WM_CAP_GRAB_FRAME_NOSTOP 0 0
        sendmessage-file cap-result WM_CAP_FILE_SAVEDIBA 0 "scrshot.bmp"
    ]
    btn "Exit" [
        sendmessage cap-result WM_CAP_END 0 0
        sendmessage cap-result WM_CAP_DRIVER_DISCONNECT 0 0
        free user32.dll
        quit
    ]
]
set-caption: make routine! [
    hwnd [int] 
    a [string!]
    return: [int]
] user32.dll "SetWindowTextA"
hwnd-set-title: get-focus
set-caption hwnd-set-title "Web Camera"
find-window-by-class: make routine! [
    ClassName   [string!]
    WindowName  [integer!]
    return:     [integer!]
] user32.dll "FindWindowA"
hwnd: find-window-by-class "REBOLWind" 0
cap: make routine! [
    cap [string!]
    child-val1 [integer!]
    val2 [integer!]
    val3 [integer!]
    width [integer!]
    height [integer!]
    handle [integer!]
    val4 [integer!]
    return: [integer!]
] avicap32.dll "capCreateCaptureWindowA"
sendmessage: make routine! [
    hWnd [integer!] 
    val1 [integer!]
    val2 [integer!]
    val3 [integer!]
    return: [integer!]
] user32.dll "SendMessageA"
sendmessage-file: make routine! [
    hWnd [integer!] 
    val1 [integer!] 
    val2 [integer!]
    val3 [string!]
    return: [integer!]
] user32.dll  "SendMessageA"
cap-result: cap "cap" 1342177280 0 0 320 240 hwnd 0
; 1342177280 in the line above is BitOR(WS_CHILD,WS_VISIBLE) 
sendmessage cap-result WM_CAP_DRIVER_CONNECT 0 0
sendmessage cap-result WM_CAP_SET_SCALE 1 0
sendmessage cap-result WM_CAP_SET_OVERLAY 1 0
sendmessage cap-result WM_CAP_SET_PREVIEW 1 0
sendmessage cap-result WM_CAP_SET_PREVIEWRATE 1 0
do-events


FUNDAMENTALS:

REBOL has hundreds of built-in function words that perform common tasks.
As in other languages, function words are typically followed by passed
parameters. Unlike other languages, passed parameters are placed
immediately after the function word and are not necessarily enclosed in
parenthesis. To accomplish a desired goal, functions are arranged in
succession, one after another. The value(s) returned by one function are
often used as the argument(s) input to another function. Line terminators
are not required at any point, and all expressions are evaluated in left
to right order, then vertically down through the code. Empty white space
(spaces, tabs, newlines, etc.) can be inserted as desired to make code
more readable. Text after a semicolon and before a new line is treated as
a comment. You can complete significant work by simply knowing the
predefined functions in the language, and organizing them into a useful
order.

REBOL contains a rich set of conditional and looping structures, which can
be used to manage program flow and data processing activities. If, switch,
while, for, foreach, and other typical structures are supported.

Because many common types of data values are automatically recognized and
handled natively by REBOL, calculating, looping, and making conditional
decisions based upon data content is straightforward and natural to
perform, without any external modules or toolkits. Numbers, text strings,
money values, times, tuples, URLs, binary representations of images,
sounds, etc. are all automatically handled. REBOL can increment, compare,
and perform proper computations on most common types of data (i.e., the
interpreter automatically knows that 5:32am + 00:35:15 = 6:07:15am, and it
can automatically apply visual effects to raw binary image data, etc.).
Network resources and Internet protocols (http documents, ftp directories,
email accounts, dns services, etc.) can also be accessed natively, just as
easily as local files. Data of any type can be written to and read from
virtually any connected device or resource (i.e., "write %file.txt data"
works just as easily as "write ftp://user:pass@website.com data", using
the same common syntax). The percent symbol ("%") and the syntax
"%(/drive)/path/path/.../file.ext" are used cross-platform to refer to
local file values on any operating system.

Any data or code can be assigned a word label. The colon character (":")
is used to assign word labels to constants, variable values, evaluated
expressions, functions, and data/action blocks of any type. Once assigned,
variable words can be used to represent all of the data and/or actions
contained in the given expression, block, etc. Just put a colon at the end
of a word, and thereafter it represents all the following actions and/or
data. That forms a significant part of the REBOL language structure, and
is the basis for it's flexible natural language dialecting abilities.

Multiple pieces of data are stored in "blocks", which are delineated by
starting and ending brackets ("[]"). Blocks can contain data of any type:
groups of text strings, arrays of binary data, collections of actions
(functions), other enclosed blocks, etc. Data items contained in blocks
are separated by white space. Blocks can be automatically treated as lists
of data, called "series", and manipulated using built-in functions that
enable searching, sorting, ordering, and otherwise organizing the blocked
data. Data and function words contained in blocks can be evaluated (their
actions performed and their data values assigned) using the "do" word.
New function words can also be defined using the "does" and "func" words.
"Does" forces a block to be evaluated every time its word label is
encountered. The "func" word creates an executable block in the same way
as "does", but additionally allows you to pass your own specified
parameters to the newly defined function word. You can "do" a module of
code contained in a text file, as long as it contains the minimum header
"rebol[]". Blocks are also used to delineate most of the syntactic
structures in REBOL (i.e., in conditional evaluations, function
definitions, etc.).

The syntax "view layout [block]" is used to create basic GUI layouts.
You can add graphic widgets to the layout simply by adding widget
identifier words to the enclosed block: "button", "field", "text-list",
etc. Color, position, spacing, and other facet words can be added after
each widget identifier. Action blocks added immediately after any widget
will perform the enclosed functions whenever the widget is activated
(i.e., when the widget is clicked with a mouse, when the enter key
pressed, etc.). Path refinements can be used to refer to items in the
GUI layout (i.e., "face/offset" refers to the position of the selected
widget face). Those simple guidelines can be used to create useful GUIs
for data input and output, in a way that's native (doesn't require any
external toolkits) and much easier than any other language.

See http://re-bol.com for a complete REBOL tutorial with line-by-line
explanations of all the code in these examples.


REBOL [title: "Quick Manual"]
print "This will take a minute..."  wait 2
echo %words.txt what echo off   ; "echo" saves console activity to a file
echo %help.txt
foreach line read/lines %words.txt [
    word: first to-block line
    print "___________________________________________________________^/"
    print rejoin ["word:  " uppercase to-string word]  print "" 
    do compose [help (to-word word)]
]
echo off
x: read %help.txt
write %help.txt "VID STYLES (GUI WIDGETS):^/^/"
foreach i extract svv/vid-styles 2 [write/append %help.txt join i newline]
write/append %help.txt "^/^/LAYOUT WORDS:^/^/" 
foreach i svv/vid-words [write/append %help.txt join i newline]
b: copy [] 
foreach i svv/facet-words [
    if (not function? :i) [append b join to-string i "^/"]
]
write/append %help.txt rejoin [
    "^/^/STYLE FACETS (ATTRIBUTES):^/^/" b "^/^/SPECIAL STYLE FACETS:^/^/"
]
y: copy ""
foreach i (extract svv/vid-styles 2) [
    z: select svv/vid-styles i
    ; additional facets are held in a "words" block:
    if z/words [
        append y join i ": "
        foreach q z/words [if not (function? :q) [append y join q " "]]
        append y newline
    ]
]
write/append %help.txt rejoin [
    y "^/^/CORE FUNCTIONS:^/^/" at x 4
]
editor %help.txt
