This is completely terrible for many reasons.
First, you're putting things together into a string, sending a copy of that string back from a function, then taking the string apart to get the objects again. That is a lot of useless string operations that are slow.
Second, you're doing like a billion ray casts but you STILL aren't going to find bricks that are catty-corner to the one you're searching from.
Third, there IS a built in function for this sort of thing.
initContainerBoxSearch(%position, %boxSize, %mask);
while (%searchObj= containerSearchNext())
{
//do stuff to %searchObj
}