GUI Layout. Can I end and begin a horizontal group automatically?

Hey! I'm writing the script for my inventory.

What I'm trying to do is something like this:

function OnGUI()
 {
   GUILayout.BeginArea (Rect (0,0,400,));
     GUILayout.BeginHorizontal();
        if (hatchet > 0){
          GUILayout.Button ("Hatchet");
        }
        if (coins > 0){
          GUILayout.Button ("Coins");
        }
        if (logs > 0){
          GUILayout.Button ("Logs");
        }
        if (kindling > 0){
          GUILayout.Button ("Kindling");
        }
        if (fishingPole > 0){
          GUILayout.Button ("Fishing Pole");
        }
        if (rawSalmon > 0){
          GUILayout.Button ("Raw Salmon");
        }
        if (rawTrout > 0){
          GUILayout.Button ("Raw Trout");
        }
        if (fishingBait > 0){
          GUILayout.Button ("Fishing Bait");
        }
        if (cookedTrout > 0){
          GUILayout.Button ("Cooked Trout");
        }
     GUILayout.EndHorizontal();
   GUILayout.EndArea();
}

This isn't my actual code. The buttons are more complicated and have functionality. But this is the basics of my inventory script. What I want is to have a 5 x 8 inventory where the buttons all align to the top and to the left. I don't want them overlapping. I think this could be achieved by writing script that automatically places:

 GUILayout.EndHorizontal();
 GUILayout.StartHorizontal();

after every 5 items that exist in the inventory (greater than 0). How could I do this?

Thanks very much.

I think it would be a lot easier with arrays:

import UnityEngine.GUILayout;

var inventoryItems : int[];
var inventoryNames : String[];

function OnGUI()
{
    var count = 0;
    BeginArea (Rect (0,0,400,700));
    BeginVertical();
    for (v = 0; v < 8; v++) {
        BeginHorizontal();
        for (h = 0; h < 5; h++) {
            while (count < inventoryItems.Length && inventoryItems[count] == 0) count++;
            if (count < inventoryItems.Length && Button (inventoryNames[count])) {
                // do whatever
            }
            count++;
        }
        EndHorizontal();
    }
    EndVertical();
    EndArea();
}