THE constitutional role of the head of state is not normally that common a subject. After all, in advanced democracies, the monarch or president usually performs an uncontentious and largely ceremonial role, miles above the hurly-burly of politics.

In recent weeks, however, this has been severely tested in the UK, with revelations about the unlawful shutting down of Parliament and intervening in the 2014 independence referendum debate.

As we know from the judgment of the Court of Session, the current prorogation of Westminster was unlawful. Her Majesty the Queen followed the recommendation of her Prime Minister Boris Johnson as is established custom and practice. The prorogation was given effect following a visit to Balmoral by the Lord President of the Privy Council, Jacob Rees-Mogg.

READ MORE: No-Deal Brexit police sent to Glasgow loyalist marches

The summary of the judgment by Scotland’s highest court stated that: “Accordingly the court will make an order declaring that the Prime Minister’s advice to HM the Queen and the prorogation which followed thereon was unlawful and is thus null and of no effect.”

Hot on the heels of the British political establishment putting the monarch in an invidious position on prorogation, came further confirmation that the very same kind of people did exactly the same during the independence referendum.

Former prime minister David Cameron has confirmed: “I remember conversations I had with my private secretary and he had with the Queen’s private secretary and I had with the Queen’s private secretary, not asking for anything that would be in any way improper or unconstitutional but just a raising of the eyebrow even, you know, a quarter of an inch, we thought would make a difference.”

The National: David Cameron was not above using the Queen for political gainDavid Cameron was not above using the Queen for political gain

READ MORE: Tories will pay a high price for treating Scots with contempt

If ever there was a mendacious statement there it is. Put in plain language: the UK PM confirmed that arrangements were made via the most senior officials at Downing Street and Buckingham Palace for the Queen to act in a way that would have a material impact on a highly political campaign.

What has received less publicity is the confirmation on Radio 4’s PM programme by the then-BBC royal correspondent that the intervention was also flagged up proactively by a Buckingham Palace source with a view to receiving media attention.

No wonder the palace has let it be known this week that there is real “displeasure” over Cameron’s actions. After all it is essential for the monarch to act, and be seen to act, in a totally non-political way. These are the long-established unwritten rules.

All of this exposes the difficult line that heads of state sometimes have to walk. In most European countries, including our own, the monarch or presidents have a largely representational and ceremonial role. Regardless of whether a republic or constitutional monarchy, being positioned above the political fray and fault lines is really important.

Our northern European Nordic neighbours have been well served by their current heads of state Margrethe II of Denmark, Harald V of Norway and Carl XVI Gustaf of Sweden and those who preceded them.

Our Irish neighbours have a first-class president in Michael D Higgins, and before him Mary McAleese and Mary Robinson. Iceland has the talented Gudni Thorlacius Johannesson as head of state, and before him the great friend of Scotland Olafur Ragnar Grimsson.

The National: Irish president Michael D HigginsIrish president Michael D Higgins

READ MORE: Angus Robertson: It’s time for Scotland and Wales to show there’s a better way forward

All of them have faced challenges at one time or another at the intersection of their ceremonial position and their country’s political system. Over my years in politics and journalism I’ve been fortunate enough to see this working first hand.

During a decade as a broadcaster in Vienna I got to know both the conservative-backed diplomat president Thomas Klestil, followed by social democrat-supported Heinz Fischer, and more recently the inspiring former Green party leader Alexander Van der Bellen. All have tried to rise above the political fray, but have wrestled with constitutional powers, including swearing in (or not) government appointees. This matters in a country which now has far-right Freedom Party (FPO) ministers. With only a week to go until the Austrian general election, President Van der Bellen has already ruled out swearing in a particularly controversial former FPO interior minister.

During my time in UK elected politics as a constituency MP and as the SNP Westminster leader, I found myself increasingly at events with the royal family, from the annual Remembrance Sunday commemoration, to state events at Parliament and Buckingham Palace, and latterly as a member of the Privy Council. Without doubt the royals are massively committed to their public service roles and doing the right thing at home, across the Commonwealth and further afield.

As Scotland moves towards independence, we can look forward to our elected parliament, government and head of state that all will play important roles in our national life.

But unlike the UK it will be with a written constitution. All of our neighbours, whether monarchies or republics, have a set of clearly understandable rules and practice in the form of a written constitution. It won’t solve all challenges in all circumstances, but it would stop the sharp practice we have seen from British prime ministers like Boris Johnson and David Cameron.