if error? try problems
[1/4] from: ryan::christiansen::intellisol::com at: 6-Apr-2001 9:24
The following statement works in my script...
cgi-input: retrieve-user-data
message-action-cgi cgi-input
The function 'retrieve-user-data successfully transfers the CGI input into
the variable 'cgi-input and subsequently, the 'message-action-cgi function
successfully processes the cgi-input variable. The cgi-input object
includes three values: messageType, messageID, and actionType. I test the
above statements using a URL, as such...
http://www.fargonews.com/cgi-bin/messages.cgi?actionType=display&messageType=news&messageID=none
But if I try to add error-checking so that it will default to using a
pre-defined object!, it does not work.
if error? try [
cgi-input: retrieve-user-data
message-action-cgi cgi-input
][
no-cgi-input: make object! [
messageType: "news"
messageID: "none"
actionType: "display"
]
message-action-cgi no-cgi-input
]
I've been working on this little problem for a long time now. Can anyone
see what I'm doing wrong?
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]
[2/4] from: jeff:rebol at: 6-Apr-2001 9:07
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
[3/4] 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
[4/4] from: jeff:rebol at: 6-Apr-2001 10:04
Howdy, Ryan:
> 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:
Just from the sound of the symptoms, it sounds to me like it
makes it through most of message-action-cgi the first time,
generates an error towards the end and then invokes the
error case which does message-action-cgi a second time.
You may want to amass all the generated output in a string
in message-action-cgi, and only print it when you've made it
to the end of the function, so that you avoid producing a
partial result.
Again, just my speculation. :-)
-jeff