7 Replies Latest reply on Jan 15, 2014 9:14 AM by philmodjunk

    Creating a list from Parsed text

    philmcgeehan

      Title

      Creating a list from Parsed text

      Post

           I would like to be able for my users to type in a town name, press a button, and a list be created of possible towns returned from a URL ( i.e. http://autocomplete.wunderground.com/aq?query=poole )

           So far I have been able to achieve a ¶ separated list by parsing text after ""name": "" until the next """, then adding a ¶.

           My next step is to be able to select a location and get the Lat and Long from it to set other fields.

           Anybody out there have any hints?

           Many thanks,
           Phil

      Capture.JPG

        • 1. Re: Creating a list from Parsed text
          philmodjunk

               I am guessing that you want the user to be able to click a location in the list and get the lat long?

               Will you look up lat long from a table in your file or query a web site for that data?

               Do you mainly need to know how to turn your text field list of return separated values into a "click list" or do you have other problems with getting this to work?

          • 2. Re: Creating a list from Parsed text
            philmcgeehan

                 Thanks for your response.

                 The URL returns text like this:

                 { "RESULTS": [ { "name": "Poole, United Kingdom", "type": "city", "c": "GB", "zmw": "00000.15.03862", "tz": "Europe/London", "tzs": "GMT", "l": "/q/zmw:00000.15.03862", "lat": "50.716667", "lon": "-2.000000" }, { "name": "Pooler, Georgia", "type": "city", "c": "US", "zmw": "31322.1.99999", "tz": "America/New_York", "tzs": "EST", "l": "/q/zmw:31322.1.99999", "lat": "32.117161", "lon": "-81.258118" }, { "name": "Poolesville, Maryland", "type": "city", "c": "US", "zmw": "20837.1.99999", "tz": "America/New_York", "tzs": "EST", "l": "/q/zmw:20837.1.99999", "lat": "39.130783", "lon": "-77.403107" }, { "name": "Poole Farm, Georgia", "type": "city", "c": "US", "zmw": "30054.3.99999", "tz": "America/New_York", "tzs": "EST", "l": "/q/zmw:30054.3.99999", "lat": "33.680668", "lon": "-83.852684" }
                 ....

                 and I want the user to click on "Poole, United Kingdom" in the list, and for a script or calculation to get the respective Lat and Long from the text, and put them in another field; but I don't know the best way to go about doing it.

            • 3. Re: Creating a list from Parsed text
              philmcgeehan

                   Also, I was going to turn that big text field into a drop down list eventually, do you know of a way to make a nice clickable list?

              • 4. Re: Creating a list from Parsed text
                philmodjunk

                     There's a "parse" custom function that you can download from the Brian Dunning Custom Functions web site that can probably use the location name to parse out the latitude and longitude data. (No need to re-invent the wheel if that function will work for you.)

                     In the Known Bugs List database, on the first layout you see when you open the file in FileMaker Pro, there's a calculation field that lists all open FileMaker windows. If you click a name in that list a script opens the window. An OnObjectEnter script trigger is tripped by the click and the script uses the location of the cursor in order to extract the name of the window to use to open that window. The main limitation is that this method does not work if you add a scroll bar to scroll the data. You can click the link that I've included in this paragraph to down load and examine a copy of the file to see how I got this to work.

                     An alternative approach is to parse those names and use them to create individual records in a related table. Such a table of location names could then be used to list locations in a portal where the portal rows are buttons for selecting one.

                     A third option is to use that text field of return separated values as the value source field for a value list so that you can select a location from a drop down list. When you specify a text field with return separated values as the source for your value list, each return separated value appears as a separate value in the value list.

                • 5. Re: Creating a list from Parsed text
                  philmcgeehan

                       Thanks Phil.

                       I was using that Parse function (http://www.briandunning.com/cf/559) to get the Town Names already.
                       But now I've made some changes, and I'm quite pleased, so far. I now parse the Town names and the lat and long from the returned URL text; and with a bit of text box formatting I managed to get it to look relatively tidy.

                       With the script from your linked database, I can now set another field with the Latitude and Longitude, which I'll eventually use for another function in my solution.

                       So thanks very much!

                  • 6. Re: Creating a list from Parsed text
                    philmcgeehan

                         There is one other thing you might be able to help with. At the moment, to Parse the returned text to the big text box, I use some rather inefficient looking calculation inside a SetField script step for each town returned, and then Substitute any extra returns "¶¶" with "".

                         I imagine there must be a way to loop through them?

                         It's like that 20 times!

                    • 7. Re: Creating a list from Parsed text
                      philmodjunk

                           When I want to append data to a list, use code like this:

                           Set Field [ Table::ListField ; List ( Table::LIstField ; //calc to parse data for one item goes here ) ]

                           That requires a looping script but is a pretty elegant way for appending data to the end of a list of values.

                           I can also use similar code inside a recursive custom function to do the same.