How reveive error message?
How reveive error message?
Hi to all
i am using windows
so is there any example about
HOW TO RECEIVE error message from fbc compiler from
code editor ?
thnx
i am using windows
so is there any example about
HOW TO RECEIVE error message from fbc compiler from
code editor ?
thnx
Re: How reveive error message?
Compile with option -exx.
Use an editor/ide which keeps the console open so you can read the messages.
OR
You can try this
write errload at the beginning of each sub/function
write errhandle at the end
You can do the same in the main module.
Please note these are run time error messages,
Use an editor/ide which keeps the console open so you can read the messages.
OR
You can try this
write errload at the beginning of each sub/function
write errhandle at the end
You can do the same in the main module.
Code: Select all
'============ERROR ROUTINE=======================
#cmdline "-exx"
#macro errload
Print "Error handler active."
Dim errnum as long
On Error Goto ehandler
#endmacro
#macro errhandle
Goto skipover
ehandler:
Errnum = Err()
Print "ERROR ";Errnum;" ";
Select Case as const Errnum
case 0: Print " ... "
Case 1 :Print "Illegal function call"
Case 2 :Print "File not found signal"
Case 3 :Print "File I/O error"
Case 4 :Print "Out of memory"
Case 5 :Print "Illegal resume"
Case 6 :Print "Out of bounds array access"
Case 7 :Print "Null Pointer Access"
Case 8 :Print "No privileges"
Case 9 :Print "interrupted signal"
Case 10 :Print "illegal instruction signal"
Case 11 :Print "floating point error signal"
Case 12 :Print "segmentation violation signal"
Case 13 :Print "Termination request signal"
Case 14 :Print "abnormal termination signal"
Case 15 :Print "quit request signal"
Case 16 :Print "return without gosub"
Case 17 :Print "end of file"
End Select
Print "Function: " &__function__
#ifdef __FB_LANG__
#if __FB_LANG__ = "qb"
Print "Module: " & *__Ermn
#else
Print "Module: " & *Ermn
#endif
#endif
Print "Line: " & Erl
'OPTIONAL BELOW
'Print "Press a key to exit"
'Sleep
'End
skipover:
#endmacro
'==================END ERROR ROUTINE====================================
Sub dothis
errload
open "nonesuch" for input as #1
close #1
errhandle
End Sub
function dothat() as long
errload
return 2023
errhandle
end function
dothis
print dothat
errload
Dim As Long Pointer o
Print *o
errhandle
sleep
Re: How reveive error message?
thanks dodicat
i mean in first place receive message then show it in a editor ...
let say using multi line edit control
i mean in first place receive message then show it in a editor ...
let say using multi line edit control
Re: How reveive error message?
So what you're really asking is how to run a program as a child process and capture it's output (std out and std err)? Like what IDEs do?
I'd check the source code to FBIDE and see how they do it.
I'd check the source code to FBIDE and see how they do it.
Re: How reveive error message?
yes caseih that one
i would like to add it into my FB editor
and thanks
i would like to add it into my FB editor
and thanks
Re: How reveive error message?
Try that :
Code: Select all
Const TEST_COMMAND = "<path compiler>.exe <path source><source name>.bas"
Open Pipe TEST_COMMAND For Input As #1
Dim As String ln
Do Until EOF(1)
Line Input #1, ln
Print "output=";ln
Loop
Close #1
sleep
Re: How reveive error message?
SARG
thanks
but i need something on win API level
thanks
but i need something on win API level
Re: How reveive error message?
I don't understand : the goal is to receive the ouput from the compiler not to use Win API.....
So what is the exact problem with the proposed solution. Under the hood (on Windows) open pipe uses Win API, open pipe with fbc is just an easy way.
Re: How reveive error message?
the goal is to use win api
because editor is not written with FB then with o2
because editor is not written with FB then with o2
Re: How reveive error message?
The easiest way : write a dll using fbc code and use it in your O2 code otherwise look at createpipe and so on in the Win SDK manual.....
Btw you should have say the reason but I guess at first you don't want to talk about O2
Btw you should have say the reason but I guess at first you don't want to talk about O2
Re: How reveive error message?
Hi aurelVZAB
I got the wrong end of your question, "error message" threw me, you want compiler messages.
Please pop in your own path to an fb compiler, or any compiler which will output text when it is run (no need to compile any file here, all you need is the compiler raw output to test )
I know nothing about Win SDK or O2, sorry.
I got the wrong end of your question, "error message" threw me, you want compiler messages.
Please pop in your own path to an fb compiler, or any compiler which will output text when it is run (no need to compile any file here, all you need is the compiler raw output to test )
I know nothing about Win SDK or O2, sorry.
Code: Select all
#Include Once "windows.bi"
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
Dim Shared As zString * 1024 path="C:\Users\Computer\Desktop\fb\FreeBASIC-1.09.0-winlibs-gcc-9.3.0\fbc64.exe"
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 m=pipeout(path)
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
Re: How reveive error message?
thanks dodicat
sorry if i ask it in a wrong way...
yes compiler messages ...including of course error messages if user made mistake or error
ok
i will try code ..
sorry if i ask it in a wrong way...
yes compiler messages ...including of course error messages if user made mistake or error
ok
i will try code ..
Re: How reveive error message?
dodicat
in my case path is :
is that OK?
i compiled code and what i get is console with warning
D:\FreeBASIC-1.09.0-win64\FreeBASIC-1.09.0-win64\CompilerMessanger.bas(50) warning 4(2): Suspicious pointer assignment
Is that OK ?
in my case path is :
Code: Select all
Dim Shared As zString * 1024 path="D:\FreeBASIC-1.09.0-win64\FreeBASIC-1.09.0-win64\fbc.exe"
i compiled code and what i get is console with warning
D:\FreeBASIC-1.09.0-win64\FreeBASIC-1.09.0-win64\CompilerMessanger.bas(50) warning 4(2): Suspicious pointer assignment
Is that OK ?
Re: How reveive error message?
@dodicat
can you explain to me why is always this ugly warning in fb:
this wc class member ..name :
Suspicious pointer assignment
can you explain to me why is always this ugly warning in fb:
this wc class member ..name :
Code: Select all
.lpszClassName = strptr ("WindowClass")
Re: How reveive error message?
sorry @dodicat
if i bothering you with this "suspicous pointer"
i figured that must be declared inside FBMain()
now compile properly with output window show compiler messages when i click
button "Compiler "
thanks a lot ..ahh i am not used very much on FB tricks ...shame on me
if i bothering you with this "suspicous pointer"
i figured that must be declared inside FBMain()
now compile properly with output window show compiler messages when i click
button "Compiler "
Code: Select all
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 ("WindowClass")
.lpszClassName = strptr (WND_CLASS_NAME)
End With