Using UrlKeys$

new BookmarkLockedFalling
Jerry Muelver
Administrator
*****

Jerry Muelver Avatar

Posts: 521

Post by Jerry Muelver on Sept 21, 2007 20:19:11 GMT -5

How do I use UrlKeys$? I show a page with a couple of HTML links in it, wait for the viewer to click on a link, and then.... ? Can I grab UrlKeys$ and extract its contents or value after a link click?

Or, is there a way to use a generic processing handler for all links:

[tryagain]
link #linkhandle, "One", [dolinks]
link #linkhandle, "Two", [dolinks]

[dolinks]
print "The value of the calling link is "; #linkhandle contents$()
goto [tryagain]

or somesuch. I've got a 50-page document with a couple hundred links, and don't want to have to create a separate handler for each link. I thought UrlKey$ was going to be my salvation.
Jerry Muelver
Administrator
*****

Jerry Muelver Avatar

Posts: 521

Post by Jerry Muelver on Sept 21, 2007 21:01:38 GMT -5

Never mind -- I got it: ::)

[tryagain]
link #one, "One", linker
html " "
link #two, "Two", linker
#two setkey("This is two")
html " "
link #quit, "Quit", linker
#quit setkey("All done!")
print
wait

sub linker key$
print key$
if key$ = "#quit" then end
end sub


Still, it would be nice to know how to use UrlKeys$....
Chris Iverson
Junior Member
**

Chris Iverson Avatar

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

Post by Chris Iverson on Sept 21, 2007 22:24:28 GMT -5

UrlKeys$ is for data passed to the application through the URL, the stuff after the question mark. E.g. if you had a runbasic app named 'login', and it accepted data for 'username' and password', the URL would be:

http://localhost:8008/seaside/go/runbasicpersonal?app=login&username=me&password=secret

UrlKeys$ would hold this:

"app=login&username=me&password=secret"

EDIT: I'll post a demo tomorrow, I'm tired.
Last Edit: Sept 21, 2007 22:27:52 GMT -5 by Chris Iverson
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!
Jerry Muelver
Administrator
*****

Jerry Muelver Avatar

Posts: 521

Post by Jerry Muelver on Sept 21, 2007 22:25:13 GMT -5

Well, I almost have it. I still have a problem. I have to be able to generate handles dynamically, one handle for each link on the page, so I know which link is activating the generic handler sub. Like:

a$ = "PageOne"
link #a,ドル a,ドル linker

Can I have a handle array? #a(1), #a(2), etc.?
Jerry Muelver
Administrator
*****

Jerry Muelver Avatar

Posts: 521

Post by Jerry Muelver on Sept 21, 2007 22:27:28 GMT -5

thedarkfreak said:
UrlKeys$ is for data passed to the application through the URL, the stuff after the question mark.

Whoops. I had it backwards, and thought UrlKeys$ had the data being passed by the clicked link. Old habits, from a previous language.
carlgundel
Administrator
*****
Creator of Run BASIC

carlgundel Avatar

Posts: 975

Post by carlgundel on Sept 21, 2007 22:56:35 GMT -5

jerrymuelver said:
Well, I almost have it. I still have a problem. I have to be able to generate handles dynamically, one handle for each link on the page, so I know which link is activating the generic handler sub. Like:

a$ = "PageOne"
link #a,ドル a,ドル linker

Can I have a handle array? #a(1), #a(2), etc.?

You can set the key of each link, like this.

linkNames$ = "apple cheese brocolli"
for x = 1 to 3
a$ = word$(linkNames,ドル x)
link #1, a,ドル genericRoutine
#1 setkey(a$)
print
next x
wait

sub genericRoutine key$
if key$ = "apple" then print "iPhone"
if key$ = "cheese" then print "stinky"
if key$ = "brocolli" then print "eat your veggies"
end sub

Does this help?

-Carl
Last Edit: Sept 21, 2007 22:58:09 GMT -5 by carlgundel
Brent
Full Member
***

Brent Avatar

Posts: 129Male

Post by Brent on Sept 22, 2007 2:28:20 GMT -5

BTW, It should be pointed out that you should never pass login information to an app using the URL. If a computer is public, others could get that info from the browser's history. Also, someone could make a link to a site they control and try to get you to click on it after logging in, thus sending your info in the referrer URL to be picked out of a logfile.
[b]Brent[/b][br][br][url=http://www.b6sw.com/forum/viewforum.php?f=32]SapientBoard[/url] 0.1.2 released 02 May 2009
Jerry Muelver
Administrator
*****

Jerry Muelver Avatar

Posts: 521

Post by Jerry Muelver on Sept 22, 2007 6:28:17 GMT -5

Carl, yup, that's it! I thought I had to set the key for each HANDLE, and didn't think it would stick if set for each KEY!

I have to golf today, so developing my app with this last missing link will have to wait a day or so. But I figure by the end of October, word of my RBPager will have leaked out to Google, and they'll be begging to buy me out. ::)
Chris Iverson
Junior Member
**

Chris Iverson Avatar

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

Post by Chris Iverson on Sept 22, 2007 17:51:25 GMT -5

I wouldn't use the URL method of passing data for something like a username and a password. I just needed an example.

Since my site would most likely be written in RB, I'd just have 'login' as a module with a Login() function, and directly pass the data to it.
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!