How can I tell if running from stand-alone or compiler?
How can I tell if running from stand-alone or compiler?
Easy one...
How can the program tell if it is running from the compiler or in stand-alone?
Is there a constant (with a value) or something else?
How can the program tell if it is running from the compiler or in stand-alone?
Is there a constant (with a value) or something else?
MacBook Pro-M1 (2021), Tahoe 26.1, PB 6.30b2
I'm guessing as I don't have a MAC but I would have thought that in practice (though not always in theory) this code would do what you want:
Code: Select all
If LCase(GetPathPart(ProgramFilename()))= LCase(GetTemporaryDirectory())
MessageRequester("Run Type", "Running from the IDE")
Else
MessageRequester("Run Type", "Running as a stand-alone EXE")
EndIfAnthony Jordan
there's no difference when running a pb executable from the ide or a compiled version , the compiler create an .exe then run it.
but you can set yourself a way to kow it
put something like
then use the variable for your program to know if it run from the compiler or not...
but you can set yourself a way to kow it
put something like
Code: Select all
global standalone.b=1 ; change it to 0 for a non standalone build
- Kaeru Gaman
- Addict

- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
akj wrote:I'm guessing as I don't have a MAC but I would have thought that in practice (though not always in theory) this code would do what you want:Code: Select all
If LCase(GetPathPart(ProgramFilename()))= LCase(GetTemporaryDirectory()) MessageRequester("Run Type", "Running from the IDE") Else MessageRequester("Run Type", "Running as a stand-alone EXE") EndIf
that may not work if you compile the program in the same directory of the final build , like i do for some code that need files to be present.
Thanks all.
I've been using the variable method as shown below.
I've been using the variable method as shown below.
Code: Select all
FilePath.s=GetCurrentDirectory()
If Len(AFilePath)<5
; gives / (one char) (this is stand-alone mode)
FilePath=ProgramFilename() ; this works in stand-alone mode
PBMode=0 ; in stand-alone
Else
;gives full file path
PBMode=1 ; in compile mode
EndIf
MacBook Pro-M1 (2021), Tahoe 26.1, PB 6.30b2
- Kaeru Gaman
- Addict

- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
Re: How can I tell if running from stand-alone or compiler?
> How can the program tell if it is running from the compiler or in stand-alone?
For Windows (and probably cross-platform) I've been using this:
No need to enable anything in every source. 
For Windows (and probably cross-platform) I've been using this:
Code: Select all
CompilerIf #PB_Compiler_Debugger
; Do runtime code here.
CompilerElse
; Do final exe code here.
CompilerEndIf
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
- Kaeru Gaman
- Addict

- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
@freak,
As most PB users would expect a constant that seems to relate to the compilation process to be mentioned in the 'Compiler Directives' section of the Help manual, I would like to request that a reference to (i.e. mention of) #PB_Editor_CreateExecutable be added to that help section. Pretty please.
Alternatively, can a facility be provided for [a copy of] the Help pages to be freely editable by registered PureBasic users? Of course, the edits would need to be vetted by 'The Management' but it would be a good way to quickly improve the quality and scope of the PB documentation which in my opinion is still quite minimalist.
As most PB users would expect a constant that seems to relate to the compilation process to be mentioned in the 'Compiler Directives' section of the Help manual, I would like to request that a reference to (i.e. mention of) #PB_Editor_CreateExecutable be added to that help section. Pretty please.
Alternatively, can a facility be provided for [a copy of] the Help pages to be freely editable by registered PureBasic users? Of course, the edits would need to be vetted by 'The Management' but it would be a good way to quickly improve the quality and scope of the PB documentation which in my opinion is still quite minimalist.
Anthony Jordan
Its not a feature of the compiler. Its a feature of the IDE, and it is documented in the IDE documentation. (if you use the commandline compiler, the constant will not be added).akj wrote:@freak,
As most PB users would expect a constant that seems to relate to the compilation process to be mentioned in the 'Compiler Directives' section of the Help manual, I would like to request that a reference to (i.e. mention of) #PB_Editor_CreateExecutable be added to that help section. Pretty please.
There was a wiki once. It was taken down due to lack of user interest.akj wrote:Alternatively, can a facility be provided for [a copy of] the Help pages to be freely editable by registered PureBasic users? Of course, the edits would need to be vetted by 'The Management' but it would be a good way to quickly improve the quality and scope of the PB documentation which in my opinion is still quite minimalist.
quidquid Latine dictum sit altum videtur
Use the demoversionPB wrote:> you can compile a standalone exe INCLUDING debugger support
How? The docs say it's never done that way, for speed reasons.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.



