> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> On Behalf Of Ed Leafe
> Sent: Sunday, August 12, 2007 5:46 AM
> To: Dabo Users list
> Subject: Re: [dabo-users] IIF()
> 
> On Aug 11, 2007, at 11:41 PM, Paul McNett wrote:
> 
> > You can actually do:
> >
> > (pennies == 1) and "penny" or "pennies"
> >
> > It's pretty obtuse, but it comes in handy when you just need the
> > one-liner, such as in an expr in the report writer.
> 
>       Except for the fatal flaw of that construct: it doesn't work with
> all values.
> 
>       Let's say that you want to include a $4.99 fee in your app, but if
> the person is a member of a certain group, you want to waive the fee.
> So you write:
> 
> (person in group) and 0 or 4.99
> 
>       This makes the problem obvious; when you have variable names in the
> expression instead of an explicit zero, it's harder to catch.
> 
> -- Ed Leafe
> -- http://leafe.com
> -- http://dabodev.com
> 
> 

This is my approach to the problem presented.  I would have used arrays in
FoxPro and lists seem to provide the same functionality (and more).       

How would I concatenate the "s" or "ies" at the end of the following
statement"

      print str(givetocustomer[lni]) + ' ' + money[lni]

Here is bottom half of the script:

Change = <some amount entered previously>
denominations = [2000, 1000, 500, 100, 50, 25, 10, 5, 1]

money = ['$20.00', '$10.00', '$5.00', '$1.00', 'Fifty Cent Piece',
'Quarter', 'Dime', 'Nickel', 'Penny'] 

moneys = ['$20.00', '$10.00', '$5.00', '$1.00', 'Fifty Cent Pieces',
'Quarters', 'Dimes', 'Nickels', 'Pennies']

givetocustomer = [0, 0, 0, 0, 0, 0, 0, 0, 0]

lnlen = len(denominations)
    
lni = 0
while lni <= lnlen - 1:
  # floor division yields no decimals and no rounding
  givetocustomer[lni] = change // denominations[lni]
  # modulus returns remainder
  change = change % denominations[lni]
  if givetocustomer[lni] > 0:
    if givetocustomer[lni] > 1:
      print str(givetocustomer[lni]) + ' ' + moneys[lni]
    else:
      print str(givetocustomer[lni]) + ' ' + money[lni]
  lni += 1


Jeff Johnson
[EMAIL PROTECTED]
623-582-0323
Fax 623-869-0675


--- StripMime Report -- processed MIME parts ---
multipart/signed
  text/plain (text body -- kept)
  application/x-pkcs7-signature
---

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/dabo-users/[EMAIL PROTECTED]

Reply via email to