I'm trying to capture a screen image and save it as a bitmap in the game folder, but it doesn't work. The goal is to create a bitmap called "result.bmp" Here is my code:

BMAP* screen_shot_map = "#400x300x16"; //create temporary bitmap

function grab_screen()

{bmap_for_screen(screen_shot_map,1,0); //get screen image
if (key_p == 1)
bmap_save(screen_shot_map,"result.bmp"); //place screen image into "result.bmp" after pressing key_p
}

function main()

{video_mode = 7;
level_load("BrooklynApartments.wmb");
wait(3);
grab_screen();
}