Thanks NorthGuy - neither was the case but cheers.
MarkF - tried the PWRTE but no difference. You're right about the clock: it was a hang-over from a previous investigation. I let the chip default to 4MHz and everything was the same.
Doctorandus_P - I don't have a logic analyser, worse luck!
nigelwright7557 - no I'm the one missing something: I forgot to show the resistors in the diagram, sorry, they are there though.
newbrain - oh. I though it was both clever and elegant, sorry. I would rather do things according to convention though so thank you.
Ian.M - thank you once more for your help (ref. many, many of my posts in the past). I tried it out and it does work (of course) thank you. See below.
Thank you very much to everyone. I used your points, and indeed code, to investigate. I was still getting weird errors that varied with all kinds of things: delays, whether MCLRE = ON or =OFF, when I cycled the power and so on.
Then came the final breakthrough. No matter what these things (delay, etc.) were set to or what I did it worked every time. What did I change? I unplugged the pickit3! When I unplugged it from the chip and powered on or reset it worked perfectly.
What a pain in the @rse.