There is hope yet for a gambling man in the Islamic republic.

True, all the casinos in Iran have been closed since last fall, when Shah Mohammad Reza Pahlavi ordered them boarded up in a futile attempt to assuage Moslem opponents and to keep his throne.

But the new puritannical climate hasn't stopped Hong Kong tycoon Stanley Ho from trying to salvage what he can from a $50 million race track and "country club" complex that opened last June.

Today, the Farahabad racetrack - still rather embarassingly named after the shah's wife, Empress Farah - held its first meet of the season, and "le tout Tehran," or what's left of it, was there. But then so were some members of the common folk. A good time was had by all.

The feature race of the day was - you guessed it - the Islamic Republic Cup, for Turkoman horses at least four years old over a mile course and paying about $2,500 in prize money. Nothing like the old days when the feature Aryamehr Cup (named after the shah's title of "light of the Aryans") paid $150,000.

But never mind. The windows were opened as usual with win, pace and exacta betting for as little as a 100-rial ($1.42) stake. As a sign of the changing times, there were more windows available for the smaller denomination wagers and those for the larger ones had been done away with entirely.

"We're catering to the masses," said Ho, and a millionaire owner of casinos and other interests in Macao and Hong Kong. There's no more exclusivity. People don't even need to wear coats and ties any more in the member's stand."

As for the gambling, prohibited under Islam, it was explained that betting on horse races isn't really gambling at all, according to Moslem religious law. Horse races, like camel races, wrestling matches or shooting contests, are tests of skill and betting on them is permitted.

What is not allowed is gambling on games of chance. Because, according to Islam, if one puts money on the throw of the dice, the draw of the cards or the spin of the roulette wheel, one is really betting on God, and that is just not done.

What most of the Iranian horse race aficionados who turned up at Farahabad today did not know was that the main financial incentive for Ho and his Chinese partners was to have been a vast casino on an upper floor of the complex. It never opened. Work on it was still under way when the shah ordered casinos closed, and the advent of the Islamic republic forced Ho and company to abandon that part of the project.

One of the most modern tracks anywhere, the race course is nestled between stark mountains near a suburb east of Teheran.

At the entrance militiamen from the local revolutionary committee, stand guard with automatic rifles.

Inside women dressed in the latest Paris fashions mingle with those covered by the traditional head-to-toe veil called the "chador." On the third floor, once the exclusive preserve of those who paid $1,000 to $3,000 membership fees, are a luxurious loung, dining room and betting facilities now open to anyone who pays a $7 admission charge. The chic mix with the unshaven, Dior clashes with the army jacket.

"Last year we didn't let people in chadors come up here," said an immaculately dressed and coifefed Iranian hostess in her 20s. "But now we can't tell them anything," she said, barely disguising her distaste for it all.

"I liked it better last year," she allowed, adding that she didn't really care too much for the Islamic republic or Ayatollah Rulhollah Khomeini.

On a lower floor, Haj Rasul Ghobadi-Samain, 49, a grizzled shopkeeper from the northwestern town of Ardebil, said he was enjoying himself immensely, but he hadn't been betting because he didn't understand the rules.

"If there had been any religious objection, I wouldn't have come," he said. But asked if he considered himself a hard-line Moslem, he replied, "No. The only real hard-line Moslem in Iran is Ayatollah Khomeini."

Another race fan present was Bahram Bakhtair, a sophisticated British educated industrial machinery dealer who is a cousin of Shahpour Bakhtair,the shah's last prime minister who vanished during the insurrection that brought the Islamic republic to power.

He said he was sure his 63-year -old cousin was "safe," but that he didn't know where he might be hiding.

The younger Bakhtair said he plans to race his own thoroughbreds at Farahabad in a few more weeks when, if all goes well, the prize money will have improved.

"I'm from the Bakhtair tribe and we love horses," he said. "In England I left so much money at the track it's not funny."

Another Bakhtair clansman was present. He, however, did not see his future as lying in Iran.

"You can't do business here any more, and there's nothing else to do," he said. "You can't drink or go anywhere. The only amusement is this racetrack."

He said he planned to go to the United States before the next revolution, which he expects to occur in a couple of months.

In an interview before the races, Ho, the Hong Kong entrepreneur, said that among the conditions negotiated with Iranian officials and religious leaders to reopen the racetrack was that he not employ "too many expatriates."

He said he was maintaining a "skeleton crew" of foreign staff among his 280 employes to run the sophisticated computerized parimutuel system, electronic timing devices and photo-finish equipment.

To forestall any religious objections against betting-which Ho insisted be called wagering for reasons that were not clear-spectators now become members of a racing club for a day upon paying their entrance fees. Thus, the wagering is sort of family affair between the club and its members.

Asked if he thought revolutionary militiamen might take it into their heads to close the track despite the authorities' approval, Ho said, "Let us see. You know, I'm in the gambling business. I've been a gambling man all my life."