![]() |
H.2 Passing Simple Parameters to Routines |
profit = 1234 tax_rate = 6.5/100 calculate_tax_due with amount profit, rate tax_rate, returning due tax_due print 'Tax due: '; tax_due private routine calculate_tax_due with amount, rate, returning due due = amount * rate end routineThe with clause contains the names of the parameters coming into the routine. The returning clause contains the names of the parameters returned by the routine.
myamount = 45 myrate = 5.6 calculate_tax_due with amount myamount, rate myrate, returning due mydue private routine calculate_tax_due with amount, rate, returning due due = amount * rate end routineInstead, we could use this code:
amount = 45 rate = 5.6 calculate_tax_due with amount amount, rate rate, returning due dueand even further simplify it as:
amount = 45 rate = 5.6 calculate_tax_due with amount, rate, returning dueThe examples produce equivalent results where the last example is the simplest.
Hide Description
|
|
Looking for the full power of Sheerpower?
Check out the Sheerpower website. Free to download. Free to use. |