Last week the Supreme Court tried to write a great compromise -- and came out with a great muddle.

The case came from New Jersey, where an assistant vice principal opend a 14-year-old girl's pocketbook looking for cigarettes. The administrator found them, and also found marijuana and evidence that the girl had been dealing as well as smoking dope.

If that official had been a cop, if the schoolhouse had been a home, if the student had been an adult, it would have been unconstitutional to search that pocketbook without ''probable cause.'' But the court ruled that in this unique setting called schools, in this unique relationship of student to administrator, the search was legal.

By a margin of 6-3, the Supreme Court said that the school authorities couldn't invade the personal belongings of of a student on a mere whim. But they could open a purse or a bookbag if there were ''reasonable grounds'' to believe that they would find evidence that the student had broken a law or a school rule. The court didn't say what was ''reasonable.''

I read this decision with the typical double focus of a parent. One eye was fixed on the hundreds of high schools where the lavatories and staircases are off-limits to most kids because a few have turned them into drug stores or rule them with weapons. The other eye was fixed on the official in many schools, the one inevitably nicknamed ''little Hitler,'' who gleefully enforces trivia. I wondered if there was no way to make students safe from one group without making them vulnerable to the other.

Like most citizens, I willingly give up a bit of my own privacy to ensure my safety. Every time I go into an airport, I allow my bags to be X-rayed and even searched in exchange for being protected from someone else' bomb. But is school now a giant terminal full of strangers who must be wary of each other? Is school so dangerous that students have to give up their privacy for protection?

I am very conscious of the need for a safe environment for learning. Polls show that more than half of us believe drugs are used aschool and more than a third rank discipline as the No. 1 problem. As part of his majority opinion, Justice Byron R. White wrot, ''In recent years . . . drug use and violent crime in the schools have become major social problems.'' The atmosphere is ripe for a turn to law and order.

But I am also aware of the need for a comfortable environment for learning. We don't want prison-schools in which the underground curriculum teaches harassment and abuse by authority.

The nature of our ambivalence about he teacher-student relationship encountered here is as old as our public-school system. Do teachers have the authority of parents or of the state? Do students have the rights of children or citizens? We alternately entrust children to the care of schools and protect them from the abuses of schools. Our feelings about this relationship vary enormously according to our experience, or to the student or teacher that comes to mind.

In 1977, the courts allowed the schools to hit students, to use ''erasonable force to . . . correct pupils and maintain order.'' Now they are allowed to invade students' privacy as long as it is ''reasonable.'' As Harold Howe, a former U.S. commissioner of education now at the Harvard School of Education, notes wryly, ''They (have) asked school authorities to be reasonable in making searches and then given them a hunting license to decide what is reasonable.''

I imagine that this case will make little difference in the everyday running of the schools. Many schools already operate like communities built on mutual respect; others have the atmosphere of a 19th-century workhouse. But it should be noted tha the Supreme Court didn't make a decision in the literal sense of that word. The Supreme Court hasn't resolved our conflicts about safety and privacy or about the relationship of students to the schools. It has merely reflected and perhaps heightened our ambivalence.