William Cunningham, 9th Earl of Glencairn — Scottish judge