Page 1 of 1

Pass variable to URL

Posted: Wed Aug 21, 2013 10:57 am
by Mills
Hi Guys

I would like to know if it is possible to pass a variable to a URL?

Here is a background of what I am currently doing and want to achieve:
I've created a website where you can enter a business location and it is then saved in a database, an icon can be linked to the location and the end result for a user is to see the location of businesses.

I have created an android app browser to display the map of my website and that can get the user's location using GPS. The GPS coordinates is currently placed is a variable and I need to pass this variable to the URL of the website.

When the browser in the app opens I need to pass the variable

Code: Select all

mobileControlSet sBrowserId, "url", "mywebsite/mobile/map.php?maplat=theLat"
The variable is "theLat" and I have entered maplat to show the variable when opening the webpage in the app, currently it returns theLat and not the variable which should be the latitude coordinate.

Hopefully there is an easy solution to this and I'm just doing it completely wrong. Surely it should be possible to pass a variable straight to a URL in livecode?

Any feedback will be greatly appreciated on this.

Thank you in advance!
Mills

Re: Pass variable to URL

Posted: Wed Aug 21, 2013 11:18 am
by Klaus
Hi Mills,

1. welcome to the forum :-)

2. Create the correct string ("fix" string & variable) first like this:
...
put "mywebsite/mobile/map.php?maplat=" & theLat into tUrl
mobileControlSet sBrowserId, "url", tUrl
...

3. Check these great learning resources, if you find the time, you won't regret!
http://www.hyperactivesw.com/revscriptc ... ences.html

Best

Klaus

Re: Pass variable to URL

Posted: Wed Aug 21, 2013 2:03 pm
by Mills
Hi Klaus,

Thank you for the feedback!

I have taken your advice and can now pass the variable to the URL.

Just have to figure out how to share variables between cards and then how to put data of a field into a variable. Correct me if I'm wrong, but I think you can get the data of a field into a variable as follows:

Code: Select all

 put field "lat" into theLat 
If that is the case then I just need to figure out how to share a variable between cards...

Once again, thank you for your help Klaus.

Regards
Mills

Re: Pass variable to URL

Posted: Wed Aug 21, 2013 2:23 pm
by Klaus
Hi Mills,

you can use a GLOBAL variable, or maybe just access the field with the desired value from everywhere, not just the current card, you want to like:
...
## cd = abbreviation for card
put field "lat" of cd "not the current card" into theLat
...
## Or even:
...
put field "lat" of cd "a card in another stack" of stack "the stack with the card" into theLat
...


Best

Klaus

Re: Pass variable to URL

Posted: Wed Aug 21, 2013 2:36 pm
by Mills
Klaus,

Thank you, your advice will guide me to the solution I needed.

I still have allot to learn about Livecode... and you just made it easier.

Thanks!
Mills

Re: Pass variable to URL

Posted: Wed Aug 21, 2013 3:39 pm
by Klaus
Hi Mills,

glad I could help!

Don't hesitate to ask here and please check the stacks in the URL I posted earlier.
They are a very good starting point for "getting" the LC basics!


Best

Klaus