answer command stopped working

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Bellballer1
Posts: 40
Joined: Sat Oct 24, 2015 5:42 pm

answer command stopped working

Post by Bellballer1 » Wed Mar 02, 2016 11:20 pm

Hello all!

I'm trying to build an app that uses the google Maps API. When I had the following code in the google maps api substack, the answer command worked fine, and a dialog box would pop up after every search field entry I made.

function getMarkerCode pName
if sMarkers[pName] is empty then
return "error: no such marker."
else
local tMarkerCode, tPlaceJson, tPlaceArray

put "var " & pName & " = new google.maps.Marker({" & return into tMarkerCode
put "icon: 'https://chart.googleapis.com/chart?chst ... 256|000000|'," & return after tMarkerCode
put "position: new google.maps.LatLng(" & sMarkers[pName]["pos"] & ")," & return after tMarkerCode
put "map: map," & return after tMarkerCode
put "title:'" & sMarkers[pName]["title"] & "'" & return after tMarkerCode
put "});"& return after tMarkerCode

put getPlaceByLatLong(sMarkers[pName]["pos"]) into tPlaceJson
put jsonToArray(tPlaceJson) into tPlaceArray
##put tPlaceArray["results"][1]["formatted_address"]
put "(function (marker) {"&return after tMarkerCode
put "google.maps.event.addListener(marker, 'click', function (e) {"&return after tMarkerCode
put "infobox.setContent('<div id=" & quote & "infobox" & quote & " >'+'<p>'+" & quote & tPlaceArray["results"][1]["formatted_address"] &quote & "+'</p>'+'</div>');" & return after tMarkerCode
put "infobox.open(map, marker);"&return after tMarkerCode
put "markCentered(marker.position);"&return after tMarkerCode
put "});" & return after tMarkerCode
put "})(" & pName & ");"&return after tMarkerCode

return tMarkerCode
answer tMarkerCode --## triggered the dialog box to pop-up showing the contents of "tMarkerCode" based on all the above "puts"
end if
end getMarkerCode

However, when I added a database onto my main stack, the "answer tMarkerCode" dialog box showing the contents of tMarkerCode no longer appears. I am not sure why that is, and it is keeping me from debugging the code (i.e. I need to change the code shown above so that the items in my database, such as "title" and "position" are fed correctly into tMarkerCode).

I went through 131 pages of the forum on the "answer command" to see if there was a solution, but nothing was posted there to help me. Any tips or help anyone can provide would be greatly appreciated and would allow me (a beginner) to carry on with my app creating goals. Thanks!

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: answer command stopped working

Post by SparkOut » Wed Mar 02, 2016 11:22 pm

return will return the value from the function and exit - it will not continue to execute any statements afterwards. Just put the answer statement before the return.
HTH

Bellballer1
Posts: 40
Joined: Sat Oct 24, 2015 5:42 pm

Re: answer command stopped working

Post by Bellballer1 » Wed Mar 02, 2016 11:55 pm

Thank you! That worked! I am sure I tried that before, but in any case, it's working now. Thanks a bunch!!

Post Reply