Thanks for your feedback. This change would break existing code. So it can't be implemented as is. The correct way is to implement another function which does this work. It could be an overloaded version taking a TStrings instead of a string.
Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] Author of ICS (Internet Component Suite, freeware) Author of MidWare (Multi-tier framework, freeware) http://www.overbyte.be ----- Original Message ----- From: "Busai Péter" <[EMAIL PROTECTED]> To: <twsocket@elists.org> Sent: Tuesday, September 12, 2006 10:48 AM Subject: [twsocket] THttpSrv slight modification to functionExtractURLEncodedValue > Hi! > > In one of my html forms I had to use html element "<select multiple > name=...", so when the user selects multiple items, we got a datastream > like this: > var1=value1&var1=value2&var1=value3... etc. > Original function returned only the first value of var1. I know the > remark states that it retrieves only a single value, but since I did not > found an other function retrieving multiple values like that, I took > some guts, and made some modification to it. > Just in case someone faces the same problem, here is the modified code. > In case of multiple values, they are separated by CRLFs, so the result > can be loaded to a TString descendent's Text property for example . > > Peter > > function ExtractURLEncodedValue( > Msg : PChar; { URL Encoded stream } > Name : String; { Variable name to look for } > var Value : String) { Where to put variable value } > : Boolean; { Found or not found that's the question } > var > NameLen : Integer; > FoundLen : Integer; {tps} > Ch : Char; > P, Q : PChar; > begin > Result := FALSE; > Value := ''; > if Msg = nil then { Empty source } > Exit; > > NameLen := Length(Name); > > P := Msg; > while P^ <> #0 do begin > Q := P; > while (P^ <> #0) and (P^ <> '=') do > Inc(P); > FoundLen := P - Q; {tps} > if P^ = '=' then > Inc(P); > if (StrLIComp(Q, @Name[1], NameLen) = 0) and > (NameLen = FoundLen) then begin {tps} > > {*** Multiple Values ***} > If Value <> '' > Then Value := Value + #13#10; // separate values by CrLf > {**********} > > while (P^ <> #0) and (P^ <> '&') do begin > Ch := P^; > if Ch = '%' then begin > Ch := chr(htoi2(P + 1)); > Inc(P, 2); > end > else if Ch = '+' then > Ch := ' '; > Value := Value + Ch; > Inc(P); > end; > Result := TRUE; > // break; {*** Commented *** We are looking for more > "Name"-s} > end; > while (P^ <> #0) and (P^ <> '&') do > Inc(P); > if P^ = '&' then > Inc(P); > end; > end; > > -- > To unsubscribe or change your settings for TWSocket mailing list > please goto http://www.elists.org/mailman/listinfo/twsocket > Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be