Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: sending 'none to CGI

From: sterling:rebol at: 10-Jan-2001 19:18

It will arrive as a string and remain that way until you change it. REBOL, when run in CGI mode, gathers up the relevant environment variables and drops them into the system/options/cgi object. The query-string holds the exact text following the '?' in the URL. You can then make use of 'decode-cgi to make checking values easier: system/options/cgi/query-string: "value=none" cgi-obj: make object! decode-cgi system/options/cgi/query-string The cgi-obj will now be an object containing the word 'value which has the value of the string "none". REBOL purposely does not evaluate any of the CGI information as that would open a security hole. In order to change that "none" into a REBOL none value, you would need to use load. load "none" will result in a REBOL none value. However, if your query string looked like this: value=none none then the resulting decoded string would be: none none and loading it would result in a block: [none none] which, as you point out below is a block with unevaluated words which means that neither item in the block is actually the REBOL none value. They are both simply the word 'none. It is best, when writing REBOL CGI applications, to know ahead of time what kind of data you are expecting to receive. You can then use 'make object decode-cgi' to help you make an object with the values. Then, for non-string values, either wrap a direct conversion in a try block: if error? try [to-integer cgi-obj/usernumber] ["return error page"] or check the type of a load (which is safe because it does not evaluate any code): if not integer? load cgi-obj/usernumber ["return error page"] Well, that was rather long-winded for a one line answer. Sorry. Sterling