How reveive error message?
Re: How reveive error message?
well but that is set of compiler messages
this program actually cannot receive error message
right ?
this program actually cannot receive error message
right ?
Re: How reveive error message?
or
can i use buffer = GetCommandLine ()
can i use buffer = GetCommandLine ()
Re: How reveive error message?
Hi aurelVZAB
My little program will receive error messages if the string path includes path to compiler + space+path to a .bas file
example
If there is an error in the .bas file it will show, otherwise a success message will show.
I get no warnings here running the code (Win 10, fb 1.09.0 and fb 1.10.0)
My little program will receive error messages if the string path includes path to compiler + space+path to a .bas file
example
Code: Select all
#Include Once "windows.bi"
Dim Shared As zString * 1024 path="C:\Users\Computer\Desktop\fb\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\fbc64.exe" 'compiler
path+=" "
path+="C:\Users\Computer\Desktop\fb\code\allbas\argand.bas" 'source code
Declare Function fb_Set_Font (Font As String,Size As Integer,Bold As Integer=0,Italic As Integer=0,Underline As Integer=0,StrikeThru As Integer=0) As HFONT
Declare Function pipeout(s As String) As String
Declare Function main As Long
End main
Function WndProc(hWnd As HWND, msg As UINT, wParam As WPARAM, lParam As LPARAM) As LRESULT
Static As hwnd ebox,btn
Select Case msg
Case WM_CREATE
btn=CreateWindowEx(NULL,"button", "compiler", WS_VISIBLE Or WS_CHILD , 0,20,60,40, hwnd, Cast(Any Ptr,1), NULL, NULL)
ebox= CreateWindowEx(NULL,"edit", "", WS_VISIBLE Or WS_CHILD Or WS_VSCROLL Or WS_HSCROLL Or WS_Border Or ES_MULTILINE Or ES_AUTOVSCROLL , 0,350, 750, 200, hwnd,0, NULL, NULL)
Dim As HFONT f1=fb_Set_Font("Courier new",10,,true),f2=fb_Set_Font("times new roman",10,,false)
SendMessage(ebox,WM_SETFONT,Cast(WPARAM,f1),0)
SendMessage(btn ,WM_SETFONT,Cast(WPARAM,f2),0)
Case WM_COMMAND
If Loword(wParam) =1 Then
Var t=Timer
var m=pipeout(path)
if instr(m," error ")=0 then m+="Success, compiled in "+str(timer-t)+" seconds"
setwindowtext(ebox,m)
End If
Case WM_CLOSE
PostQuitMessage(NULL)
End Select
Return DefWindowProc(hWnd, msg, wParam, lParam)
End Function
Function MAIN As Long
' Create window class:
Dim As WNDCLASS wcls
Function=0
With wcls
.style = CS_HREDRAW Or CS_VREDRAW
.lpfnWndProc = @WndProc
.hInstance = GetModuleHandle(NULL)
.hIcon = LoadIcon(NULL, IDI_APPLICATION)
.hCursor = LoadCursor(NULL, IDC_ARROW)
.hbrBackground = GetStockObject(WHITE_BRUSH)
.lpszMenuName = NULL
.lpszClassName = Strptr("WindowClass")
End With
If RegisterClass(@wcls) = FALSE Then
MessageBox(NULL, "RegisterClass('WindowClass') FAIL!", "Error!", MB_OK Or MB_ICONERROR)
End
End If
'mainwindow
CreateWindowEx(NULL, "WindowClass", "Some editor", WS_OVERLAPPEDWINDOW Or WS_VISIBLE, 100, 100, 800, 600, NULL, NULL, NULL, NULL)
Dim As MSG uMsg
While GetMessage(@uMsg, NULL, NULL, NULL) <> FALSE
TranslateMessage(@uMsg)
DispatchMessage(@uMsg)
Wend
End Function
Function fb_Set_Font (Font As String,Size As Integer,Bold As Integer,Italic As Integer,Underline As Integer,StrikeThru As Integer) As HFONT
Dim As HDC hDC=GetDC(HWND_DESKTOP)
Dim As Integer CyPixels=GetDeviceCaps(hDC,LOGPIXELSY)
ReleaseDC(HWND_DESKTOP,hDC)
Return CreateFont(0-(Size*CyPixels)/72,0,0,0,Bold,Italic,Underline,StrikeThru,ANSI_CHARSET _
,OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FF_DONTCARE,Font)
End Function
Function pipeout( s As String) As String
Var f=Freefile
Dim As String tmp
Open Pipe s For Input As #f
s=""
Do Until Eof(f)
Line Input #f,tmp
s+=tmp+Chr(13,10)
Loop
Close #f
Return s
End Function
I get no warnings here running the code (Win 10, fb 1.09.0 and fb 1.10.0)
Re: How reveive error message?
very good dodicat
I have one question, why the following code ?
Declare Function main As Long
End main
I would expect that main would not get executed yet it is, btw in your present example end is not needed, at least I think so
I have one question, why the following code ?
Declare Function main As Long
End main
I would expect that main would not get executed yet it is, btw in your present example end is not needed, at least I think so
Re: How reveive error message?
srvaldez
Since main is a function returning 0, end main is OK.
It just returns 0 to the system after running main
But just main would do.
Since main is a function returning 0, end main is OK.
It just returns 0 to the system after running main
But just main would do.
Re: How reveive error message?
dodicat, I rarely use End so I forgot that End can have an integer argument
Re: How reveive error message?
OK dodicat
I will try again
I will try again
Re: How reveive error message?
dodicat
i tested with proper paths
and nothing ..simply not work
i tested with proper paths
and nothing ..simply not work
Re: How reveive error message?
Hi aurelVZAB
I put
aurelVZAB
near the top of my argand.bas file
(A deliberate error)
here was my compiler output
C:\Users\Computer\Desktop\fb\code\allbas\argand.bas(3) error 42: Variable not declared, aurelVZAB in 'aurelVZAB'
With no deliberate error I get
Success, compiled in 0.350426900000457 seconds.
If you are using another compiler then the
if instr(m," error ")=0 then m+="Success, compiled in "+str(timer-t)+" seconds"
might not apply.
I tested with freepascal, it was OK.
For some reason C++ sends errors to the console and not the window, I will have to investigate.
I put
aurelVZAB
near the top of my argand.bas file
(A deliberate error)
here was my compiler output
C:\Users\Computer\Desktop\fb\code\allbas\argand.bas(3) error 42: Variable not declared, aurelVZAB in 'aurelVZAB'
With no deliberate error I get
Success, compiled in 0.350426900000457 seconds.
If you are using another compiler then the
if instr(m," error ")=0 then m+="Success, compiled in "+str(timer-t)+" seconds"
might not apply.
I tested with freepascal, it was OK.
For some reason C++ sends errors to the console and not the window, I will have to investigate.
Re: How reveive error message?
dodicat
can we agree in one thing?
I need to capture message from fbc.exe ....not from gcc
do i have right ?
can we agree in one thing?
I need to capture message from fbc.exe ....not from gcc
do i have right ?
Re: How reveive error message?
You could try this method, using a temp file, srvaldez suggested this back a bit.
If you have no success try
shell path+ " 2>tempout.txt"
in line 31.
Tested freebasic, freepascal, G++
With G++ I have to use shell path+ " 2>tempout.txt"
Code: Select all
#Include Once "windows.bi"
'freeconsole
Dim Shared As zString *1024 path="C:\Users\Computer\Desktop\fb\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\fbc64.exe" 'compiler
path+=" "
path+="C:\Users\Computer\Desktop\fb\code\allbas\argand.bas" 'source code
Declare Function fb_Set_Font (Font As String,Size As Integer,Bold As Integer=0,Italic As Integer=0,Underline As Integer=0,StrikeThru As Integer=0) As HFONT
Declare Function Load(s As String) As String
Declare Function main As Long
End main
Function WndProc(hWnd As HWND, msg As UINT, wParam As WPARAM, lParam As LPARAM) As LRESULT
Static As hwnd ebox,btn
Select Case msg
Case WM_CREATE
btn=CreateWindowEx(NULL,"button", "compiler", WS_VISIBLE Or WS_CHILD , 0,20,60,40, hwnd, Cast(Any Ptr,1), NULL, NULL)
ebox= CreateWindowEx(NULL,"edit", "", WS_VISIBLE Or WS_CHILD Or WS_VSCROLL Or WS_HSCROLL Or WS_Border Or ES_MULTILINE Or ES_AUTOVSCROLL , 0,350, 750, 200, hwnd,0, NULL, NULL)
Dim As HFONT f1=fb_Set_Font("Courier new",10,,true),f2=fb_Set_Font("times new roman",10,,false)
SendMessage(ebox,WM_SETFONT,Cast(WPARAM,f1),0)
SendMessage(btn ,WM_SETFONT,Cast(WPARAM,f2),0)
Case WM_COMMAND
If Loword(wParam) =1 Then
Var t=Timer
shell path+ " >tempout.txt"
var m=Load("tempout.txt")
kill "tempout.txt"
if instr(m," error ")=0 then m+="Success, compiled in "+str(timer-t)+" seconds"
setwindowtext(ebox,m)
End If
Case WM_CLOSE
PostQuitMessage(NULL)
End Select
Return DefWindowProc(hWnd, msg, wParam, lParam)
End Function
Function MAIN As Long
' Create window class:
dim WND_CLASS_NAME as string
WND_CLASS_NAME ="WindowClass"
Dim As WNDCLASS wcls
Function=0
With wcls
.style = CS_HREDRAW Or CS_VREDRAW
.lpfnWndProc = @WndProc
.hInstance = GetModuleHandle(NULL)
.hIcon = LoadIcon(NULL, IDI_APPLICATION)
.hCursor = LoadCursor(NULL, IDC_ARROW)
.hbrBackground = GetStockObject(WHITE_BRUSH)
.lpszMenuName = NULL
.lpszClassName = strptr (WND_CLASS_NAME)
End With
If RegisterClass(@wcls) = FALSE Then
MessageBox(NULL, "RegisterClass('WindowClass') FAIL!", "Error!", MB_OK Or MB_ICONERROR)
End
End If
'mainwindow
CreateWindowEx(NULL, "WindowClass", "Some editor", WS_OVERLAPPEDWINDOW Or WS_VISIBLE, 100, 100, 800, 600, NULL, NULL, NULL, NULL)
Dim As MSG uMsg
While GetMessage(@uMsg, NULL, NULL, NULL) <> FALSE
TranslateMessage(@uMsg)
DispatchMessage(@uMsg)
Wend
End Function
Function fb_Set_Font (Font As String,Size As Integer,Bold As Integer,Italic As Integer,Underline As Integer,StrikeThru As Integer) As HFONT
Dim As HDC hDC=GetDC(HWND_DESKTOP)
Dim As Integer CyPixels=GetDeviceCaps(hDC,LOGPIXELSY)
ReleaseDC(HWND_DESKTOP,hDC)
Return CreateFont(0-(Size*CyPixels)/72,0,0,0,Bold,Italic,Underline,StrikeThru,ANSI_CHARSET _
,OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FF_DONTCARE,Font)
End Function
Function Load( fname As String) As String
Var f=Freefile
Dim As String tmp,s
Open fname For Input As #f
Do Until Eof(f)
Line Input #f,tmp
s+=tmp+Chr(13,10)
Loop
Close #f
Return s
End Function
shell path+ " 2>tempout.txt"
in line 31.
Tested freebasic, freepascal, G++
With G++ I have to use shell path+ " 2>tempout.txt"
Re: How reveive error message?
Unfortunatlly i can't find in Jose CSED_FB ..
or Vanya IDE
or XusinBoy IDE
or KuanHsu fbPoseidon
how they capture fbc messages ...
i found something about CreateProces ..etc ..etc..
or Vanya IDE
or XusinBoy IDE
or KuanHsu fbPoseidon
how they capture fbc messages ...
i found something about CreateProces ..etc ..etc..
Re: How reveive error message?
I found something in Vanya IUP IDE
and looking to me very complicated :
and looking to me very complicated :
Code: Select all
If CreatePipe(@hChildRead, @hChildWrite, @sa, NULL) Then
If SetHandleInformation(hChildRead, HANDLE_FLAG_INHERIT, NULL) Then
Dim pi As PROCESS_INFORMATION
Dim si As STARTUPINFO
si.cb = SizeOf(STARTUPINFO)
si.hStdError = hChildWrite
si.hStdOutput = hChildWrite
si.dwFlags = STARTF_USESTDHANDLES
If CreateProcess( pszCMD ,pszParamCMD,NULL,NULL,TRUE,CREATE_NO_WINDOW,NULL,NULL,@si,@pi) Then
CloseHandle(hChildWrite)
Do
If ReadFile(hChildRead, @szBuffer, 1000, @iReadBytes, NULL) Then
*pszSavedInfo &= Left(szBuffer , iReadBytes)
Else
Exit Do
EndIf
Loop
CloseHandle(hChildRead)
CloseHandle( pi.hProcess )
CloseHandle( pi.hThread )
EndIf
EndIf