Post by Richard H.Thanks, I have it working correctly now.
Good! I'm glad to hear that. No sarcasm this time.
Post by Richard H.Maarten, thanks for the free insult :)
Always pleased to be of service.
At the risk of overstaying my welcome, I'd like to expound a bit
on the development of your code as we could see it from our side.
You had a first version. It didn't work. You identified, mostly
correctly, the problem with it. You asked for advice. You got a
little more than you bargained for.
The next step is where it got problematic, and where I got curt.
You tried to use the advice you were given, but you did not spend
enough time checking the advice itself, and what the functions
mentioned did exactly, and which part of that you needed, and how
to integrate it with your existing solution to make it start to
work.
Instead, you applied what has been described as the Jackson Pollack
approach to programming - throw code at the system, trying to see
what works.
While it's undeniably creative and occasionally makes for beautifully
psychedelic code, it's actually quite rare that you stumble upon the
correct solution using _only_ that method. Thinking carefully about
what you have, what you want, and how to get from one to the other,
generally works faster and better.
There is actually a bit of real science in there. 'What you have' is
called the precondition. 'What you want' is the postcondition. The
prescription how to transform the precondition into the postcondition
is called an algorithm. Note that to design an algorithm (which can
be very simple!), you need to know where you come from and where you
want to go. Only then can you think clearly about the steps to take
on the way.
Hope that helps.
Groetjes,
Maarten Wiltink