DIM Position[1] AS REACT INTEGER
DIM Description[1] AS REACT STRING
DIM Quantity[1] AS REACT INTEGER
DIM Price[1] AS REACT DOUBLE
DIM Total[1] AS REACT DOUBLE

DIM VAT As REACT DOUBLE
DIM SumSubTotal As REACT DOUBLE
DIM SumVAT As REACT DOUBLE
DIM SumTotal As REACT DOUBLE

VAT = 19.0

SALES_ARRAY = CSVREADER("order.csv", ";", TRUE)

Position = SLICE(SALES_ARRAY, 1, 0)
Description = SLICE(SALES_ARRAY, 1, 1)
Quantity = SLICE(SALES_ARRAY, 1, 2)
Price = SLICE(SALES_ARRAY, 1, 3)

Total -> Quantity * Price
SumSubTotal -> SUM(Total)
SumVAT -> SumSubTotal * VAT / 100
SumTotal -> SumSubTotal + SumVAT

CLS
PRINT "--- Simple reactive order sample ---"
PRINT 
PRINT "Customer ordered: "
Order = STACK(1, Position, Description, Quantity, Price, Total)
PRINT "Pos Description       Quantity     Price       Total"
PRINT FRMV$(Order, "{:3d} {:<20} {:5d} {:>8.2f}$ {:>10.2f}$")
PRINT

PRINT "Regular order:"
PRINT FORMAT$("Subtotal: {:>10.2f}$", SumSubTotal)
PRINT FORMAT$("VAT:      {:>10.2f}$", SumVAT)
PRINT FORMAT$("Total:    {:>10.2f}$", SumTotal)
PRINT 

PRINT "We need new prices up to 10 Percent!"
Price = Price * 1.1
PRINT FORMAT$("Subtotal: {:>10.2f}$", SumSubTotal)
PRINT FORMAT$("VAT:      {:>10.2f}$", SumVAT)
PRINT FORMAT$("Total:    {:>10.2f}$", SumTotal)
PRINT 

PRINT "Administration reduced VAT to 7.0 %"
VAT = 7.0
PRINT FORMAT$("Subtotal: {:>10.2f}$", SumSubTotal)
PRINT FORMAT$("VAT:      {:>10.2f}$", SumVAT)
PRINT FORMAT$("Total:    {:>10.2f}$", SumTotal)
PRINT 
