Path: utzoo!utgpu!watmath!xenitec!timk From: timk@xenitec.uucp (Tim Kuehn) Newsgroups: comp.databases Subject: Re: dBase/Clipper Summary: iif helps out Message-ID: <1989Aug8.130848.15052@xenitec.uucp> Date: 8 Aug 89 13:08:48 GMT References: <1989Aug4.172532.10732@maccs.dcss.mcmaster.ca> Reply-To: timk@xenitec.UUCP (Tim Kuehn) Distribution: na Organization: Xenitec Consulting Services, Kitchener, ON Lines: 37 In article <1989Aug4.172532.10732@maccs.dcss.mcmaster.ca> pjr@maccs.dcss.mcmaster.ca (Patrick J. Ryan ) writes: >In trying to run some dbaseIII+ programs using clipper, I have >encountered a problem with the following example: > >The database is a baseball team roster which I am trying to order >by batting average. Thus I have the statement > >INDEX ON (1-H/AB) TO BA > >(H and AB are numeric fields standing for hits and at-bats respectively) >dbase III+ happily constructs the index, even when some of the records >have a 0 value for AB. When the list is printed out using the index, >the ratio H/AB is printed out as ****** but occurs at the bottom of >the list, as if it were 0. > >Clipper compiles and links ok but when the program runs, it hits a >division by 0 error. This happens even when there are no records >having AB = 0. > >Does anyone have an idea of why this occurs and/or how to avoid the >problem? Thanks. dbase III+ allows divide by zero and doesn't complain? Sheesh! For your clipper index I suggest: Index on iif(ab=0,0,1-h/ab) to ba (you can replace the ',0,' with any appropriate number you like). +-----------------------------------------------------------------------------+ |Timothy D. Kuehn timk@xenitec | |TDK Consulting Services !watmath!xenitec!timk | |871 Victoria St. North, Suite 217A | |Kitchener, Ontario, Canada N2B 3S4 (519)-741-3623 | |DOS/Xenix - SW/HW. uC, uP, DBMS. Satisfaction Gauranteed| +-----------------------------------------------------------------------------+