Convicted cocaine dealer Charles Lewis testified yesterday that after he and Mayor Marion Barry learned that their drug use at a Ramada Inn in December 1988 had almost been discovered by D.C. police, they took frantic steps to avoid detection.

Lewis told jurors that after he was questioned by a Washington Post reporter about an aborted police raid of his room on Dec. 22, 1988, he destroyed the pipe he and Barry had used to smoke crack by smashing it and flushing the pieces down the toilet. Then, he testified, he and Barry agreed on what they would say to police, and Barry advised him that he could rid his system of evidence of drug use by drinking lemon juice and water.

Lewis was describing the aftermath of what has come to be known as the Ramada Inn episode, which prosecutors say spawned the drug conspiracy charges against Barry. In that episode, police detectives went to the downtown hotel in response to a maid's complaint that Lewis had drugs in his room, but they left abruptly when the hotel manager realized Barry was in Lewis's room.

Barry's defense lawyer, R. Kenneth Mundy, immediately attacked Lewis's credibility on cross-examination, asking about Lewis's plea agreement with prosecutors, his trial preparation by investigators and his history of drug use.

Mundy obtained an admission from Lewis that the primary reason he decided to cooperate with the government was to try to get a reduced sentence in another drug case.

In the first two hours of cross-examination Mundy did not directly challenge any of Lewis's key allegations about Barry's drug use and the atempts to conceal it.

The 50-year old Lewis, a former D.C. Office of Personnel employee, is testifying under a plea agreement in which the government agreed to drop more serious perjury charges against him and ask for leniency on a pending drug charge in the Virgin Islands in return for his testimony against Barry.

Earlier in the day, under questioning from Assistant U.S. Attorney Judith E. Retchin, Lewis said he found out about the aborted police raid from a Washington Post reporter about an hour after Barry left. Reporter Sharon LaFraniere had visited Lewis to investigate a tip about Barry's visit to his room.

Faced with the realization that he and Barry had almost been caught in the act, Lewis testified, he immediately smoked the crack that he and Barry had not used, and destroyed the pipe.

"I took the bottom of {a wine} bottle, and I took the pipe apart and I just knocked it on the bathroom floor, using the bath mat so it didn't go all over," Lewis said. Then, he said, he put the pieces in "the large hotel paper napkins and I just, you know, squeezed it together and I flushed it down the toilet."

A few hours later, he said, Barry called to say someone on his D.C. police security detail had told him about the incident, and the two of them talked guardedly about how to conceal the incident.

"What was the message you were trying to convey to Mr. Barry?" Retchin asked.

"It was a message of -- like trying to fix the dam," Lewis said. "We have a problem and we need to fix it, we need to get our stories straight."

Lewis said that what actually happened that day began with a 9 a.m. encounter in the corridor with a hotel maid. Lewis said he asked the maid, whom he recognized as having cleaned his room before, for paper to write a job application. Then, he said, he asked her if she wanted some cocaine, as "a friendly gesture."

The maid declined the offer and told the hotel manager, who called the police. Two undercover vice detectives showed up to investigate around noon -- just as Barry arrived to pay his visit.

Lewis said that Barry brought with him a crack pipe as a replacement for the makeshift smoking apparatus the two had been using. Then, he said, "we decided to test the pipe out and we smoked for about 10 or 15 minutes."

As Barry was leaving, Lewis said, "he said he would call me at the end of the day and he would be at another hotel, and he would have two or three ladies for us."

He said that after he learned of the aborted police raid from the Washington Post reporter and he destroyed the pipe, Barry "called and asked if the police had been there, and I told him no . . . . He told me that he learned from his security guard that they were coming, the police were coming to my room, but the mission got aborted because he was there."

Believing that his telephone might be bugged, Lewis said, he tried to get the message across to Barry that they should conceal their actions.

"I said, 'Well, Mr. Mayor, I told {the Washington Post reporter} that no, there was no drugs in the room. You didn't see any drugs in the room, did you, Mr. Mayor?' And he says, 'That is right, there was none.' "

"Why did you talk to Mr. Barry in the manner you just described?" Retchin asked.

"Because I thought that the phone was bugged and I didn't want . . . the mayor and me to be talking about drugs in a positive way," Lewis answered.

Later, Retchin asked, "Did you reach an understanding with Mr. Barry as to what you were going to tell the police?"

