i can't get it to work

here's my code:

Code:
var max_panels = 12;
var panel_handle[12]; //array to store the panel pointers
panel* coord_ptr;
string file_name = "t";
string file_type = ".pcx";
string file;
string file_number;

function random_panel()
{
panel_handle[0] = handle(transform_l01_normal);
panel_handle[1] = handle(transform_l02_normal);
panel_handle[2] = handle(transform_l03_normal);
panel_handle[3] = handle(transform_l04_normal);
panel_handle[4] = handle(transform_l05_normal);
panel_handle[5] = handle(transform_l06_normal);
panel_handle[6] = handle(transform_l07_normal);
panel_handle[7] = handle(transform_l08_normal);
panel_handle[8] = handle(transform_l09_normal);
panel_handle[9] = handle(transform_l10_normal);
panel_handle[10] = handle(transform_l11_normal);
panel_handle[11] = handle(transform_l12_normal);

var i;
var a = 0;

while(a < max_panels)
{
i = int(random(3))+1;
str_cpy(file,file_name);
str_for_num(file_number,i);
str_cat(file,file_number);
str_cat(file,file_type);

coord_ptr = ptr_for_handle(panel_handle[a]);
coord_ptr.bmap = file;
a += 1;
wait(1);
}
}

in another function i have i.e. this line:

transform_l01_normal.visible=on;



i have some bmps (t1.pcx, t2.pcx, t3.pcx, t4.pcx)

as soon as the panel should get visible, the game crashes.
i can't find the error. please help!