steveob Posted July 22, 2004 Posted July 22, 2004 First post so if this doesn't make sense, please go easy! I use FP v6 to run golf tournaments. Players give their exact handicap to one decimal point which is entered in a field. A second calculation field using the round function then converts this to their playing handicap. The problem is with the plus handicap players which I have to enter as minus figures e.g plus 1.3 is entered as -1.3 for other calculations to be correct. However, golf is peculiar in that it rounds plus handicaps (entered as minus) the opposite way to FP. This is only the case if the exact handicap is plus 0.5, 1.5 or 2.5. FP rounds these up to -1, -2 and -3 respectively but the rules of golf handicapping mean that they should round to 0, -1 and -2 respectively. I have tried to write an If..Else type script in the File definitions option box without success. Any suggestions gratefully received. Steveob
aklodner Posted July 22, 2004 Posted July 22, 2004 Try using the int() function. Int will drop the decimal, so in your example the following would happen: int(0.5) would result in 0 int(1.5) would result in 1 int(2.5) would result in 2 You could then convert these numbers to negatives for your other calcs. Hope this helps, best of luck in your tournaments. Adam
steveob Posted July 23, 2004 Author Posted July 23, 2004 Thanks for the reply. Unfortunately, there are 0.5s as well as -0.5s in the handicaps, so using int causes problems with the ordinary 0.5s which should round up to 1 rather than down to 0. Have tried using Case but again no success. At the moment changing them manually, if I remember! Any other suggestions most welcome. Steveob
aklodner Posted July 23, 2004 Posted July 23, 2004 Maybe try this route. Make your handicaps field a text type field, the one you enter into. Then, create the following calculation and set type result as number: Case(PatternCount(textField , "s" ) > 0, Round(TextToNum(textField),0), Int(TextToNum(textField))) What's happening, is even though the numeric field is displaying 0.5s, it's only being read as 0.5. So, make it a text, then in the calc, use the texttonum() function to turn the text into a number format. Then, it should work. Hope this one works! Adam
steveob Posted July 26, 2004 Author Posted July 26, 2004 Thanks again for the reply aklodner. Think my lazy English may have mislead you. The "-0.5s" is just a plural, i.e. more than one player with a handicap of -0.5, the "s" is not entered anywhere in a field. Trying to put this problem in a different way, the round function deals with every number between -3.0 and 12.0 (our highest handicap) except -0.5, -1.5 and -2.5. What I need is a a way of isolating those three numbers so that they round to 0.0, -1.0 and -2.0 and every other number "rounds" in the normal way. I would have thought that an If..Else script should work but despite many attempts and variations, my three exceptions seem to round to 1!!!
Tripod Posted July 26, 2004 Posted July 26, 2004 Yeah, if you only have a few conditions that differ from a default int or round conversion, then IF or CASE would be your best bet. Try writing it again, and posting the specific code and folks will most likely go out of the way here to show you what you are missing...
Ugo DI LUCA Posted July 26, 2004 Posted July 26, 2004 May be Choose(handicap<3,Round(handicap, 2), Choose(Abs(handicap),0,-1,-2)) Never played Golf though, so you'd rather put some real data to see what the rules are
steveob Posted July 27, 2004 Author Posted July 27, 2004 Thanks for the replies everyone. Think I have cracked it after much trial and error and following the suggestions for IF and CASE. No luck with IF but have entered the following in Define Fields/Options "Case (EXACT HANDICAP= -2.5, "-2", EXACT HANDICAP= -1.5, "-1", EXACT HANDICAP= -0.5, "0", Round(EXACT HANDICAP, 0)) Have checked this against previous data in a copy of the dbase and all seems to be OK. would be grateful if any gurus out there could give their opinion!!!!
Ugo DI LUCA Posted July 27, 2004 Posted July 27, 2004 Your former examples definitely didn't helped clearing this issue. Just my 2 cents : handicap+ Choose(handicap<0 and Mod(handicap,1),Round(handicap,0)-handicap,.5)
Ugo DI LUCA Posted July 27, 2004 Posted July 27, 2004 or Mod(handicap,1)+handicap*Sign(handicap) if all your inputs goes from .5 to .5 from -3 to 12
Recommended Posts
This topic is 7493 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 accountSign in
Already have an account? Sign in here.
Sign In Now