The buildingPos function does not work like that (official comref is wrong). Let me dig out an example for you...
Edit #1: Here:
_unit move (_building buildingPos _rpos)
Taken out of a script I once wrote for handling a bit similar situation. It's pretty easy for you to figure out how to use it in your own script, just make sure you understand that AI units are not good inside buildings, they will probably go to the "basement" very often, and go through walls every now and then.
Edit #2: OK I give you also this little function which I wrote to find out how many indexed positions there are inside a building:
// ******************************************************************************************
// buildingPosCount.sqf
// Returns number of indexed positions in a building.
// These positions can be used with the buildingPos function.
// When using indexed positions from a script,
// take in notice that 1st position has index number 0,
// 2nd has index number 1 and so on. So if a building
// has 8 positions, you can use them as 0...7 from a script
// with the buildingPos function.
// USAGE:
// init: buildingPosCount = preprocessFile "buildingPosCount.sqf"
// calling: <building> call buildingPosCount
// returns: <integer>
// example: _posses = nearestBuilding player call buildingPosCount
// Baddo 2005
// You can contact me through www.ofpec.com
// ******************************************************************************************
private ["_i"];
_i = 0;
while { format [{%1}, _this buildingPos _i] != "[0,0,0]" } do
{
_i = _i + 1;
};
_i
Read the comments in the start of the function carefully.
If I recall correctly, the nearestBuilding function only returns buildings that have these indexed positions inside them, so if you want to write a truly dynamic script which looks for buildings with indexed positions and order AI units into them, use nearestBuilding and buildingPosCount for the job to first figure out a building and then how many indexed positions there are in it.