Re: Tutorial of sorts

new topic     » goto parent     » topic index » view thread      » older message » newer message

lithex wrote:
> Here's my attempt at (Irv's) first problem:
> --This is a version of PAY.ex
> temp=value(cmd[4]) hours=temp[2]
> temp=value(cmd[5]) payrate=temp[2]
I hope I'm not intruding upon Irv's space when I say this,
and I also hope that I'm not viewed as being nit picky,
but I felt this was important to mention as it *is*
a learning situation...

My comment involves the throwing away of temp[1] in
the code lines above.  I'm not real sure that is a wise
thing to do; after all, if the user of the program
mistyped something on the command line invoking the
program, and value() failed to convert it, then a very
ungracious program abortion will follow...
you can read that as 'bad nasty *crash*' :)

I would think that right about now would be the perfect
time to get into the habit of actually checking for
that situation, and if that situation is found, you can
either exit gracefully from the program (which gives you
the opportunity to save potentially precious data) or
you can reprompt the user for a more appropriate value.

Yes, I understand that the parameters for the "tutorial"
didn't really discuss this issue, but, once again, I
feel it's never too early to develop this habit...

you see this situation *actually coded* for (nearly) every
routine that uses: fn=open("blah","w") if fn=-1 then...
that gets posted to the listserv, so why should value()
be any different, eh? :)

As for the rest of the code, kudos indeed.
IMO, well written, nice variable names, easily read...

> Name    Hours worked       Gross pay     Tax       Net pay
> Jose    40                 480.00        120.00    360.00
I am wondering about the header that was supposed to
go above the numeric output... ;)
but i'll leave that one up to Irv :)

take care, and I hope no feelings ruffled :)
--Hawke'

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu