Ahh, that should work.
You could perhaps wrap that code up into an enumerator class if you wanted.
Once you have a unit index (unitIndex = unit.unitId), you can convert it to a unit pointer provided you know the base address of the unit array. If HFL provides that, then sure. This is normally simple code like this:
unitPtr = &unitArray[unitIndex];
However, the unit array might not be a typed properly (I'm not sure), and so indexing it might not provide the correct offset. In which case you can do the indexing manually. You'll also need a bit of casting. To use byte level offsets you should cast to a byte sized data type, such as char. You'll probably need to cast back to the type of your unit pointer, depending on what it is. If you use char*, then you can probably avoid that cast. I'll just fill in "UnitType*" for that part of the cast since it will depend on your pointer declaration:
unitPtr = (UnitType*)((char*)unitArray + unitIndex * 120);
Now to access the fields off the unitPtr, you'll need a bit more casting and offsets. I'll favour extra casts for clarity of offsets, although you can probably code this a little more directly if you play with the offsets to match the size of the casted type. I find that a bit hard to read though, so here's the doubly casted way:
numTruckLoads = *(int*)((char*)unitPtr + 0x58);
That should get you the value you're looking for.