I dont know why the second code I posted is not completed. I think there are a bug in " [ code ] [ / code ]"

The second code

[pascal]
program teste;

{$APPTYPE CONSOLE}

uses
sdl,
sdlutils,
sdl_image;


const
SCREEN_WIDTH = 640;
SCREEN_HEIGHT = 480;
SCREEN_BPP = 32;

var
screen,image: PSDL_Surface;
event: TSDL_Event;
thread: PSDL_Thread;
quit: boolean = false;



procedure apply_surface(x, y: integer; source,destination: PSDL_Surface);
var
offset: SDL_Rect;

begin
//Get offsets
offset.x := x;
offset.y := y;

//Blit
SDL_BlitSurface( source, nil, destination, @offset );
end;


function init: boolean;
begin
//Initialize all SDL subsystems
if( SDL_Init( SDL_INIT_EVERYTHING ) = -1 ) then
begin
result:= false;
exit;
end;

//Set up the screen
screen := SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE );

//If there was in error in setting up the screen
if( screen = nil ) then
begin
result:= false;
exit;
end;

//Set the window caption
SDL_WM_SetCaption( 'Thread test', nil );

//If everything initialized fine
result:= true;
end;


function load_files: boolean;
begin
//Load the image
image := load_image('image.png',true);

//If there was an error in loading the image
if( image = niL ) then
begin
result:= false;
exit;
end;

//If everything loaded fine
result:= true;
end;

procedure clean_up;
begin
//Stop the thread
SDL_KillThread( thread );

//Free the surface
SDL_FreeSurface( image );

//Quit SDL
SDL_Quit();
end;

function my_thread(): integer;
begin
//While the program is not over
while( quit = false ) do
begin
//Do the caption animation
SDL_WM_SetCaption( 'Thread is running', nil );
SDL_Delay( 250 );

SDL_WM_SetCaption( 'Thread is running.', nil );
SDL_Delay( 250 );

SDL_WM_SetCaption( 'Thread is running..', nil );
SDL_Delay( 250 );

SDL_WM_SetCaption( 'Thread is running...', nil );
SDL_Delay( 250 );
end;

result:= 0;
end;


begin
//Initialize
if (init = false ) then
begin
exit;
end;

//Load the files
if( load_files = false ) then
begin
exit;
end;

//Create and run the thread
thread := SDL_CreateThread(@my_thread, nil );

//Apply the image to the screen
apply_surface( 0, 0, image, screen);

//Update the screen
if( SDL_Flip( screen ) = -1 ) then
begin
exit;
end;


while (quit = false) do
begin
while (SDL_PollEvent(@event) > 0) do
begin
case event.type_ of
SDL_QUITEV:
quit:= true;
end;
end;
clean_up;
end;

end.
[/pascal]