A Selkirk man who admitted a series of offences has avoided a jail sentence at the town's sheriff court.
But Dean McCallum was warned that if he returned to illicit drug taking and commits a further offence the court would have no option but to send him to prison.
Sheriff Peter Paterson admitted he was taking a "chance" with the 28-year-old by imposing an alternative to custody.
But he said McCallum had appeared to be making progress in the past few months.
The sheriff said: "I am giving you all the benefit the court can do at this stage."
McCallum pleaded guilty to possession of an offensive weapon in Selkirk in May, possession of cocaine at Hawick Police Station on September 14 and two counts of behaving in a threatening or abusive manner.
His Community Pay Back order involves 200 hours of unpaid work as well as a night time curfew at his Buccleuch Road home for the next four months.
Comments: Our rules
We want our comments to be a lively and valuable part of our community - a place where readers can debate and engage with the most important local issues. The ability to comment on our stories is a privilege, not a right, however, and that privilege may be withdrawn if it is abused or misused.
Please report any comments that break our rules.
Read the rules hereComments are closed on this article