cortiel

how does one debug a custom function

Discussion created by cortiel on Jun 9, 2017
Latest reply on Jun 9, 2017 by fmpdude

i have FMP advanced 15

i want to debug this CF

Let([

~x=APPS::urlcontent ;

~cnt = 7;

~x1=Position ( ~x; "<address_component>"; 1; ~cnt ) +19;

~x2=Position ( ~x; "</address_component>"; 1; ~cnt ) ;

~x3=~x2-~x1;

~zip1 =Middle ( ~x; ~x1; 5) ;

~cnt = 8;

~x1=Position ( ~x; "<address_component>"; 1; ~cnt ) +19;

~x2=Position ( ~x; "</address_component>"; 1; ~cnt ) ;

~x3=~x2-~x1;

~zip2 =Middle ( ~x; ~x1; 4)

] ;

 

 

~zip1 & ¶ & ~zip2)

 

 

 

 

it is supposed to parse out the zipcode from a google address  query (bolded below)

 

here is what google returns:

 

<?xml version="1.0" encoding="UTF-8"?>

<GeocodeResponse>

<status>OK</status>

<result>

  <type>street_address</type>

  <formatted_address>61 Eldredge Rd, Willington, CT 06279, USA</formatted_address>

  <address_component>

   <long_name>61</long_name>

   <short_name>61</short_name>

   <type>street_number</type>

  </address_component>

  <address_component>

   <long_name>Eldredge Road</long_name>

   <short_name>Eldredge Rd</short_name>

   <type>route</type>

  </address_component>

  <address_component>

   <long_name>Willington</long_name>

   <short_name>Willington</short_name>

   <type>locality</type>

   <type>political</type>

  </address_component>

  <address_component>

   <long_name>Tolland County</long_name>

   <short_name>Tolland County</short_name>

   <type>administrative_area_level_2</type>

   <type>political</type>

  </address_component>

  <address_component>

   <long_name>Connecticut</long_name>

   <short_name>CT</short_name>

   <type>administrative_area_level_1</type>

   <type>political</type>

  </address_component>

  <address_component>

   <long_name>United States</long_name>

   <short_name>US</short_name>

   <type>country</type>

   <type>political</type>

  </address_component>

  <address_component>

   <long_name>06279</long_name>

   <short_name>06279</short_name>

   <type>postal_code</type>

  </address_component>

  <address_component>

   <long_name>2002</long_name>

   <short_name>2002</short_name>

   <type>postal_code_suffix</type>

  </address_component>

  <geometry>

   <location>

    <lat>41.8506550</lat>

    <lng>-72.2623590</lng>

   </location>

   <location_type>ROOFTOP</location_type>

   <viewport>

    <southwest>

     <lat>41.8493060</lat>

     <lng>-72.2637080</lng>

    </southwest>

    <northeast>

     <lat>41.8520040</lat>

     <lng>-72.2610100</lng>

    </northeast>

   </viewport>

  </geometry>

  <place_id>ChIJSzIS8JKL5okR0c1hOGvE5IQ</place_id>

</result>

</GeocodeResponse>

Outcomes