WASHINGTON (AP) _ On Dec. 22, 1988, Mayor Marion Barry rushed his aides through a session on the city budget and then left hurriedly, saying he needed to attend a funeral.

But according to testimony in Barry's drug and perjury trial, the mayor first drove that day to the hotel room of an acquaintance, drug dealer Charles Lewis. Lewis has said in court that Barry presented him with a crack cocaine pipe and the two men tested it.

The events of that afternoon provide a glimpse into the life of a man whose official duties included grappling publicly with the difficulties of a large urban city, while - according to numerous witnesses at the trial - routinely using illegal drugs in private.

Medical experts say juggling such activities would be difficult, but not impossible, and that substance abusers can hide their problems from close associates.

But they pay a price.

''The bottom line is that in policy-making jobs, when you talk about alcohol and drugs, there's no question that they will have an effect on job performance,'' said Dr. Michael Stoil of the Washington-area chapter of Council on Alcohol and Drug Abuse. ''Normally, you see the effect mostly with attention span and concentration.''

''Studies of alcoholism, in particular, generally suggest that work is the last thing to go,'' said Dr. Marc Hertzman, a George Washington University psychiatry professor who studies the effects of substance abuse.

''When all else - marriage, family life - is gone, most people can still carry on effectively enough so that their associates and superiors do not suspect a problem,'' Hertzman said in an interview last week.

Barry has pleaded innocent to all charges, although he has admitted using cocaine in what he says was an FBI entrapment when he was arrested last Jan. 18 during a sting operation at a Washington hotel.

So far in the trial, which resumes Tuesday, eight prosecution witnesses have testified that they saw Barry use drugs, including cocaine, crack cocaine, marijuana and opium, with the first such allegation dating to 1985. One witness, Rasheeda Moore, testified that she and the mayor used drugs more than 100 times together.

Following his arrest, Barry spent seven weeks in Florida and South Carolina substance abuse treatment programs. He has said he was treated for addictions to alcohol and two prescription medicines.

The experts' experience that a substance abuser can continue to work, even though impaired, conforms with the recollections of Barry's top advisers.

''He seemed very distracted, unfocused,'' said one top Barry aide in recalling the December 1988 meeting on the city budget.

''He was in a real hurry to leave, and here we were talking about the possibility of a budget deficit. He did not give his full time and attention to the meeting,'' the aide said.

Even before that day in 1988, the mayor's own aides had begun a quiet surveillance of their own, keeping track of how many morning meetings Barry missed and whether he was paying attention in the ones he did attend.

''Something was wrong,'' one aide said. ''He had always been so sharp, but he just wasn't anymore.''

''It was like with families of alcoholics,'' said another top aide. ''We'd meet with him, come out and ask each other, 'Well, how did he look today?'

The aides spoke only on condition that their names not be used.

By the fall of 1989 many of Barry's top assistants had concluded privately that the mayor had a substance abuse problem.

They recall being startled in November 1989 when Barry used a city cabinet meeting to give a speech on the dangers of drug abuse and then introduce seven recovering addicts who discussed their problems.

''At the end of the meeting, in front of all 50 of us, the mayor asked one of them what cocaine felt like,'' said one cabinet member who was there.

And at the next month's cabinet meeting - less than a month before his arrest in the sting operation - Barry invited two doctors to address the group on the medical effects of drug abuse.

''It was almost like he was going through a cathartic experience, crying out for help, and dragging us along,'' said another cabinet member, who also spoke only on condition of anonymity. ''Many of us were ignorant about drugs, and the mayor certainly cast himself in that camp.''

One drug counselor says Barry's behavior fits a well-known pattern.

''Generally speaking, that is part of the manipulation that goes on in a person's mind to deny the use - to cover their tracks with other people,'' says Jill Wiedemann-West, a drug counselor with Hazelden Services Inc.

''Part of (the) denial is to make people believe you are not in any way, shape or form involved in drugs.''