[REBOL] Re: if error? try problems
From: ryan:christiansen:intellisol at: 6-Apr-2001 11:47
If you hit my script directly using the if error? try statement, the
browser displays the "Content-Type: text/html" statement at the top of the
page. When I view source, I see that it is displaying the stylesheet info
twice, once before the Content-Type statement and once afterward. Here is
the message-action-cgi function:
message-action-cgi: func [
{Decode CGI input and create, display, edit, or delete message(s).}
cgi-input [object!] "Decoded CGI data as submitted from an HTML page,
most likely sent using GET with messageType and messageID sent as an
appendage to the url request."
][
print "Content-Type: text/html^/"
default-input: make cgi-input [
messageID: "none"
]
if error? try [
stylesheet-to-load: make file! (rejoin [cgi-input/messageType
.css
])
stylesheet: read stylesheet-to-load
][
stylesheet-to-load: %comments.css
stylesheet: read stylesheet-to-load
]
print {
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE></TITLE>
}
print {<STYLE type="text/css">}
print stylesheet
print {</STYLE>}
print {
</HEAD>
<BODY>
}
switch/default cgi-input/actionType [
"create-form" [
sessionID-check: make decimal! time-in-digits now
user-sessionID: make decimal! cgi-input/sessionID
either (user-sessionID + 1000) > sessionID-check [
display-create-form cgi-input
][
display-login-form cgi-input
]
]
"create" [
sessionID-check: make decimal! time-in-digits now
user-sessionID: make decimal! cgi-input/sessionID
either (user-sessionID + 1000) > sessionID-check [
create-message/from-cgi cgi-input
display-messages/for-editing default-input
][
display-login-form cgi-input
]
]
"comment" [
if error? try [
create-message/from-cgi cgi-input
][
comments-directory: make file! rejoin
[cgi-input/messageType {/}]
make-dir comments-directory
create-message/from-cgi cgi-input
]
parent-message-input: make cgi-input [
messageType: cgi-input/parent-messageType
messageID: cgi-input/parent-messageID
]
post-comment-input: make cgi-input [
messageType: cgi-input/parent-messageID
messageID: "none"
]
post-comment-reverse-input: make cgi-input [
messageID: "none"
messageType: parent-message-input/messageID
parent-messageID: parent-message-input/messageID
parent-messageType: parent-message-input/messageType
]
display-messages/for-reading/for-commenting
parent-message-input
wait 1
display-messages/for-reading/for-commenting post-comment-input
display-comment-form post-comment-reverse-input
]
"display" [
display-messages/for-reading/for-commenting cgi-input
]
"display-comments" [
reverse-input: make cgi-input [
messageID: "none"
messageType: cgi-input/messageID
parent-messageID: cgi-input/messageID
parent-messageType: cgi-input/messageType
]
display-messages/for-reading/for-commenting cgi-input
if error? try [display-messages/for-reading/for-commenting
reverse-input][]
display-comment-form reverse-input
]
"edit-form" [
sessionID-check: make decimal! time-in-digits now
user-sessionID: make decimal! cgi-input/sessionID
either (user-sessionID + 1000) > sessionID-check [
display-messages/for-editing cgi-input
][
display-login-form cgi-input
]
]
"edit" [
sessionID-check: make decimal! time-in-digits now
user-sessionID: make decimal! cgi-input/sessionID
either (user-sessionID + 1000) > sessionID-check [
edit-message cgi-input
display-messages/for-editing default-input
][
display-login-form cgi-input
]
]
"delete" [
sessionID-check: make decimal! time-in-digits now
user-sessionID: make decimal! cgi-input/sessionID
either (user-sessionID + 1000) > sessionID-check [
delete-message cgi-input
display-messages/for-editing default-input
][
display-login-form cgi-input
]
]
"display-login" [
display-login-form cgi-input
]
"login" [
unencrypted-logins: decrypt read %logins.bin
do unencrypted-logins
login: make object! [
userID: cgi-input/userID
password: cgi-input/password
]
login-string: make string! logins
either all [(find/any/case login-string login/userID)
(find/any/case login-string login/password)][
cgi-input: make cgi-input [
sessionID: time-in-digits now
]
display-messages/for-editing cgi-input
][
display-login-form cgi-input
]
]
][
display-messages/for-reading/for-commenting default-input
]
print {
</BODY>
</HTML>
}
]
Ryan C. Christiansen
Web Developer
Intellisol International
4733 Amber Valley Parkway
Fargo, ND 58104
701-235-3390 ext. 6671
FAX: 701-235-9940
http://www.intellisol.com
Global Leader in People Performance Software
_____________________________________
Confidentiality Notice
This message may contain privileged and confidential information. If you
think, for any reason, that this message may have been addressed to you in
error, you must not disseminate, copy or take any action in reliance on it,
and we would ask you to notify us immediately by return email to
[ryan--christiansen--intellisol--com]
[jeff--rebol--ne]
t To: [rebol-list--rebol--com]
Sent by: cc:
rebol-bounce@ Subject: [REBOL] Re: if error? try problems
rebol.com
04/06/2001
11:07 AM
Please
respond to
rebol-list
Howdy, Ryan:
What does it blow out with? .. or where does it?
maybe:
if error? try [message-action-cgi no-cgi-input][
print "The error is down here?"
]
Just a thought--
-jeff