Re: CGI help

new topic     » goto parent     » topic index » view thread      » older message » newer message
jeremy said...
GeorgeWalters said...

Jeremy, I ran across a small bug in your "process_data". If the 1st time it's called and 'data' is an atom, your routine will crash since 'the_map' has no value.

Oh! Thanks, I'll update my copy.

Jeremy

Jeremy, I've also modified your "process_data" to handle a "query_string" which had more than one field and value pairs. It was only returning the last one for me. There a couple of appends to return a sequence with all the conversions.

 
function processData(object data) 
	atom i, char 
	object tmp 
	sequence charbuf, fieldbuf, fname,the_map 
	fname="" 
	the_map = {} -- <<< add here 
		 
	if atom(data) then 
		return the_map 
	end if 
 
	charbuf = {}  fieldbuf = {}  i = 1 
	while i <= length(data) do 
		char = data[i]  -- character we're working on 
		if equal(char, HEX_SIG) then 
			tmp = value("#" & data[i+1] & data[i+2]) 
			charbuf &= tmp[2] 
			i += 3 
		elsif equal(char, WHITESPACE) then 
			charbuf &= " " 
			i += 1 
		elsif equal(char, VALUE_SEP) then 
			fname = charbuf 
			charbuf = {} 
			i += 1 
		elsif find(char, PAIR_SEP) then 
			the_map = append(the_map,{fname, charbuf}) --<< change here 
			fname = {} 
			charbuf = {} 
			i += 1 
		else 
			charbuf &= char 
			i += 1 
		end if 
	end while 
 
	if length(fname) then 
		the_map = append(the_map, {fname, charbuf})--<<<< and change here 
	end if 
 
	return the_map 
end function    
 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu