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

[REBOL] Working with objects

From: mat:plothatching at: 19-Jan-2009 16:51

Dudes, Hope you can shed some light here. Every time I feel bold enough to ask a question it results in a forehead slapping, so here's hoping :) Got a script that pulls in some cgi data. cgidatain: read-cgi cgidata: construct decode-cgi cgidatain Groovy. Problem is sometimes we might not get passed all the values we want. I had been ignoring this... but now it's time to figure out really how to deal with it. So I looked at object handling more closely. Seems we can do: get in cgidata 'digital This will return 'none' if digital is either set to none in the block or it doesn't exist. That'll do! Next I run into all the usual issues I have with rebol such as not understanding how to test for none, is a value, is it unset? In the end, I just test to see if it equals none, that seems to work. And because I'm sick to the back teeth of not understanding the exact order in which I have to sprinkle things in rebol, I'll do the usual thing and shove brackets around everything until I'm sure it works: if ((get in cgidata 'digital) = none) [ Print "Digital don't equal nuffin!" ] That works. Great! Course now there doesn't appear to be any nice way to easily tack on a named value pair to an object, I see there is in Rebol 3 * but not for current Rebol... so this is what it looks like I have to do: if ((get in cgidata 'digital) = none) [ cgidata: make cgidata [digital: "all"] ] If there's no cgidata/digital set because we didn't get it on the http get URL request, we remake the cgidata block from the old one and add the path with our default value. Sweet, it works. Now, how should I have really done this? And can anyone suggest a reasonably elegant way to do things based on an object like this with some fallbacks to defaults? Cheers! * I asked to be added to the AltMe Rebol 3 world and got messaged a username, but no password? I couldn't really see what I could do with that without a password or am I missing something / being stupid? -- Regards, Mat Bettinson