[REBOL] Re: el(se)if constriction
From: al:bri:xtra at: 28-Oct-2000 8:03
> ...is there a better way of doing this?
You could try this:
Ifs: function [
"Multiple ifs"
Ifs [block!]
/Default Case [block!]
][Block][
while [not empty? Ifs] [
Block: do/next Ifs
if first Block [return do first second Block]
Ifs: next second Block
]
if Default [return do Case]
none
]
Example:
ifs/default [
parse Request/1 [thru "POST " to end] [
append Request first Connection ; Get the form data.
Post Connection Request
]
parse Request/1 [thru "GET " copy Filename to " HTTP" to end] [
Filename: to-file replace/all Filename " " " "
Get Connection Web Filename
]
][
Forbidden Connection
]
Example:
ifs/default [
not found? find Absolute Web [
Forbidden Connection
]
not exists? Absolute [
Not-Found Connection Web Filename
]
dir? Absolute [
ifs/default [
exists? Index: join Absolute %index.htm [
Get-File Connection Index
]
exists? Index: join Absolute %Index.html [
Get-File Connection Index
]
][
Get-Directory Connection Web Filename
]
]
][
Get-File Connection Absolute
]
Andrew Martin
ICQ: 26227169
http://members.nbci.com/AndrewMartin/