Tim Barrow's play Union, showing at Edinburgh's Royal Lyceum Theatre, contains fleeting references to Darien in its spirited depiction of the events leading to the marriage of Scotland and England more than three centuries ago.

"Our one great hope of colonial power, Darien, has failed," reflects a member of the old Scots Parliament during a debate on the proposed Union, while the English protagonists in London allude to Scotland's wealth having been "largely lost in the Darien disaster", which of course it had.

Bawdy and fun, but also rather cartoonish in its treatment of the history (Barrow confesses to having known nothing about it before writing the play), I couldn't help feeling it undersold the importance of Darien, a short-lived yet hugely consequential episode in the story of both Scotland and Great Britain.

Early last week I strolled around Plaza Frances in Panama City's Casco Viejo, which overlooks the mouth of the Panama Canal and the Bridge of the Americas."

One engraved panel commemorates "Guillermo Patterson" (William Paterson), the visionary founder of the Darien scheme. Trade, he predicted, would "increase trade, and money will beget money… thus the door of the seas and the key of the universe" would open without "being liable to the fatigues, expenses and dangers".

But eloquence was not enough to save Darien from exactly those liabilities. Although Paterson's vision of a trading colony linking the Atlantic to the Pacific in the late 17th century was 200 years ahead of its time, it wasn't enough to be right; Paterson had to be right at the right time.

The death knell came on May 18, 1699, in the form of an English veto, the Governor of Jamaica Sir William Beeston (a 17th-century equivalent of George Osborne) declaring that the settlement of Caledonia was "contrarie to the peace entered into with his [Majesty's] allies, and therefore commanded me that no assistance be given them".

Therefore not a penny in trade returned to the coffers of the Company of Scotland in Edinburgh, later dissolved under the terms of the Treaty of Union. The rump morphed into an Equivalent Society charged with administering the £400,000 compensation paid to the Darien investors; in 1724 this became the Equivalent Company and three years after that the Royal Bank of Scotland.

Thus the Darien story - as was the case with the near-demise of RBS three centuries later - became in the eyes of some a tale of Scottish enterprise betrayed by English duplicity or worse, incompetence. Hubris had of course played its part, with Darien's backers boasting of an opportunity for a small nation to make accelerated profits by exploiting a strategic trading advantage.

Today, independence is sometimes sold as a constitutional get-rich-quick scheme, a chance to fulfil a myriad of desires, capitalist, socialist and nationalist. Yes Scotland posters currently hint at the great wealth to be unleashed if only Scots put X in the correct box come September.

And the question of currency remains potent. Speaking at a Yes Scotland event last week the SNP MSP Joan McAlpine said an independent Scotland using sterling without a formal currency union was a "pretty attractive" prospect. This is otherwise known as the "Panama option", and indeed so-called "dollarisation" also operates in El Salvador as well as informally throughout Central America.

Receiving, understandably, more attention was another dissenting (but unnamed) voice in the Better Together camp, which admitted blithely that "of course there would be a currency union". Overlooked by an understandably gleeful Yes camp was the quid pro quo (keeping Trident at Faslane) and the most important consideration: what the terms of a currency union might actually be. One off-the-record comment does not suddenly make Plan A intellectually coherent.

In Panama, the Plan B favoured by Ms McAlpine operates reasonably well although it isn't complete; some domestic coinage circulates alongside trusty greenbacks. But the obvious weakness remains: Panama and El Salvador might use the dollar, but they have no control over US monetary policy; the fact they use another country's currency is a tacit admission of economic weakness, not strength.

Only in 1999 did Panama gain full control of the Canal and its economy, as a result of liberalisation in the mid-90s, is now the largest in the region. In Nicaragua, meanwhile, veteran president Daniel Ortega plans a rival waterway he says will enable his much poorer country to achieve "total and definitive independence", by which he means economic self-sufficiency.

Today there are no roads to "Punta Escoces" in Darien and it remains difficult to access, although "Escocia" trips easily from the tongues of taxi drivers and an electoral district in the capital (polling is due in May) even bears the name Calidonia (sic). In John le Carre's novel The Tailor Of Panama, the banker Ramon Rudd claims to be descended from Scottish adventurers left stranded by the Darien disaster.

Fittingly Theodore Roosevelt, who as US president championed construction of the Panama Canal, was descended from the Rev Alexander Stobo, one of the original Darien settlers who relocated to the US rather than face the shame of returning to Scotland. The Canal was, in the words of John Prebble, "the ultimate realisation of William Paterson's dream".

The failure of Darien also highlighted tensions in the 1603 Union of the Crowns, for the legislative battle over succession and further English restrictions on Scottish trade that followed exposed the folly of a single monarch supposedly representing two competing interests. That too was resolved by the Treaty of Union, which of course created a single kingdom "by the name of Great Britain".

And thereafter Scotland was able to indulge its imperial ambitions that had been so cruelly frustrated in Central America, albeit in concert with England rather than as an independent nation. Thus the spirit of Darien achieved belated success in the heavily Scottish character of the British Empire.

Which is why talk of independence restoring equality to the relationship between Scotland and England is difficult to take seriously. Darien reminds us that no such "equality" existed prior to Union, and nor would it after: even if an independent Scotland succeeded in growing its population by a million and its economy via tartan neoliberalism, rUK would still dominate. The two nations might be "equal" in an abstract sovereign sense, but in the real world it would look rather different.

"Darien is now a scar on the memory of the Scots," concluded Prebble's account of the debacle, "and the pain of the wound is still felt even where the cause is dimly understood." But Darien does not illustrate, as some straw men would have it, that Scotland is too wee, too small and too poor to be independent once again. Rather it shows that the fates of nations do not rest on their size or ambitions, but also on luck, and that's something few governing men or women can have any hope of controlling.