For a different take, here's the old school version I get to parse URL
items into an array:

// WebRequest_ParseURLItems
// Strip parameters off URL and parse the remainder into items.
// 4D automatically URL decodes the incoming data before it arrives.
// Otherwise, this routine would need to convert special characters
// encoded as hex in the incoming URL.

C_TEXT($1;$request_url)
$request_url:=Text_TrimLeadingSlash ($1)  // Don't want a leading /
If ($request_url="@/")  // Don't want a trailing /
  $request_url:=Substring($request_url;1;Length($request_url)-1)  // Drop
the first character.
End if

  // This routine is only interested in regular URL items before any ?
  // and special arguments.
C_LONGINT($question_mark_position)
$question_mark_position:=Position("?";$request_url)
If ($question_mark_position>0)
$request_url:=Substring($request_url;1;$question_mark_position-1)
End if

ARRAY TEXT(WebRequest_URLItems_at;0)
  // Parse the script URL into array items:
Text_ParseIntoArray ($request_url;->WebRequest_URLItems_at;"/")

  // Save the original URL in the 0 element:
WebRequest_URLItems_at{0}:=$request_url

  // End of routine.

I've then got a function to read an item by position safely. I'd expect
that most of us have something like Text_ParseIntoArray in our toolkits
already.
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to