Based off what Trinick gave you:
If you're going to be searching for the same uiname a lot, you could save some time by indexing datablocks you've already found:
function getDataBlockFromUIName(%uiName)
{
if($DatablockNameArray[%uiName])
return $DatablockNameArray[%uiName];
for(%i = 0; %i < dataBlockGroup.getCount(); %i++)
{
%o = dataBlockGroup.getObject(%i);
if(%o.UIName $= %uiName)
{
$DatablockNameArray[%uiName] = %o;
return %o;
}
}
}
or similarly, after loading you could loop through every datablock and add the uiname and datablock to the array, then (provided you don't load any weapons afterwards, which you should) you won't need to run the loop at all