Wearing hat and gat and partial to highly stylized chat, Mike Hammer at first seems a hard-boiled detective of the old school.

But although "Margin for Murder," a made-for-TV movie airing tonight at 9 on Channel 9, makes every attempt to keep him in class, Hammer quickly goes truant. The venerable Mickey Spillane character is not now nor has he ever been one for finesse, cleverness or charm, and will defeat by sheer force of personality any script that tries to make him into Sam Spade or Philip Marlowe.

"Margin" is a simple tale of vengeance. Hammer, in the guise of Kevin Dodson ("Shannon"; and before that, Crocker on "Kojak"), has lost a friend named Joey. Joey has apparently double-crossed some diamond smugglers and paid with his life. Hammer, working for friendship and not for a fee, is thus propelled from morgue to mansion while gunshots ring, sirens wail and beer-can tops pop.

He is a private eye, and the private eye code of conduct has always been specific. A private eye may deal in seamy matters, but with skill and pride; he takes a fee, but not a bribe; he bends the law, but carefully, because he doesn't want to lose his license; and he has a deep-seated, uncharacteristically sentimental reverence for friends or partners and his reputation.

As Sam Spade explains it in the film "The Maltese Falcon":

"When a man's partner is killed, he's supposed to do something about it. It doesn't matter what you thought of him, he was your partner and you're supposed to do something about it."

Hammer says tonight, of the departed Joey:

"When a man has a friend, they go through life together. Good times, bad times, thick and thin. They stick together. Your friend gets killed, you do something about it. Turn it around, and I'm the one gets knocked off. Joey'd be out there trying to do the same thing I'm trying to do."

Perhaps the most endearing aspect of the hard-boiled detective personality is the contrast between this sentimental behavior and an otherwise otherworldly worldliness. In the film "The Big Sleep," Marlowe watches unseen as admirable little Harry Jones takes poison rather than reveal the whereabouts of his tarty girlfriend, Agnes. Marlowe intentionally lets fate play out its hand, but he is nonetheless moved by Harry's valiant death.

Hammer, in this script, says many things that might have been said by his predecessors. "I don't get bought, I don't make deals, and I don't get scared." But he never lets fate play out its hand. He is hot, not cool. He does not go along to get along; he does not tolerate, he hates.

The shades of gray, the fascinating ambivalence, the vulnerability that make Spade and Marlowe memorable and fascinating are not present.

Of all lawyers, Hammer says: "They're lower on the social scale than child molesters." When warned not to fight city hall, he blows up: "I can tear their heads off at the neck. What, do they think they're gods or something? They're garbage. If people'd stop going along with them, they'd crawl back in their holes. I hate them all."

This is Dirty Harry talking, not Spade or Marlowe or even Kojak. Hammer is not hard-boiled, but hysterical and probably psychotic. Even death cheats his special needs: Delivered the corpse of Joey's presumed murderer, he is bitterly disappointed to have missed the chance to kill him himself; later, when he finds the real killer, he spares him even more brutally: "Killing you would've been too easy. Now you'll just die little by little."

Spillane had nothing to do with this television movie, but the writers have done right by his Mike Hammer character. This story replicates precisely the blank, mechanical tone of the Hammer books, and in assigning to women the status of end tables (they are most often seen holding glasses or supporting a telephone) it is also faithful.

Hammer's secretary, Velda, played by Cindy Pickett, is quite obviously nuts about him. She doesn't mind the other women, because that's just Mike. What seems to fascinate her is his .45-caliber handgun. She emulates him as best she can with a purse pistol. Psychiatry must have something to say about that, but it was not in the book I looked up.

All in all, "Margin for Murder" provides quite a fair glimpse of Spillane's Hammer, who has helped his author to sales of 70 million books worldwide. If there is not quite enough needless violence in tonight's program, blame that on the "outside forces" affecting television today.