A man who was selling thousands of pounds worth of cannabis to fund his cocaine habit has walked free from court.

Tristan Wilcox, 35, had drugs worth almost £2,500 stashed in his microwave oven when police searched his home early last summer.

But after hearing Wilcox was keen to beat his addiction a judge allowed him to keep his liberty.

Hannah Squire, prosecuting, told Swindon Crown Court on Friday how police went to his home on Sunday, June 2.

When they searched it they found two quantities of cannabis stored in the microwave in the kitchen.

She said he had 168 grams of herbal cannabis, which is worth up to £800 in street deals, and 168 grams of cannabis resin valued at £1,680.

After he was arrested he was questioned and told officers he would sell the drugs to friends to fund his cocaine habit.

"In cases like this one always has to wonder how many friends on has and if anyone one sells drugs to isn't a friend," she said.

Wilcox, of River Parade, Chippenham, pleaded guilty to two counts of possessing drugs with intent to supply.

The court head he had a number of previous convictions but only one for drug offences, when he was caught with cocaine and cannabis in 2006.

Alex Daymond, defending, said: "He is clearly someone who is trying to deal with his drug problem. He is suitable for a drug rehabilitation requirement."

He said he was unlikely to receive a jail term long enough for him to get any help in custody.

"He is a long term drug addict and he has built up considerable debts as a result of that habit and it is a familiar story of someone who had fallen in to supply to fund that habit," said Mr Daymond.

Recorder Richard Onslow said: "This is your first appearance in the crown court, otherwise you have more or less kept out of trouble.

"You know possessing drugs is an offence, you know you must not sell drugs to other people.

"You had 168 grams of cannabis and 141 grams of resin when your property was searched last year. You made full admissions in interview and pleaded guilty at the first appearance in the crown court.

"Having such a quantity of drugs you qualify for a custodial sentence. Because of what you have done I can suspend that custodial sentence.

"Because of that the four months I impose on you will be suspended for 18 months."

He imposed a drug rehabilitation requirement and told Wilcox he must be under the supervision of the probation service for a year.