; Eax - Error to show
ErrorEndProgram:
PUSH DWORD MB_OK | MB_ICONERROR
PUSH DWORD errorcaption
SHL eax, 2
mov ebx, [Errormsgoffset+eax]
PUSH DWORD ebx
PUSH DWORD 0 ;HWND NULL
CALL [MessageBoxA]
JMP NEAR EndProgram

.data

Errormsgoffset DD errormsg0, errormsg1, errormsg2, errormsg3, errormsg4, errormsg5

; Error list
; 0 - Memory allocation
; 1 - File Reading
; 2 - File Writing
; 3 - File pointer mobing
; 4 - Opening file
; 5 - Creating text window
; 6 - Closing file

errormsg0 DB 'Error allocating memory block', 13, 10, 'Terminating Program', 13, 10, 0
errormsg1 DB 'Error when reading data from file', 13, 10, 'Terminating Program', 13, 10, 0
errormsg2 DB 'Error when writing data to file', 13, 10, 'Terminating Program', 13, 10, 0
errormsg3 DB 'Error when moving file pointer', 13, 10, 'Terminating Program', 13, 10, 0
errormsg4 DB 'Error opening file', 13, 10, 'Terminating Program', 13, 10, 0
errormsg5 DB 'Error creating text output window', 13, 10, 'Terminating Program', 13, 10, 0
errormsg6 DB 'Error closing file', 13, 10, 'Terminating Program', 13, 10, 0

errorcaption DB 'Ultrabasic Error', 0

.code