65 lines
3 KiB
Text
65 lines
3 KiB
Text
Module Currency_Task {
|
|
Locale 1033
|
|
Font "Courier New"
|
|
Form 80,32
|
|
\\Decimal type
|
|
hamburgers=4000000000000000@
|
|
\\ Currency type
|
|
hamburger_price=5.5#
|
|
milkshakes=2#
|
|
milkshake_price=2.86#
|
|
tax_rate=0.0765#
|
|
\\ Using Columns with variable width in console
|
|
PrHeadLine("Item","price","quantity", "value")
|
|
PrLine("hamburger",hamburger_price,hamburgers,hamburgers*hamburger_price)
|
|
PrLine("milkshake", milkshake_price,milkshakes,milkshakes*milkshake_price)
|
|
PrResults( "subtotal", hamburgers*hamburger_price+milkshakes*milkshake_price)
|
|
PrResults("tax", (hamburgers*hamburger_price+milkshakes*milkshake_price)*tax_rate)
|
|
\\ 1 is double by default we can use 1# or 1@
|
|
PrResults("total", (hamburgers*hamburger_price+milkshakes*milkshake_price)*(tax_rate+1))
|
|
|
|
\\ Using variables for partial calculations. They get type from expression result
|
|
h_p_q=hamburgers*hamburger_price
|
|
m_p_q=milkshakes*milkshake_price
|
|
|
|
\\ Using format$ to prepare final strings
|
|
Print format$("{0:15}{1:-8}{2:-25}{3:-25}","Item", "price", "quantity", "value")
|
|
Print format$("{0:15}{1:2:-8}{2:0:-25}{3:2:-25}","hamburger",hamburger_price,hamburgers, h_p_q)
|
|
Print format$("{0:15}{1:2:-8}{2:0:-25}{3:2:-25}","milkshake", milkshake_price,milkshakes,m_p_q)
|
|
Print format$("{0:-48}{1:2:-25}","subtotal", h_p_q+m_p_q)
|
|
Print format$("{0:-48}{1:2:-25}","tax", (h_p_q+m_p_q)*tax_rate)
|
|
Print format$("{0:-48}{1:2:-25}","total", (h_p_q+m_p_q)*(tax_rate+1))
|
|
\\ Another time to feed Document to export to clipboard
|
|
Document Doc$=format$("{0:15}{1:-8}{2:-25}{3:-25}","Item", "price", "quantity", "value")+{
|
|
}+format$("{0:15}{1:2:-8}{2:0:-25}{3:2:-25}","hamburger",hamburger_price,hamburgers, h_p_q)+{
|
|
}+format$("{0:15}{1:2:-8}{2:0:-25}{3:2:-25}","milkshake", milkshake_price,milkshakes,m_p_q)+{
|
|
}+format$("{0:-48}{1:2:-25}","subtotal", h_p_q+m_p_q)+{
|
|
}+format$("{0:-48}{1:2:-25}","tax", (h_p_q+m_p_q)*tax_rate)+{
|
|
}+format$("{0:-48}{1:2:-25}","total", (h_p_q+m_p_q)*(tax_rate+1))+{
|
|
}
|
|
clipboard Doc$
|
|
\\ one line user function definition
|
|
\\ x get type from passed value
|
|
Def ExpressionType$(x)=Type$(X)
|
|
\\ Check Expression final type
|
|
Print ExpressionType$(hamburgers)="Decimal"
|
|
Print ExpressionType$(milkshakes)="Currency"
|
|
Print ExpressionType$(h_p_q)="Decimal"
|
|
Print ExpressionType$(m_p_q)="Currency"
|
|
Print ExpressionType$((h_p_q+m_p_q)*tax_rate)="Decimal"
|
|
Print ExpressionType$((h_p_q+m_p_q)*(tax_rate+1))="Decimal"
|
|
|
|
Sub PrHeadLine(a$,b$,c$,d$)
|
|
Print Part $(1,15),a$,$(3,8),b$, $(3,25),c$, $(3,25),d$
|
|
Print
|
|
End Sub
|
|
Sub PrLine(a$,b,c,d)
|
|
Print Part $(1,15),a$,$("0.00"),$(3,8),b, $("0"),$(3,25),c,$("0.00"), $(3,25),d
|
|
Print
|
|
End Sub
|
|
Sub PrResults(a$,b)
|
|
Print Part $(3,48),a$,$("0.00"),$(3,25),b
|
|
Print
|
|
End Sub
|
|
}
|
|
Currency_Task
|