Lesson 4 - Show Address not working

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

amanteai
Posts: 12
Joined: Tue Aug 20, 2013 3:37 am

Lesson 4 - Show Address not working

Post by amanteai » Wed Oct 02, 2013 1:59 pm

Yes, I'm behind. I'm catching up. :wink:

I've completed lesson 4, but the Show Address function isn't working. It doesn't bring up any code error, there's just no response at all. Locate Me and Directions work. I've combed through the script about 10 times, compared it to the video and the pdf, and can't see my mistake, which probably means it's extremely obvious to someone else.

Can anyone spot the error?

Here's the Search button script

Code: Select all

on touchEnd pId
   mobGUIUntouch the long id of me
   
   if the uOptionType of group "mapType" is "Show Address" then
      showAddress the uText of group "searchAddress"
   else if the uOptionText of group "mapType" is "Directions" then
      showDirections the uText of group "searchAddress"
      end if
end touchEnd
Here's the Maps card script.

Code: Select all

on openCard
   if the environment is "mobile" then
      mobileStartTrackingSensor "location"
      end if
end openCard

on closeCard
     if the environment is "mobile" then
        mobileStopTrackingSensor "location"
        end if
end closeCard

on showCurrentLocation
   local tURL
   put currentLocationURL() into tURL
   displayURL tURL
end showCurrentLocation

function currentLocationURL
   local tLatitude, tLongitude, tURL
   put item 1 of getCurrentLocation() into tLatitude
   put item 2 of getCurrentLocation() into tLongitude
   
   if tLatitude is empty then
      put "55.95369" into tLatitude
   end if
   if tLongitude is empty then
      put "-3.198784" into tLongitude
   end if
   put "http://maps.google.com/maps?q=" & tLatitude & comma & tLongitude into tURL
   return tURL
end currentLocationURL

function getCurrentLocation
   local tLocationArray
   if the environment is "mobile" then
      if mobileSensorAvailable("location") then
         put mobileCurrentLocation() into tLocationArray
         return tLocationArray["latitude"] & comma & tLocationArray["longitude"]
      else
         return empty
         end if
   else
      return empty
   end if
end getCurrentLocation

on displayURL pURL
   replace comma with "%2C" in pURL
   replace space with "%20" in pURL
   get urlEncode(pURL)
   
   if the environment is "mobile" then
      set the uURL of group "map" to pURL
   else
      launch url pURL
   end if
end displayURL

on showAddress pAddress
   local tURL
   put addressURL(pAddress) into tURL
   displayURL tURL
end showAddress 

function addressURL pAddress
   local tURL
   replace comma with "%2C" in pAddress
   replace space with "%20" in pAddress
   get urlEncode(pAddress)
   
   put "http://maps.google.com/maps?q=" & pAddress  into tURL
   return tURL
end addressURL

on showDirections pAddress
   local tURL
   put directionsURL(pAddress) into tURL
   displayURL tURL
end showDirections

function directionsURL pAddress
local tLatitude, tLongitude, tURL
put item 1 of getCurrentLocation() into tLatitude
put item 2 of getCurrentLocation() into tLongitude
if tLatitude is empty then
   put "55.95369" into tLatitude
end if
if tLongitude is empty then
put "-3.198784" into tLongitude
end if

replace comma with "%2C" in pAddress 
replace space with "%20" in pAddress 
get urlEncode(pAddress)

put "http://maps.google.com/maps?saddr=" & tLatitude & comma & tLongitude & "&daddr=" & pAddress into tURL 
return tURL
end directionsURL

amanteai
Posts: 12
Joined: Tue Aug 20, 2013 3:37 am

Re: Lesson 4 - Show Address not working

Post by amanteai » Thu Oct 03, 2013 5:07 pm

Anybody? Help, please?

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Lesson 4 - Show Address not working

Post by LCNeil » Thu Oct 03, 2013 7:13 pm

HI Amanteai,

I cant see anything immediately wrong with your script.

If possible could you attach your stack to a reply as it will give us a better idea of how your code is working in the context of your application and it will allow us to more easily debug it.

Kind Regards,

Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
--

amanteai
Posts: 12
Joined: Tue Aug 20, 2013 3:37 am

Re: Lesson 4 - Show Address not working

Post by amanteai » Fri Oct 04, 2013 2:25 am

I'm trying to attach the stack but I keep getting the alert "The extension livecode is not allowed." What am I screwing up?

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3900
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Lesson 4 - Show Address not working

Post by Simon » Fri Oct 04, 2013 2:31 am

zip your file up first.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

amanteai
Posts: 12
Joined: Tue Aug 20, 2013 3:37 am

Re: Lesson 4 - Show Address not working

Post by amanteai » Fri Oct 04, 2013 2:50 am

Thanks Simon!

Neil, stack attached.
Attachments
Lesson4SummerSchoolApp.livecode.zip
(179.15 KiB) Downloaded 150 times

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3900
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Lesson 4 - Show Address not working

Post by Simon » Fri Oct 04, 2013 3:02 am

Hi amanteai,
I don't see any scripts in your map card.
Can't tell you what has gone wrong if there is nothing to see.
Or...
Did you want someone to make it work?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

amanteai
Posts: 12
Joined: Tue Aug 20, 2013 3:37 am

Re: Lesson 4 - Show Address not working

Post by amanteai » Fri Oct 04, 2013 3:28 am

Hilarious. No Simon, I don't want someone else to make it work. Apparently I saved the file for lesson 4, then promptly started working on lesson 4 using lesson 3's file. And then packaged up lesson 4, unaware that I had not been using that file. Damn rookie. :oops:
Attachments
Lesson4SummerSchoolApp.livecode.zip
(181.35 KiB) Downloaded 154 times

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3900
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Lesson 4 - Show Address not working

Post by Simon » Fri Oct 04, 2013 4:26 am

Got it!

Please read your group "Search" code carefully...
Really Carefully!!

Maybe spell check?
nah

OK... check your custom properties names :)

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

amanteai
Posts: 12
Joined: Tue Aug 20, 2013 3:37 am

Re: Lesson 4 - Show Address not working

Post by amanteai » Fri Oct 04, 2013 6:26 pm

Well I feel like an idiot! Thanks Simon, I knew it must have been something obviously simple but of course I couldn't spot it. This is why typing in while concurrently listing to the video is a bad idea. Thank you.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3900
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Lesson 4 - Show Address not working

Post by Simon » Fri Oct 04, 2013 6:34 pm

Glad you saw the error :)

Simon
Last edited by Simon on Sun Oct 06, 2013 9:52 pm, edited 1 time in total.
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4505
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Lesson 4 - Show Address not working

Post by jacque » Sun Oct 06, 2013 3:20 am

Edited for brevity. :)
Last edited by jacque on Sun Oct 06, 2013 10:12 pm, edited 2 times in total.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3900
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Lesson 4 - Show Address not working

Post by Simon » Sun Oct 06, 2013 3:38 am

Hi Jacque,

Nothing really great :)

Simon
Last edited by Simon on Sun Oct 06, 2013 10:01 pm, edited 2 times in total.
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4505
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Lesson 4 - Show Address not working

Post by jacque » Sun Oct 06, 2013 7:25 am

Edited for brevity again.
Last edited by jacque on Sun Oct 06, 2013 10:13 pm, edited 1 time in total.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3900
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Lesson 4 - Show Address not working

Post by Simon » Sun Oct 06, 2013 7:55 am

It's not a big deal.

Simon
Last edited by Simon on Sun Oct 06, 2013 9:52 pm, edited 1 time in total.
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply

Return to “Summer School 2013”