COURT psychiatrist to the early Stewarts. Now in medieval Scotland that would have been a job with prospects . . . and long hours. Forsooth, they were a bunch o' heidbangers.

Somehow, however, a goodly number of the Stewart kings, the most famous dynasty in Scottish history and all candidates in their own ways for the analyst's couch, contrived prior to James V to meet a variety of gory ends, by exploding cannon, assassins' knives, or diced and spliced on the battlefield.

What a surprise then to learn that James V died, so we're told, from melancholy, or as we say today - depression. I first learned this in the legendary Doc MacPhail's history class at Clydebank High and I remember being amazed. I'm still amazed when I ponder James's pitiful, clean, in-between-the-sheets end.

Mind you, the Stewart monarchs had a lot to put up with, what with a shaky economy, rebellious nobles, religious intrigues, and big brother England always poking his nose into our affairs. It's a wonder more of them didn't just give up the ghost or turn to the medieval version of Prozac, a goblet of claret.

But does James V's miserable, face-to-the-wall, conclusion to life really stand up to scrutiny? Were the blues so bad that he just curled up and died? Or were there other contributory factors? Actually, like everything else in Scottish history it's not at all straightforward.

First a few wee statistics. James V was 30 when he died at Falkland in 1542 and was buried beside his first queen Madeleine, a victim of tuberculosis who, some historians say, James married for her money.

Were there any early signs of the black humour which was to overtake James towards the end of his short life? In his youth the king was certainly physically in good nick. The chroniclers of the period described him as ''much addicted to manly sports and exercises''. Apparently he rode gracefully and took delight in hunting. He sang and danced, and found ''stern joy'' in feats of arms.

He also, it seems clear, enjoyed, in the poetic and descriptive patter of the time ''breaking a lance'' with the ladies. When he fled Falkland and his noble custodians it was assumed he had gone off to see a girlfriend.

The picture which emerges as James approached his 20th year was of an active young man with his head very much together. For example, he converted his old hobby of hunting into a means of dispensing justice in lawless parts. Jamie would summon a Border hunt (once a ''hunting party'' 12,000-strong gathered in Edinburgh) and off they would go mob-handed to chase the deer and hang the hoodlums.

By 1540 he had begun his dissent into despair. His second wife, Mary of Guise, gave birth to two princes, James and Arthur, but both infants died suddenly. James was reported to be physically unwell, possibly as a result of a horse-riding accident sustained a few years earlier.

In October 1541 he was distraught not to reach his mother's bedside before she died of a stroke. He was sleeping badly, suffering terrifying nightmares. James was also furious with his disaffected Protestant nobility who seemed reluctant to turn out against the English and after the surrender at Solway Moss he was said to have been overtaken by ''sudden fear and astonishment''.

Alas, there was no psychiatric care or even a kind ear, and James withdrew further into himself. It seems certain that physical problems exacerbated his mental state.

At Falkland he died, whispering: ''It cam' wi' a lass; it will gang wi' a lass.'' This was a reference to the birth a week earlier of his daughter Mary Queen of Scots, and the likely end of the Stewart dynasty.

Poor James, even his deathbed words proved flawed. Mary married her cousin, Henry Darnley, and the Stewart bandwagon rolled on.

Jim Hewitson