After this:

HSERIN 5000, POR,[WAIT("OK")]

and before that:

POR:
if myarray[0]="0"then

you need to fill the array as Skimask stated.

Ioannis