home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.databases
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!caen!nic.umass.edu!titan.ucc.umass.edu!dtodd
- From: dtodd@titan.ucc.umass.edu (David M. Todd)
- Subject: Re: AREV MULTIVALUE Symbolics
- Message-ID: <By2H5w.Dr7@nic.umass.edu>
- Keywords: AREV MULTIVALUE SYMBOLIC
- Sender: usenet@nic.umass.edu (USENET News System)
- Organization: University of Massachusetts, Amherst
- References: <By038z.4qA@resntl.bhp.com.au>
- Date: Sat, 21 Nov 1992 12:53:55 GMT
- Lines: 77
-
- In article <By038z.4qA@resntl.bhp.com.au> kevinb@resntl.bhp.com.au writes:
- >I have a simple requirement that has wasted a deal of time. An invoice
- >file holds a multivalued field for invoice amount. This field is defined
- >as MD2,$ ie. formatted to $1,234.56. What I want is a symbolic to round
- >up the decimal places as MD0,$. Apart from lots of gacky equations the following
- >has been tried with raw data of 123456~1234 (result denotes the amount and
- >amount.rnd fields):
- >
- > formula result
- > amount amount.rnd
- >
- > @ans = {amount} $1,234.56 $123,456
- > $12.34 $1,234
- > @ans = {amount}/100 non-numeric when numeric expected
-
- I'm at home without access to AREV, but I think I can give you *A*
- solution, though perhaps not an elegant solution. Your last symbolic
- is on the right track, but is trying to divide a multivalued field by
- a number. I'm pretty sure this will work
-
- AMT = {AMOUNT}; VALUES = ''
- CNT = COUNT(AMT)+NOT(AMT='')
- FOR X = 1 TO CNT
- VALUE = AMT<1,X>/100
- IF X > 1 THEN VALUES := @VM
- VALUES := VALUE
- NEXT X
- @ANS = VALUES
-
- Haven't tried it, but I wonder if you generate a multivalued
- denominator, if your last format would work, i.e.
-
- DENOM = 100:@VM:100:@VM:100
- @ANS = {AMOUNT}///DENOM
-
- I think that takes about as much programming though!
-
- We should be able to write a function for this, passing two
- parameters:
-
- AMOUNTS = {AMOUNT}
- PLACES = 2
- @ANS = ROUND(AMOUNTS,PLACES)
-
- FUNCTION ROUND
- CNT = COUNT(AMOUNTS)+NOT(AMOUNTS='')
- CONVERSION = 'MD':PLACES
- DENOM = OCONV(CONVERSION,1) ;/*Not sure this works, but there must be
- some simple way to generate the
- denominator from the number of places */
- FOR X = 1 TO CNT
- VALUE = AMOUNTS<1,X>/DENOM
- IF X > 1 THEN VALUES := @VM
- VALUES := VALUE
- NEXT X
- @ANS = VALUES
-
- >T my mind this should be one of the trivial exercises. After numerous other
- >and much more complicated attempts I'm back to square one.
-
- Agreed! This is a lot of work for a simple function. If there is an
- easier way (and there should be) I haven't discovered it. Don't know
- why I haven't tried to create a function before and why I've never
- seen one!
-
-
- >handling of multivalues in dictionary items is a constant cause for concern.
-
- True, but at least we *have* them!
-
-
- |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ David M. Todd ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
- |Department of Psychology, University of Massachusetts, Amherst, MA 01003 USA|
- |Phone: 413/545-0158 ___ <DTodd@Titan.ucc.UMass.EDU> _____ Fax: 413/545-0996|
-
-
-
-