Making programmes which rely heavily on archive is a joy for any political anorak.

My trawl through some of the key moments in the UK's relationship with Europe has throw up the odd nugget of new information, when I am jolted to ask: "Have I heard that before? Did I know that?"

Working alongside producer Vicky Lee, I have spent some time recently looking at old footage and interviews, some of them conducted when I had no grey hair and a jaw-line as opposed to a jowl.

Ted Heath was the stiff, aloof and not terribly voter-friendly Prime Minister who took the UK into the then EEC when he signed the Treaty of Accession in 1972. Heath's premiership was governed by events, great issues of the day which he rarely controlled. Whether it be Northern Ireland, Upper Clyde Shipbuilders or the miners' strikes of 1972 and 1974, he cut an often forlorn figure whose lack of direction was defined by a series of humiliating policy u-turns.

He was also unloved by the Conservative Party and he became a hate figure for Thatcherites and Eurosceptics, many of whom quite despicably presented his bachelor status as yet more evidence that there was something not quite right about Ted.

And yet Heath has left a more indelible imprint on the history of this country than many politicians of his generation. His European legacy is one that no amount of sneering from his enemies can change. When I met and interviewed Heath in 2000 I left with a different view of him. In truth he was not a good prime minister and he was no match for the wily Harold Wilson. And yet he had the courage to pursue a policy on Europe which cut across the instincts of a large swathe of his party and country.

Heath made his maiden speech in 1950 on the need for closer cooperation in Europe, being derided in the process by Stafford Cripps on the Labour benches. He had been in Germany during the rise of fascism and his belief was simple: Interdependence born from economic and political mutual interest would make war impossible in the future. This was Churchillian in policy terms and the ideal was pursued with an integrity that was impressive.

Of course de Gaulle vetoed the application by Harold Macmillan's Conservative government in 1961. By 1964 another Harold was in Downing Street. Labour and Harold Wilson had not been particularly enthusiastic about Europe. Indeed the party's European wing led by Roy Jenkins had been dismayed by Hugh Gaitskell's leader's speech to the 1962 conference, when he warned about throwing away one thousand years of history.

Gaitskell's untimely death in January 1963 led to a leadership contest. The two front runners were Harold Wilson and the mercurial George Brown. "A choice between a crook (Wilson) and a drunk (Brown)," complained Anthony Crosland who initially backed Jim Callaghan before opting for the drunk when Callaghan was eliminated.

And yet as our programme points out it was the drunk who drove the European project within the Labour government. The source for this is an interview I conducted with George Thomson, Lord Thomson of Monifieth, in 2005. MP for Dundee East for 21 years, he was the last Secretary of State for Commonwealth Affairs and someone who would go on to become a European Commissioner in 1973. He would have joined the SDP in 1981 had he not been leading the IBA, making the key defections from Labour a Gang of Five.

Thomson recalls that George Brown fought like a tiger to keep the European issue alive during Labour's period of office (1964-70). But again de Gaulle vetoed a further application. Harold Wilson appears privately at least to have been won over to the European cause at this time. Lord Thomson told me that during the 1970 general election campaign Wilson had phoned him signing off on a speech Thomson would make committing the party to membership and progressing a fresh application when they won the election. Against the odds and most of the polls Labour lost and the Conservatives won in 1970. Europe would be Heath's lasting legacy not Wilson's.

By the time of the 1975 referendum most in the major UK parties were comfortably pro-EEC. In Scotland however the terrain was different. The SNP was implacably opposed to UK membership, viewing the EC as overly centralist. In those days the party also took a more classically nationalist position on sovereignty. It was something to be preserved not to be shared or pooled or given away. After all, the SNP were not fighting for Scottish independence to start ceding powers to foreign interests.

That of course is in stark contrast to the position of today when not a single elected member of the SNP backs the 1975 position. "Independence in Europe" was adopted by the SNP in 1988 although the party had been softening its stance on the EC post 1983 under Gordon Wilson's leadership. It is a measure of changed circumstances that Jim Sillars, the architect of the 1988 policy shift, now backs Brexit. Indeed Gordon Wilson has been kite-flying with the suggestion of a tactical vote for Brexit as the outcome most likely to produce a second referendum on Scottish independence.

Europe has divided every party bar the Liberal Democrats. In the current Conservative Party it is the only issue capable of igniting a civil war. The stakes at this referendum are enormous. It will decide David Cameron's future and perhaps ultimately that of his party too.

But overshadowing the interests of one governing party, it could also determine the future of an entire continent. As Bruno Waterfield of The Times perceptively observes, even if the vote is for remain, every other European country will learn a lesson from the Prime Minister's politicking. Namely that you can go to the European Council and start unpicking parts of the project you don't like.

That could usher a new culture of how the member states interact. Therefore even a vote for remain could ensure the EU will never be the same again.

Comment by Bernard Ponsonby, STV's political editor. He joined the station in 1990 and became political editor in 2000. He has presented most election, by-election, and results programmes over the last quarter-century.

Watch Everything You Wanted to Know About the EU (But Were Too Afraid to Ask) at 10.30pm on STV and the STV Player.