PDA

View Full Version : debug mode



Crisp_N_Dry
19-04-2005, 12:48 PM
I want to enable a debug mode by adding a condtion to the target field in my shortcut. For example My shortcut might have the target
"Project1.Exe -Debug". I then want my program to realise that I want debug mode enabled and switch a boolean to enable it. I'm sure it's relatively simple but Google is proving fruitless. Anyone?

tux
19-04-2005, 01:33 PM
load delphi -> help -> delphi help -> (index) paramstr function

:)


The following example beeps once for each ?¢_obeep?¢__ passed in on the command line. The example terminates the application if ?¢_oexit?¢__ is passed in on the command line.

procedure TForm1.FormCreate(Sender: TObject);

var
i: Integer;
for i := 1 to ParamCount do
begin
if LowerCase(ParamStr(i)) = 'beep' then
Beep
else if LowerCase(ParamStr(i)) = 'exit' then
Application.Terminate;
end;
end;

{MSX}
19-04-2005, 01:46 PM
load delphi -> help -> delphi help -> (index) paramstr function


I think he wants to add the Compiler switch, not just know about the parameter.
Something like:

if paramstr(1)='debug' then {$DEFINE debug}
(obviously not working)

Btw i don't think it is possible. The compiler switches (and all compiler directives) are resolved at compile time so your executable don't know anything about it.

tux
19-04-2005, 04:03 PM
in that case, use an .inc file and define the debug in that, just include that in every source file

Crisp_N_Dry
19-04-2005, 09:29 PM
Brilliant stuff Tux, works like a charm. Always wondered what ParamStr actually did. Alyways used it to get the file path for my exe and that was it. It's actually a pretty useful function. Thanks again :D