Alternatively, get the formID string of the cell and compare the mod index byte with "00".
That is a simpler way, provided he's looking for one specific cell (or a small number), but not for a general check of whether the player is in Anvil (or another city).
In Enhanced Economy I have an array of names that I check similar to how I posted above (except that instead of checking for "Anvil", it loops through my name array until it finds a match), in order to look up the right index in another array that defines the local prices for that city (and some other stuff). This works for any correctly named cell in a city, even mod-added cells - and even for mod-added cities like Rimmen.
OK, now I'm confused. I thought that GetInCell effectively worked exactly the way TheNiceOne's code emulates. The string "Anvil" is not being compiled into anything, it's a literal value to be compare to the start of the current cell name. It doesn't matter if there is no Anvil, because the only source of that string is the script itself, so the lack of Oblivion.esm is irrelevant.
What I'm not sure of is how GetInCell or GetParentCell give you anything useful in a town. The wiki says they work in interior and not exterior cells, and IIRC a town's worldspace is exterior but they still appear to work provided the dummy (interior?) cell exists. They even work with Open Cities where the cities are part of the Tamriel worldspace. It appears that the interior/exterior restriction may be an exaggeration of the facts.
Well, GetParentCell has no such restriction as far as I can see. As for for GetInCell, it doesn't say that the player must be in an interior cell, but that it must be used with a valid interior cell name (or actually Editor ID). And "Anvil"
is a valid interior cell editor ID (Just check the CS).
It's also unclear why the dummy cells need to be defined, but that may be from existence checks in the script compiler. In that case, the lack of Oblivion.esm is relevant as the source of the dummy definition to get you past the syntax check, but that's only needed when you build the mod and not when you run it.
I'm not sure exactly what type GetInCell's parameter is supposed to be, but it is clear that it requires it to be a valid Editor ID and not merely a string, in order to compile. So to me it looks like GetInCell requires a reference to an interior cell as parameter - which means that it effectively requires Oblivion.esm as master if you want to check for cells in Oblivion.esm.
But the way I suggested goes around this by checking for string names instead.