mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 07:26:24 +02:00
+ implemented win16 stderr via messageboxes similar to the way it is implemented for win32/win64 gui apps
git-svn-id: trunk@31828 -
This commit is contained in:
parent
938c797a0d
commit
1c3a0864e8
@ -256,6 +256,80 @@ begin
|
|||||||
randseed:=hl*$10000+ regs.CX;}
|
randseed:=hl*$10000+ regs.CX;}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{****************************************************************************
|
||||||
|
Error Message writing using messageboxes
|
||||||
|
****************************************************************************}
|
||||||
|
|
||||||
|
const
|
||||||
|
ErrorBufferLength = 1024;
|
||||||
|
ErrorMessageBoxFlags = MB_OK or MB_ICONHAND or MB_TASKMODAL;
|
||||||
|
var
|
||||||
|
ErrorBuf : array[0..ErrorBufferLength] of char;
|
||||||
|
ErrorLen : SizeInt;
|
||||||
|
|
||||||
|
procedure ErrorWrite(Var F: TextRec);
|
||||||
|
{
|
||||||
|
An error message should always end with #13#10#13#10
|
||||||
|
}
|
||||||
|
var
|
||||||
|
i : SizeInt;
|
||||||
|
Begin
|
||||||
|
while F.BufPos>0 do
|
||||||
|
begin
|
||||||
|
begin
|
||||||
|
if F.BufPos+ErrorLen>ErrorBufferLength then
|
||||||
|
i:=ErrorBufferLength-ErrorLen
|
||||||
|
else
|
||||||
|
i:=F.BufPos;
|
||||||
|
Move(F.BufPtr^,ErrorBuf[ErrorLen],i);
|
||||||
|
inc(ErrorLen,i);
|
||||||
|
ErrorBuf[ErrorLen]:=#0;
|
||||||
|
end;
|
||||||
|
if ErrorLen=ErrorBufferLength then
|
||||||
|
begin
|
||||||
|
if not NoErrMsg then
|
||||||
|
{$IFDEF FPC_X86_DATA_NEAR}
|
||||||
|
MessageBox(0,Ptr(Seg(ErrorBuf),Ofs(ErrorBuf)),nil,ErrorMessageBoxFlags);
|
||||||
|
{$ELSE FPC_X86_DATA_NEAR}
|
||||||
|
MessageBox(0,@ErrorBuf,nil,ErrorMessageBoxFlags);
|
||||||
|
{$ENDIF FPC_X86_DATA_NEAR}
|
||||||
|
ErrorLen:=0;
|
||||||
|
end;
|
||||||
|
Dec(F.BufPos,i);
|
||||||
|
end;
|
||||||
|
End;
|
||||||
|
|
||||||
|
|
||||||
|
procedure ErrorClose(Var F: TextRec);
|
||||||
|
begin
|
||||||
|
if ErrorLen>0 then
|
||||||
|
begin
|
||||||
|
{$IFDEF FPC_X86_DATA_NEAR}
|
||||||
|
MessageBox(0,Ptr(Seg(ErrorBuf),Ofs(ErrorBuf)),nil,ErrorMessageBoxFlags);
|
||||||
|
{$ELSE FPC_X86_DATA_NEAR}
|
||||||
|
MessageBox(0,@ErrorBuf,nil,ErrorMessageBoxFlags);
|
||||||
|
{$ENDIF FPC_X86_DATA_NEAR}
|
||||||
|
ErrorLen:=0;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure ErrorOpen(Var F: TextRec);
|
||||||
|
Begin
|
||||||
|
TextRec(F).InOutFunc:=@ErrorWrite;
|
||||||
|
TextRec(F).FlushFunc:=@ErrorWrite;
|
||||||
|
TextRec(F).CloseFunc:=@ErrorClose;
|
||||||
|
ErrorLen:=0;
|
||||||
|
End;
|
||||||
|
|
||||||
|
|
||||||
|
procedure AssignError(Var T: Text);
|
||||||
|
begin
|
||||||
|
Assign(T,'');
|
||||||
|
TextRec(T).OpenFunc:=@ErrorOpen;
|
||||||
|
Rewrite(T);
|
||||||
|
end;
|
||||||
|
|
||||||
{*****************************************************************************
|
{*****************************************************************************
|
||||||
System Dependent Exit code
|
System Dependent Exit code
|
||||||
*****************************************************************************}
|
*****************************************************************************}
|
||||||
@ -278,6 +352,11 @@ begin
|
|||||||
if not CheckNullArea then
|
if not CheckNullArea then
|
||||||
writeln(stderr, 'Nil pointer assignment');
|
writeln(stderr, 'Nil pointer assignment');
|
||||||
{$endif FPC_MM_TINY}*)
|
{$endif FPC_MM_TINY}*)
|
||||||
|
Close(stderr);
|
||||||
|
Close(stdout);
|
||||||
|
Close(erroutput);
|
||||||
|
Close(Input);
|
||||||
|
Close(Output);
|
||||||
asm
|
asm
|
||||||
mov al, byte [exitcode]
|
mov al, byte [exitcode]
|
||||||
mov ah, 4Ch
|
mov ah, 4Ch
|
||||||
@ -321,11 +400,11 @@ end;
|
|||||||
|
|
||||||
procedure SysInitStdIO;
|
procedure SysInitStdIO;
|
||||||
begin
|
begin
|
||||||
OpenStdIO(Input,fmInput,StdInputHandle);
|
AssignError(stderr);
|
||||||
OpenStdIO(Output,fmOutput,StdOutputHandle);
|
AssignError(StdOut);
|
||||||
OpenStdIO(ErrOutput,fmOutput,StdErrorHandle);
|
Assign(Output,'');
|
||||||
OpenStdIO(StdOut,fmOutput,StdOutputHandle);
|
Assign(Input,'');
|
||||||
OpenStdIO(StdErr,fmOutput,StdErrorHandle);
|
Assign(ErrOutput,'');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetProcessID: SizeUInt;
|
function GetProcessID: SizeUInt;
|
||||||
@ -360,6 +439,8 @@ begin
|
|||||||
InitWin16Heap;
|
InitWin16Heap;
|
||||||
SysInitExceptions;
|
SysInitExceptions;
|
||||||
initunicodestringmanager;
|
initunicodestringmanager;
|
||||||
|
{ Setup stdin, stdout and stderr }
|
||||||
|
SysInitStdIO;
|
||||||
{ Use LFNSupport LFN }
|
{ Use LFNSupport LFN }
|
||||||
LFNSupport:=CheckLFN;
|
LFNSupport:=CheckLFN;
|
||||||
if LFNSupport then
|
if LFNSupport then
|
||||||
|
Loading…
Reference in New Issue
Block a user