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

[REBOL] decode-cgi into nested block

From: al::bri::xtra::co::nz at: 30-Sep-2000 16:39

Hi, Shariff, you wrote (directly):
> Iīm so sorry to bother you in this manner. I took my work home (deadline
to meet) and since I subscribed to the REBOL list at work itīs not possible to post any questions. Luckily I cut and pasted a reply that you made to a question of mine a few days back. I've also posted this to the list, so other people are helped as well.
> My problem is: > test: decode-cgi "description=newdb&value1=one&value2=two" > == [description: "newdb" value1: "one" value2: "two"] > What I would really like is: > [ > newdb [ > value1 "one" > value2 "two" > ] > ] >Iīve tried replace, form and mold in various variations, but I just canīt
get rid of the colon, could you give me a boost in the right direction? First, this is better: test: make object! decode-cgi "description=newdb&value1=one&value2=two"
>> test: make object! decode-cgi "description=newdb&value1=one&value2=two" >> probe test
make object! [ description: "newdb" value1: "one" value2: "two" ] That way your Rebol is not damaged by someone writing:
>> do decode-cgi "append=yes&print=true"
== "true"
>> source append
append: == {"yes"} Back to a fresh copy of Rebol.
>> block: make block! 0
== []
>> append block to word! test/description
== [newdb] IMPORTANT NOTE: Better would be to leave description as a string.
>> append/only block make block! 0
== [newdb []]
>> append/only last block 'value1
== [value1]
>> append last block test/value1
== [value1 "one"]
>> append last block 'value2
== [value1 "one" value2]
>> append last block test/value2
== [value1 "one" value2 "two"]
>> block
== [newdb [value1 "one" value2 "two"]] For real production code, put a try block around the code and test for errols. I hope that helps! Andrew Martin There can be no errols... ICQ: 26227169