"Yes," Lewis answered. "My understanding was that I would tell the police the same thing I told the Post reporter."

"Were you going to tell the police the truth or a lie?"

"I told the Post reporter a lie and, therefore, I would be telling the police a lie."

The next day, Friday, Lewis said former D.C. Department of Public Works employee James McWilliams gave him a phone number to call Barry. By that time, he said, he had checked out of the Ramada and was staying at a friend's home. He called the number and asked for Barry after identifying himself as Alexander Farrelly, the governor of the Virgin Islands -- a name he said he knew Barry would recognize.

Barry told him that he had set up an appointment for Lewis to talk to police the next morning at 10 a.m., and he gave him "instructions on how to handle the security and going into the building," Lewis said.

Then, Lewis testified, he reminded Barry that "we in fact used drugs, and since I was the one to go to the police, drugs would be in my system, and I asked him if he knew any way where I could get it out, and he told me, yes. Just use lemon juice and lots of water."

"What did you do after getting that advice from Mr. Barry?" Retchin asked.

"I used a considerable amount of lemon juice and lots of water," Lewis said, eliciting laughter.

Much of Lewis's testimony was couched in street slang. At one point, Lewis referred to "a working 50," a term he said referred to buying crack at a wholesale rate. Instead of buying cocaine by the $20 bag, Lewis said, it was possible to spend $50 and get one large rock bigger than an oversized marble that was worth between $80 and $100.

To buy cocaine for himself and the mayor, Lewis said, he simply walked out of the Ramada, on Rhode Island Avenue NW, and up 14th Street NW. On some occasions, he said, he easily bought crack on the street within blocks of the hotel, but if he was in search of a "working 50" he had to travel farther.

To smoke crack, he and Barry used a pipe they improvised by stretching some perforated foil over the top of a sherbet glass half filled with water, putting cigarette ashes on top and the crack on top of the ashes. Then the user held a cigarette lighter close to the crack and inhaled the fumes, Lewis said.

Barry, who seemed almost buoyant throughout most of Lewis's testimony yesterday, broke into laughter when Lewis tried to explain his earlier testimony about the mayor's taking light bulbs from Lewis's room at the Ramada Inn.

At one point in Lewis's explanation, the judge, the lawyers and each of the jurors found themselves laughing at the specter of Barry unscrewing the large, globe-style bulbs from the bathroom and slipping them out of the room.

At the end of the day, Barry, with Mundy at his side, clowned for the television cameras, patting his jacket to show that he was not carrying any light bulbs.

Barry's mood seemed upbeat from the start. When he entered the courtroom yesterday morning, he joked with Sgt. Al Arrington, a D.C. police detective who has worked on the Barry investigation, and, in a chat with reporters that was cut off by a deputy U.S. marshal, he quipped again about the prosecution's "canaries."

In the morning, Barry shook hands with Cora Wilds, his close friend and former chairman of the D.C. Boxing and Wrestling Commission, who resigned in 1987 amid allegations she defrauded the government on travel expenses. She was convicted on a federal misdemeanor charge related to the expenses.

In the afternoon, Wilds was joined in the front row by Barry's wife, Effi, who sat hooking what she described as "a baby rug."

Yesterday's court session was delayed for 45 minutes while U.S. District Judge Thomas Penfield Jackson met with prosecutors and defense lawyers in the judge's chambers. At one point, while the lawyers were back in the courtroom, Jackson called for a stenographer, apparently to record an in-camera examination of a juror.

A transcript of two bench conferences held later in the day indicated that Jackson was seeking testimony from WRC-TV (Channel 4) reporter Joe Johns "to resolve that juror question." In both bench conferences, Jackson said he was waiting to hear from the station's lawyer, John Cassidy, about the matter.

Cassidy and Johns were unavailable for comment late yesterday.

At the end of yesterday's court session, Jackson held a bench conference at which he and defense lawyers complained to each other about the complaints they had received about the lack of public seating in the courtroom.

There are 18 seats available to the public, and dozens of people line up for the spaces at the start of each day.

"The phone is ringing off the hook in every {judge's} chambers," Jackson said, according to a transcript. Mundy noted that more than half the courtroom has been allocated to press seating, and Jackson said there still were reporters clamoring to cover the case.

"I have got agonizing requests from Time magazine, The Wall Street Journal."

Jackson said he heard "not altogether facetious conversations at lunch about moving into the sports coliseum."