__FB_MAINFILE__
-
- Posts: 789
- Joined: Jul 26, 2018 18:28
__FB_MAINFILE__
Now there is __FB_MAIN__ only for modules. Is it possible to add __FB_MAINFILE__?
Re: __FB_MAINFILE__
__FB_MAIN__ is only defined in the main module. So ... same for __FB_MAINFILE__?
Does this do what you want?
Does this do what you want?
Code: Select all
#ifdef __FB_MAIN__
#define __FB_MAINFILE__ __FILE__
#endif
#print __FB_MAINFILE__
-
- Posts: 789
- Joined: Jul 26, 2018 18:28
Re: __FB_MAINFILE__
No, it doesn't work correctly. I also had this option.coderJeff wrote: ↑Oct 15, 2022 16:35 __FB_MAIN__ is only defined in the main module. So ... same for __FB_MAINFILE__?
Does this do what you want?Code: Select all
#ifdef __FB_MAIN__ #define __FB_MAINFILE__ __FILE__ #endif #print __FB_MAINFILE__
This check is always correct: #if __FB_MAINFILE__ = __FILE__ (error)
But I had to change to this:
Code: Select all
'#Region "Form"
#if defined(__FB_MAIN__) AndAlso Not defined(__MAIN_FILE__)
#define __MAIN_FILE__
Const _MAIN_FILE_ = __FILE__
#ifdef __FB_WIN32__
#cmdline "Form1.rc"
#endif
#endif
#include once "mff/Form.bi"
Using My.Sys.Forms
Type Form1Type Extends Form
End Type
Dim Shared Form1 As Form1Type
#if _MAIN_FILE_ = __FILE__
Form1.MainForm = True
Form1.Show
App.Run
#endif
'#End Region
Now it is also possible to do this as indicated in my example, but I thought if there is __FB_MAIN__ why not __FB_MAINFILE__.
-
- Posts: 789
- Joined: Jul 26, 2018 18:28
Re: __FB_MAINFILE__
If the user does this, the main file is also incorrectly defined:
Code: Select all
#include once "Form2.frm"
'#Region "Form"
#if defined(__FB_MAIN__) AndAlso Not defined(__MAIN_FILE__)
#define __MAIN_FILE__
Const _MAIN_FILE_ = __FILE__
#ifdef __FB_WIN32__
#cmdline "Form1.rc"
#endif
#endif
#include once "mff/Form.bi"
Using My.Sys.Forms
Type Form1Type Extends Form
End Type
Dim Shared Form1 As Form1Type
#if _MAIN_FILE_ = __FILE__
Form1.MainForm = True
Form1.Show
App.Run
#endif
'#End Region
Re: __FB_MAINFILE__
If this is not what you want, then I don't understand.Xusinboy Bekchanov wrote: ↑Oct 15, 2022 17:10 If it would be possible to __FB_MAINFILE__ with or without a path value then that would be great.
Code: Select all
#if defined(__FB_MAIN__)
Const __FB_MAINFILE__ = __FILE__
#else
Const __FB_MAINFILE__ = ""
#endif
Code: Select all
const __FB_MAINFILE__ = __FB_IIF__( __FB_ARG_COUNT__( __FB_MAIN__ ) = 0, __FILE__, "" )
-
- Posts: 789
- Joined: Jul 26, 2018 18:28
Re: __FB_MAINFILE__
I told the compiler itself to determine this. I have my own solutions for this task as shown in my example.coderJeff wrote: ↑Oct 16, 2022 0:58If this is not what you want, then I don't understand.Xusinboy Bekchanov wrote: ↑Oct 15, 2022 17:10 If it would be possible to __FB_MAINFILE__ with or without a path value then that would be great.For fun, with fbc 1.10.0, but it's hard to read:Code: Select all
#if defined(__FB_MAIN__) Const __FB_MAINFILE__ = __FILE__ #else Const __FB_MAINFILE__ = "" #endif
Code: Select all
const __FB_MAINFILE__ = __FB_IIF__( __FB_ARG_COUNT__( __FB_MAIN__ ) = 0, __FILE__, "" )
I don't need such an empty __FB_MAINFILE__:
Code: Select all
Const __FB_MAINFILE__ = ""
Without a path value:
Code: Select all
#ifdef __FB_MAINFILE__
' This is the main file
#else
' This is not the main file.
#endif
Or like this:
With a path value:
Code: Select all
#if __FB_MAINFILE__ = __FILE__
' This is the main file
#else
' This is not the main file.
#endif