Page 1 of 1
How to detect if the code is running on the IDE [SOLVED]
Posted: Saturday 25th March 2023 10:21am
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".
Re: How to detect if the code is running on the IDE
Posted: Saturday 25th March 2023 11:57am
by vuott
Re: How to detect if the code is running on the IDE
Posted: Saturday 25th March 2023 1:27pm
by JumpyVB
Thank you vuott
Public Sub DebuggerIsAttached() As Boolean
Return Not (Args[0] Like "*.gambas")
End
Re: How to detect if the code is running on the IDE
Posted: Saturday 25th March 2023 2:56pm
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.
Re: How to detect if the code is running on the IDE
Posted: Saturday 25th March 2023 4:53pm
by JumpyVB
Thanks Bruce. I will use this.