I managed to solve the problem, but it was rather drastic and requires a time machine backup. I wondered whether the hard disk had developed a fault, despite diskcheck saying it was ok, because I could hear it cycling through a repeated sequence when I put my ear to the Macbook, usually a sign that it was unable to read a sector. So I replaced the hard disk, by opening up my Mac with a screwdriver (removing all the little screws underneath) and taking out the hard disk. It is a standard SATA disk and I bought a replacement (a Toshiba 500 GB 2.5" which I believe is what is used in the 2011 Macbook Pros - in fact it looked identical to my existing har ddisk), plugged it in and closed up the Mac. When I rebooted I either held the shift key down or the R key (can't remember now but it is referred to online) to start in recovery mode. You get some options, one of which is to reformat the hard disk, which I did to standard OSX journaled. Then I selected restore from time machine and waited 10 hours. Once the system was restored everything seemed to work fine from then on. However, the machine did "crash" once, again when I moved the mouse to the dock to open a program. Before I even got to the program the dock crashed for about 10 seconds and then the systen logged me out. But this time I was able to log in again.
Ho hum ... I hope Apple come good again. I left Microsoft some years ago as the Apple products were better, but now I am not so sure. And they are hideously expensive too.