Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5719 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi Guys,

I need some help in getting a Custom Function to work. I am using one of Brian Dunnings Latitude & Longitude functions to calculate the distance between points. I copied and pasted it into a calculation field and it works great. I now want to use his "fnLatLon.bearing" function. It requires the use of his "Atan2" function.

How do I get these functions to work? I can prob put the fnLatLon.bearing function into a calculation field (I assume) but it doesn't work for atan2. If I put atan2 into a custom function (copy and paste) I get and error about "X" being an invalid field or something.

Cheers

Posted

It's difficult to advise without seeing the actual functions and with such vague description of the error message. In general, if a custom function requires another custom function, you must define the pre-requisite function first. Only then you will be able to define the other one.

Posted

Do you need to update your profile? You can only write Custom Functions if you have the Advance Edition of FileMaker?

Lee

Posted (edited)

Sorry, I should be more specific. I'm currently using FM 10 Pro Advanced.

atan 2 function:

Let ( [

a =

If ( x > 0 ; Atan( y / x ) ;

If ( x < 0 ; Pi - Atan( -y / x ) ;

Pi / 2 * Sign ( y ) ) );

result = Mod( a; 2 * Pi)

];

result

)

If I copy this into a new custom function, I get the error "specified parameter cannot be found" and the first x is highlighted.

Edited by Guest
Posted (edited)

I made a quick sample of the two Functions, notice that you need to do the CF for [color:blue]Atan2 before you do the CF [color:blue] fnLatLon.bearing

also, note that in the [color:blue]fnLatLon.bearing CF is calling [color:blue]fnAtan2 instead of [color:blue]Atan2, although it is the Atan2 CF you need, so just change the fnAtan2 to Atan2.

BTW, I did not get the answer shown in the example at Brian Dunning's site???

I'll leave that to you to figure out where I errored, or the Author did. :

HTH

Lee

atan2.fp7.zip

Edited by Guest
Posted (edited)

BTW, FileMaker points to errors in calcultions, as you have described. In this case, the [color:red]x needs to be added as a parameters, along with [color:red]y in order for Atan.2 to be correct. Also, in fnLatLon.bearing, you will need to create the parameters of [color:red]lat1, lat2, lon1 and lon2 for it to work. Open my example file, and I think you will see what I mean.

HTH

Lee

[color:blue]To change your Profile, go to the menu bar above, MY PROFILE >> Control Panel >> FileMaker Questions.

Edited by Guest
Posted (edited)

Thanks Lee, I now have the function working but like you the results aren't accurate. No probs though, I'm sure I can troubleshoot through that.

Actually, just sorted it out. Adding 90 degrees give the correct answer.

Cheers

Edited by Guest
Posted

Don't forget to change your [color:red]Profile so that we will know how to respond to your questions in the future.

Lee

This topic is 5719 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.