Extracting values from UrlKey$

new BookmarkLockedFalling
turbov21
Guest

Guest Avatar

Post by turbov21 on Oct 17, 2007 20:03:19 GMT -5

A simple, basic function designed for grabbing values from the UrlKey$ string based on a key (key$). It's not fully complete, because I've still got to finish my URI decoder function for standing symbols like %20 into spaces and such, at which point I'll put it on the wiki. Here it is in action.

' Grabs a value from the url
function GetVal$(string,ドル key$)
value$ = ""
key$ = key$ + "="
startit = instr(string,ドル key$)

if startit > 0 then
startit = startit + len(key$)

endit = instr(string,ドル "&", startit)

if endit > 0 then
endit = endit - startit
value$ = mid$(string,ドル startit, endit)
else
value$ = mid$(string,ドル startit, len(string$))
end if
end if

GetVal$ = value$
end function
Last Edit: Oct 17, 2007 20:05:39 GMT -5 by turbov21
Chris Iverson
Junior Member
**

Chris Iverson Avatar

There are many worlds, but they all share the same sky. One sky, one destiny.
Posts: 73

I got RBP working over the internet![br][br]http://cssource.servegame.org/rb[br][br]If the server's up you'll see my crappy placeholder webpage!
kaalidor
New Member
*

kaalidor Avatar

Posts: 42

Alyce
Administrator
*****

Alyce Avatar

Posts: 519Female

-Alyce
kaalidor
New Member
*

kaalidor Avatar

Posts: 42

Psycho
Full Member
***

Psycho Avatar

Posts: 196

Post by Psycho on May 22, 2010 21:22:47 GMT -5

Here's an expansion to turbov21's earlier post including removal of "%20" and replacement with spaces.

'normally you would just use UrlKeys$ in place of this$
this$="DieDisplayAdd$&dienum=this%2012345&name=John%20Doe"

'print GetVal$(UrlKeys,ドル"whatever")
print GetVal$(this,ドル"dienum")
print GetVal$(this,ドル"name")
end


' Grabs a value from the url
function GetVal$(string,ドル key$)
value$ = ""
key$ = key$ + "="
startit = instr(string,ドル key$)
if startit > 0 then
startit = startit + len(key$)
endit = instr(string,ドル "&", startit)
if endit > 0 then
endit = endit - startit
value$ = mid$(string,ドル startit, endit)
else
value$ = mid$(string,ドル startit, len(string$))
end if
end if
for x = 1 to len(value$)
if mid$(value,ドルx,3)="%20" then spaces=spaces+1
next x
for x = 1 to spaces+1
newWordToPass$=newWordToPass$+word$(value,ドルx,"%20")
'add space if we aren't at the end of the string
if x<spaces+1 then newWordToPass$=newWordToPass$+" "
next x
GetVal$ = newWordToPass$
end function


John "Psycho" Siejkowski