How to check if a array has somthing in it

hi guys, im trying to make a gui box display the info in an array however i get spammed error messages alot becuase its trying to display whats in the array before there is anything >.< heres the code i tried. Thanks

heres the error: ArgumentOutOfRangeExecption: Index is less than 0 or more than or equal to the list count.

static var QSlot = new Array ();

if(Input.GetKeyDown("j")) {
	print(QSlot);
	}


function AddQuest () {
}

function OnGUI () {
if(QSlot[0]) {
GUI.Box(Rect(100,100,100,100), QSlot[0]);
	}
}

And yes i know the Input is outside of update, lol

Also tried this, but nothing :frowning:

ar Slot1  = "";
var Slot2 = "";
var T : Vector2 = Vector2 (100,100);
var T1 : Vector2 = Vector2 (100,100);

var SlotH = "";

static var QSlot = new Array ();



function Start () {
	QSlot.Push("Quest Tracker");
	}
function AddQuest () {
}

function Update () {
Slot1 = QSlot[0];
if(QSlot[1]){
Slot2 = QSlot[1];
if(Input.GetKeyDown("j")) {
	print(QSlot);
		}
	}	
}

function OnGUI () {
if(Slot2 != SlotH  Slot1 != SlotH  QSlot[1]) {
GUI.Box(Rect(T.x,T.y,T1.x,T1.y), Slot1);
	}
}
function OnGUI () 
{
	if(QSlot.Length > 0  QSlot[0]) 
	{
		GUI.Box(Rect(100,100,100,100), QSlot[0]);
	}
}

thank you once again fizixman <3