Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Detect running from IDE
#1
I regularly want to know if I'm running from the IDE (during development) or not.
To set the current working directory correct or to stop with End instead of System
etc.

I now use this code which seems to work for some time already:

Code: (Select All)
Dim Shared DEVELOPMENT As _Byte
$If WIN Then
  DEVELOPMENT = (Environ$("sessionname") = "Console"): If Not DEVELOPMENT Then ChDir _StartDir$
$End If
'...
If DEVELOPMENT Then End Else System
But is this a correct/reliable way? Where does sessionname=Console come from and will it stay like this in future versions?
I would love to have a _DEVELOPMENT variable out-of-the-box as part of QB64pe

Sidenote: Why is _CWD not correct initialized when not running from the IDE; It then points to the directory containing your exe instead
45y and 2M lines of MBASIC>BASICA>QBASIC>QBX>QB64 experience
Reply
#2
This is 100% guaranteed to work:

Code: (Select All)
$DEBUG
test$ = ENVIRON$("QB64DEBUGPORT")
IF test$ = "" THEN PRINT "running independently" ELSE PRINT "running from inside the IDE"

Unless, of course, you have manually set QB64DEBUGPORT in your environment for whatever obscure reason.
Reply




Users browsing this thread: 1 Guest(s)