New topic: Pass data to a URL
<http://forums.realsoftware.com/viewtopic.php?t=44036> Page 1 of 1 [ 13 posts ] Previous topic | Next topic Author Message Larry6295 Post subject: Pass data to a URLPosted: Wed May 16, 2012 3:03 pm Joined: Thu Feb 23, 2012 7:16 pm Posts: 74 Location: Springfield, Illinois I am new at coding anything for browsers so I may use wrong terminology. I am trying to press a command button in one window and bring up a URL website in another window. The website is Mapquest.com. That part is working fine. This is what I have so far that is working. Location.Text = "www.Mapquest.com" browser.LoadURL Location.Text My problem is that I wish to pass an address to Mapquest so that it will provide map for that area automatically. I don't know how to get the data in there and automatically click on it. Any advice is appreciated. _________________ Larry6295 Professional 2011 R4.3 Windows 7 64 bit HP Top kbrunner Post subject: Re: Pass data to a URLPosted: Wed May 16, 2012 5:11 pm Joined: Tue Jan 15, 2008 1:21 am Posts: 33 This is not so much a RB question. You can add parameter to the URL string like this: http://www.mapquest.com/embed?le=t&q=1555+blake+st+denver&vs=embed Applied to your example: Location.Text = "http://www.mapquest.com/embed?le=t&q=1555+blake+st+denver&vs=embed" browser.LoadURL Location.Text It may be best for you to study the mapquest developer site first: http://developer.mapquest.com/ or the more specific the section about linking to mapquest: http://www.mapquestapi.com/link-to-mapquest/ Top Larry6295 Post subject: Re: Pass data to a URLPosted: Wed May 16, 2012 6:25 pm Joined: Thu Feb 23, 2012 7:16 pm Posts: 74 Location: Springfield, Illinois WoW! I will have to do some more research. I can make out an address in the below. But when I try to replace the 1555 with another number along with the street and city, I get nothing. I looked at the source info on mapquest to see if I could identify some of the below but that didn't work out either. What should I be researching to find out what le=t&q= along with &vs means? That does not look like Real Basic. embed?le=t&q=1555+blake+st+denver&vs=embed _________________ Larry6295 Professional 2011 R4.3 Windows 7 64 bit HP Top Larry6295 Post subject: Re: Pass data to a URLPosted: Wed May 16, 2012 7:17 pm Joined: Thu Feb 23, 2012 7:16 pm Posts: 74 Location: Springfield, Illinois I might get this to work if I can use symbolics in the URL. I tried below. Location.Text = "www.mapquest.com/embed?le=t&q=Nameupdate.Textfields(3)+Nameupdate.Textfields(4)+Nameupdate.Textfields(5)&vs=embed" This doeswn't work. Any suggestions? _________________ Larry6295 Professional 2011 R4.3 Windows 7 64 bit HP Top kbrunner Post subject: Re: Pass data to a URLPosted: Wed May 16, 2012 7:23 pm Joined: Tue Jan 15, 2008 1:21 am Posts: 33 Larry6295 wrote:WoW! I will have to do some more research. Yes Larry6295 wrote:That does not look like Real Basic. Yes, it is the mapquest interface. Nothing to do with RB. Without going through the developer manual, I believe the "q" means query. The rest of the URL encoding/search string only have to do with the format. This random address worked for me: http://www.mapquest.com/embed?q=24+10th+st+new+york I am guessing you can add your search attributes right after the ?q= (spaces are replaced with +) Last edited by kbrunner on Wed May 16, 2012 7:32 pm, edited 1 time in total. Top timhare Post subject: Re: Pass data to a URLPosted: Wed May 16, 2012 7:29 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 11307 Location: Portland, OR USA Note that the plus signs in the URL are not RB string concatenation - they are data. Specifically, they represent a space. You need to put a literal "+" character between the pieces of the address. query = ReplaceAll(address.text, " ", "+") + "+" + city.text + "+" + state.text + "+" + zipcode.text I would recommend creating a query by hand, in the address bar of your browser. Once you get it working, then try to recreate it in RB code. Last edited by timhare on Wed May 16, 2012 7:30 pm, edited 1 time in total. Top kbrunner Post subject: Re: Pass data to a URLPosted: Wed May 16, 2012 7:29 pm Joined: Tue Jan 15, 2008 1:21 am Posts: 33 Larry6295 wrote:I might get this to work if I can use symbolics in the URL. I tried below. Location.Text = "www.mapquest.com/embed?le=t&q=Nameupdate.Textfields(3)+Nameupdate.Textfields(4)+Nameupdate.Textfields(5)&vs=embed" This doeswn't work. Any suggestions? You do have mixup of code and string! Try: Location.Text = "http://www.mapquest.com/embed?q=" + Nameupdate.Textfields(3) + "+" + Nameupdate.Textfields(4) + "+" + Nameupdate.Textfields(5) Top Larry6295 Post subject: Re: Pass data to a URLPosted: Wed May 16, 2012 7:39 pm Joined: Thu Feb 23, 2012 7:16 pm Posts: 74 Location: Springfield, Illinois I tried Location.Text = "www.mapquest.com/embed?le=t&q=Nameupdate.Textfields(3).text"+"Nameupdate.Textfields(4).text"+"Nameupdate.Textfields(5).text&vs=embed" also Location.Text = "www.mapquest.com/embed?le=t&q=Nameupdate.Textfields(3).text+"+"+Nameupdate.Textfields(4).text+"+"+Nameupdate.Textfields(5).text&vs=embed" Still no luck. _________________ Larry6295 Professional 2011 R4.3 Windows 7 64 bit HP Top timhare Post subject: Re: Pass data to a URLPosted: Wed May 16, 2012 7:45 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 11307 Location: Portland, OR USA If any of the text fields contain a space, it will fail. You must convert all spaces to "+" signs inside the query string. Actually, I believe you need to create the string with spaces separating the parts, and then URLEncode the entire thing before you append it to the URL. There are other characters that will trip you up, as well. URLEncode gets them all. Top timhare Post subject: Re: Pass data to a URLPosted: Wed May 16, 2012 7:48 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 11307 Location: Portland, OR USA The command is actually EncodeURLComponent http://docs.realsoftware.com/index.php/EncodeURLComponent Top Larry6295 Post subject: Re: Pass data to a URLPosted: Wed May 16, 2012 7:57 pm Joined: Thu Feb 23, 2012 7:16 pm Posts: 74 Location: Springfield, Illinois The original (below) that was suggested did work. The only thing different was the attempt to use symbolics. It did include some plus signs. "www.mapquest.com/embed?le=t&q=1555+blake+st+denver&vs=embed" _________________ Larry6295 Professional 2011 R4.3 Windows 7 64 bit HP Top kbrunner Post subject: Re: Pass data to a URLPosted: Wed May 16, 2012 8:00 pm Joined: Tue Jan 15, 2008 1:21 am Posts: 33 You are still omitting the "http://"! Here, try this: Location.Text = "1000 10th st new york" Browser.LoadURL "http://www.mapquest.com/embed?q="+EncodeURLComponent(Location.Text) Top Larry6295 Post subject: Re: Pass data to a URLPosted: Wed May 16, 2012 8:14 pm Joined: Thu Feb 23, 2012 7:16 pm Posts: 74 Location: Springfield, Illinois Success !! Thanks to all for the suggestions and solutions. This is a great forum. _________________ Larry6295 Professional 2011 R4.3 Windows 7 64 bit HP Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 13 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
