[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: in or out IDE
[Thread Prev] | [Thread Next]
- Subject: Re: in or out IDE
- From: Bruce Steers <bsteers4@xxxxxxxxx>
- Date: Fri, 2 Oct 2026 08:49:10 +0100
- To: Gambas Mailing List <user@xxxxxxxxxxxxxxxxxxxxxx>
Gotta love an easy way 😎 but to be clear, that only works if the
executable is otherwise run from outside the project directory.
If that is the case you probably don't need to create anything.
There are already things that will not be added to the executable like the
.src directory.
So you can just do ..
If Not Exist("./.src") Then
' Must be the executable outside the project directory.
Endif
It wouldn't work for me as most of my programs run from their project
directory either directly or via symlinks as they are all in active
development so the files/dirs will be found.
There's other simple ways...
If File.Ext(File.RealPath(Args[0])) = "gambas" Then
bIsExecutable = True
' This works (is true) even if the command executed is a symlink without
the .gambas extension to a .gambas executable in its project dir.
' It will not be true if run from the IDE
Endif
I prefer testing Exec and Debug pre-processor constants with #If though, it
just seems more robust for the various different launch situations :)
Respects
BruceS
On Thu, 1 Oct 2026, 23:38 Jussi Lahtinen, <jussi.lahtinen@xxxxxxxxx> wrote:
> Perhaps clearer this way:
>
> 1. Create ".IDE" to the project folder.
>
> 2. Use this code:
> If Exist("./.IDE") = True Then
> Message("This is IDE!")
> Else
> Message("This is not IDE.")
> Endif
>
> This is sure way to detect it.
>
> Jussi
>
> On Fri, Oct 2, 2026 at 1:31 AM Jussi Lahtinen <jussi.lahtinen@xxxxxxxxx>
> wrote:
>
>> You can use Application.Path to see if it is run from the project folder
>> or somewhere else. Also you can put ".IDE" named file there, which is not
>> included into the executable and check if it is there.
>>
>>
>> Jussi
>>
>> On Thu, Oct 1, 2026 at 9:47 PM Bruce Steers <bsteers4@xxxxxxxxx> wrote:
>>
>>>
>>>
>>> On Thu, 1 Oct 2026 at 15:38, Bruce Steers <bsteers4@xxxxxxxxx> wrote:
>>>
>>>>
>>>>
>>>> On Thu, 1 Oct 2026 at 15:19, Philippe Valarcher <
>>>> philippe.valarcher@xxxxxxx> wrote:
>>>>
>>>>> Le jeudi 01 octobre 2026 à 14:52 +0100, Bruce Steers a écrit :
>>>>>
>>>>> Try this...
>>>>>
>>>>> #If Exec
>>>>> Print "run from the executable"
>>>>> #Else
>>>>> Print "Run from IDE"
>>>>> #Endif
>>>>>
>>>>> Read here...
>>>>> https://gambasgb.uk/phpBB/viewtopic.php?t=22
>>>>>
>>>>> Respects
>>>>> BruceS
>>>>>
>>>>>
>>>>> On Thu, 1 Oct 2026 at 11:12, valaquarus <valaquarus@xxxxxxxxx> wrote:
>>>>>
>>>>> How can you tell if you're launching a program from within the IDE or
>>>>> outside of it?
>>>>>
>>>>>
>>>>> Thank you Bruce that's nearly what I did and it makes it real good.
>>>>>
>>>>> --
>>>>>
>>>>> Philippe Valarcher <philippe.valarcher@xxxxxxx>
>>>>>
>>>>
>>>> You're welcome.
>>>>
>>>> It's not completely 100% bullet-proof but works in most cases.
>>>>
>>>> For example if i was to start a program with gbx3 on the folder and not
>>>> run the compiled executable...
>>>> Eg.
>>>> $ gbx3 /path/to/program/folder
>>>>
>>>> then the Exec pre-processor constant will not be set but we are also
>>>> not using the IDE.
>>>>
>>>> It would be more useful i think if the IDE could also set a Flag/Env of
>>>> some sort, a more definitive indicator of an IDE test run as opposed to
>>>> launching the executable.
>>>> Perhaps if Benoit could give us something more reliable like a
>>>> pre-processor constant called IDE,
>>>> #if IDE Then
>>>>
>>>> Respects
>>>> BruceS
>>>>
>>>
>>> Actually this is a bit more robust...
>>>
>>> Public Debugging As Boolean
>>>
>>> Public Sub Form_Open()
>>> #If ( Not Exec )
>>> #If Debug
>>> Debugging = True
>>> #Endif
>>> #Endif
>>>
>>> End
>>>
>>> that way we are also checking the Debug constant (set by running via the
>>> IDE)
>>> and the Exec constant set when running the executable.
>>>
>>>
| Re: in or out IDE | Bruce Steers <bsteers4@xxxxxxxxx> |
| in or out IDE | valaquarus <valaquarus@xxxxxxxxx> |
| Re: in or out IDE | Bruce Steers <bsteers4@xxxxxxxxx> |
| Re: in or out IDE | Philippe Valarcher <philippe.valarcher@xxxxxxx> |
| Re: in or out IDE | Bruce Steers <bsteers4@xxxxxxxxx> |
| Re: in or out IDE | Bruce Steers <bsteers4@xxxxxxxxx> |
| Re: in or out IDE | Jussi Lahtinen <jussi.lahtinen@xxxxxxxxx> |
| Re: in or out IDE | Jussi Lahtinen <jussi.lahtinen@xxxxxxxxx> |