Forum > General
define application release mode or debug mode
Prakash:
{$DEFINE DEBUG}
with TFileStream.Create('d:\data.json', fmCreate) do
begin
try
S := datajson.AsJSON;
WriteBuffer(S[1], Length(S));
finally
Free;
end;
end;
{$IFDEF RELEASE}
{$ENDIF}
I want to execute this code only my application is in debug mode .
how and where to define application debug or release mode
TRon:
https://wiki.lazarus.freepascal.org/IDE_Window:_Compiler_Options#Build_modes
https://wiki.freepascal.org/Conditional_compilation
Eugene Loza:
Or to be a bit more specific:
1. Create Debug/Release mode as shown in the first link.
2. Create a custom options entry as shown a bit below that (see attached screenshot) - it will affect only the currently selected one.
your code won't compile though, {$IFDEF} needs a matching {$ENDIF}. I.e. something like:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{$IFDEF DEBUG}with TFileStream.Create('d:\data.json', fmCreate) dobegin try S := datajson.AsJSON; WriteBuffer(S[1], Length(S)); finally Free; end;end;{$ELSE} //Do something in not-debug mode{$ENDIF}
Thaddy:
The correct option is
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{$ifopt d+}This can be used with any global compiler directive, btw.
{$ifopt <x>+/-} can be used multiple times.
Warfley:
--- Quote from: Thaddy on July 25, 2024, 10:48:09 am ---The correct option is
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{$ifopt d+}This can be used with any global compiler directive, btw.
--- End quote ---
This is not a debug mode, this is for when debug symbols are present, which you may also want to have in the release build of your program, e.g. to do logging, or for performance measurements. If your goal is to have code that is only in a debug build, you should create a debug build with a define.
Navigation
[0] Message Index
[#] Next page