home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / database / 8000 < prev    next >
Encoding:
Text File  |  1992-11-21  |  2.9 KB  |  90 lines

  1. Newsgroups: comp.databases
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!caen!nic.umass.edu!titan.ucc.umass.edu!dtodd
  3. From: dtodd@titan.ucc.umass.edu (David M. Todd)
  4. Subject: Re: AREV MULTIVALUE Symbolics
  5. Message-ID: <By2H5w.Dr7@nic.umass.edu>
  6. Keywords: AREV MULTIVALUE SYMBOLIC
  7. Sender: usenet@nic.umass.edu (USENET News System)
  8. Organization: University of Massachusetts, Amherst
  9. References: <By038z.4qA@resntl.bhp.com.au>
  10. Date: Sat, 21 Nov 1992 12:53:55 GMT
  11. Lines: 77
  12.  
  13. In article <By038z.4qA@resntl.bhp.com.au> kevinb@resntl.bhp.com.au writes:
  14. >I have a simple requirement that has wasted a deal of time.  An invoice
  15. >file holds a multivalued field for invoice amount.  This field is defined 
  16. >as MD2,$ ie.  formatted to $1,234.56.  What I want is a symbolic to round 
  17. >up the decimal places as MD0,$.  Apart from lots of gacky equations the following
  18. >has been tried with raw data of 123456~1234 (result denotes the amount and
  19. >amount.rnd fields):
  20. >
  21. >    formula                 result
  22. >                        amount        amount.rnd
  23. >
  24. >    @ans = {amount}                $1,234.56    $123,456
  25. >                           $12.34      $1,234
  26. >    @ans = {amount}/100            non-numeric when numeric expected
  27.  
  28. I'm at home without access to AREV, but I think I can give you *A*
  29. solution, though perhaps not an elegant solution.  Your last symbolic
  30. is on the right track, but is trying to divide a multivalued field by
  31. a number.  I'm pretty sure this will work
  32.  
  33. AMT = {AMOUNT}; VALUES = ''
  34. CNT = COUNT(AMT)+NOT(AMT='')
  35. FOR X = 1 TO CNT
  36.    VALUE = AMT<1,X>/100
  37.    IF X > 1 THEN VALUES := @VM
  38.    VALUES := VALUE
  39. NEXT X
  40. @ANS = VALUES
  41.  
  42. Haven't tried it, but I wonder if you generate a multivalued
  43. denominator, if your last format would work, i.e.
  44.  
  45. DENOM = 100:@VM:100:@VM:100
  46. @ANS = {AMOUNT}///DENOM
  47.  
  48. I think that takes about as much programming though!
  49.  
  50. We should be able to write a function for this, passing two
  51. parameters:
  52.  
  53. AMOUNTS = {AMOUNT}
  54. PLACES = 2
  55. @ANS = ROUND(AMOUNTS,PLACES)
  56.  
  57. FUNCTION ROUND
  58. CNT = COUNT(AMOUNTS)+NOT(AMOUNTS='')
  59. CONVERSION = 'MD':PLACES
  60. DENOM = OCONV(CONVERSION,1)  ;/*Not sure this works, but there must be
  61.                                some simple way to generate the
  62.                                denominator from the number of places */
  63. FOR X = 1 TO CNT
  64.    VALUE = AMOUNTS<1,X>/DENOM
  65.    IF X > 1 THEN VALUES := @VM
  66.    VALUES := VALUE
  67. NEXT X
  68. @ANS = VALUES
  69.  
  70. >T my mind this should be one of the trivial exercises.  After numerous other 
  71. >and much more complicated attempts I'm back to square one. 
  72.  
  73. Agreed!  This is a lot of work for a simple function.  If there is an
  74. easier way (and there should be) I haven't discovered it.  Don't know
  75. why I haven't tried to create a function before and why I've never
  76. seen one!
  77.  
  78.  
  79. >handling of multivalues in dictionary items is a constant cause for concern.
  80.  
  81. True, but at least we *have* them!
  82.  
  83.  
  84. |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ David M. Todd ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
  85. |Department of Psychology, University of Massachusetts, Amherst, MA 01003 USA|
  86. |Phone: 413/545-0158 ___ <DTodd@Titan.ucc.UMass.EDU> _____  Fax: 413/545-0996|
  87.  
  88.  
  89.  
  90.