How to detect if the code is running on the IDE [SOLVED]

New to Gambas? Post your questions here. No question is too silly or too simple.
Post Reply
JumpyVB
Posts: 75
Joined: Friday 11th September 2020 9:09am

How to detect if the code is running on the IDE [SOLVED]

Post by JumpyVB »

How do I check in my code whether its running a) in the gambas development environment Run/Debugging or b) in the "Maked executable".
Last edited by JumpyVB on Monday 27th March 2023 3:07pm, edited 1 time in total.
vuott
Posts: 262
Joined: Wednesday 5th April 2017 6:07pm
Location: European Union

Re: How to detect if the code is running on the IDE

Post by vuott »

Europaeus sum !

Amare memorentes atque deflentes ad mortem silenter labimur.
JumpyVB
Posts: 75
Joined: Friday 11th September 2020 9:09am

Re: How to detect if the code is running on the IDE

Post by JumpyVB »

Thank you vuott
Public Sub DebuggerIsAttached() As Boolean
 Return Not (Args[0] Like "*.gambas")
End
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: How to detect if the code is running on the IDE

Post by BruceSteers »

I used to check the filename but it's not entirely reliable if you rename the exe to not have the .gambas ext or use a link (with no ext), but then i found a better way.

Check this out...
https://gambaswiki.org/wiki/lang/.if

Exec is set to true for a compiled exe but not when debugging in IDE

So just have something like this in your startup class...


Public IsIDE as boolean

Public sub Form_Open()

#If Not (Exec)   
 IsIDE = True
#Endif

End



With this method if your exe or the link to it has been renamed to not have the .gambas extension it will still work as expected.
If at first you don't succeed , try doing something differently.
BruceS
JumpyVB
Posts: 75
Joined: Friday 11th September 2020 9:09am

Re: How to detect if the code is running on the IDE

Post by JumpyVB »

Thanks Bruce. I will use this.
Post Reply