Page 1 of 1

#PB_Compiler_Target

Posted: Thu Jan 20, 2022 10:55 am
by Joubarbe

Code: Select all

CompilerIf #PB_Compiler_Target = "Dev"
  Debug "Development code."
CompilerElse
  Debug "Production code."
CompilerEndIf
I know you can add it through custom constants, but I think it would be handy to have it pre-built.

Re: #PB_Compiler_Target

Posted: Thu Jan 20, 2022 12:02 pm
by BarryG
This can already be done by using the built-in constant of #PB_Editor_CreateExecutable (with #PB_Editor_CreateExecutable also ticked in the Compiler Options for the app). So your code can do one thing if run from the IDE, and another thing if run from a compiled exe:

Code: Select all

Global appname$=ProgramFilename() ; Assume the user is running your app from a compiled executable (production code).
CompilerIf #PB_Editor_CreateExecutable=0 ; But if not, and is running from the IDE, use a hard-coded path (development code).
  appname$="C:\Hard\Coded\Path\To\Development.exe"
CompilerEndIf

Re: #PB_Compiler_Target

Posted: Thu Jan 20, 2022 4:01 pm
by ChrisR
Good to know for #PB_Editor_CreateExecutable, thanks :)
I was doing it, like Joubarbe, with a custom constant.