Re: Tutorial of sorts
- Posted by Irv Mullins <irv at ELLIJAY.COM> Oct 25, 1998
- 456 views
On Sat, 24 Oct 1998 18:47:50 -0700, Hawke <mdeland at NWINFO.NET> wrote: (see previous message) Some very good points: Let's try to develop this as if it were a real-life programming project. I will supply the main body of code, written so that a client could understand it. (They tend to like things like that.) Anyone who wants to work on the tutorial can supply the functions/ procedures needed to implement the code. There *MUST* be more than one way to implement each of these. Some ways are more Euphoric than others. I hope to see some examples! Here goes: -- PAY.EX - a payroll program written in Euphoria -- version 1.3 object cmd -- storage for data input on the command line atom data_is_valid cmd = command_line() -- we'll get it the most simple way for now if length(cmd) = 5 then -- valid number of arguments supplied data_is_valid = TRUE else -- invalid number of arguments supplied notify("Syntax is:", "ex pay employee-name hours-worked pay-rate") abort(1) -- no point in going any further end if emp[name] = cmd[3] -- extract input items emp[hours] = valid(cmd[4],{1,80},"Hours") -- and check for emp[payrate] = valid(cmd[5],{5.25,35.00},"Payrate") -- reasonable values. if data_is_valid then print_check(emp) log("PAYROLL.DAT",emp) else log("PAYERR.DAT",emp) notify("Error", "Unreasonable hours or payrate entered - see file PAYERR.DAT") abort(1) end if --- end of program -- FORMATS -- for now, the check can simply be two lines to the screen: -- Name Hours Payrate Gross Tax Net -- Juan 40.0 12.00 480.00 120.00 360.00 -- the logfile formats -- for PAYROLL.DAT: -- 00/00/00 Juan 40.0 12.00 480.00 120.00 360.00 -- for PAYERR.DAT: -- 00/00/00 Juan 40.0 333.00 -- end of assignment