Forum > General
"Run without Debugging" and "Command line parameters"
cvpas:
Hi,
I did a fresh install of Lazarus 1.8.4 (lazarus-1.8.4-fpc-3.0.4-win32.exe) on Windows 10 64 bit.
I set the value of "Run parameters - Command line parameters" to: "first second third" (without quotes).
Running this simple program:
--- 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";}};} ---program test_params; {$IFDEF FPC} {$MODE DELPHI}{$ELSE} {$APPTYPE CONSOLE}{$ENDIF} var i: Integer;begin for i := 1 to ParamCount do WriteLn('Param(', i, ')=', ParamStr(i)); WriteLn('Press Enter to exit ...'); ReadLn;end.
from Lazarus IDE using "Run" (F9) the output is:
Param(1)=first
Param(2)=second
Param(3)=third
Press Enter to exit ...
wich is what I expect.
But when I run the program using "Run without Debugging" (Shift+Ctrl+F9) the output is:
Param(1)=first second third
Press Enter to exit ...
It seems that in the second case Lazarus IDE will send the content of "Command line parameters" as a single parameter to the executable.
Is this a bug or is it "by design" ?
Thank you.
valdir.marcos:
--- Quote from: cvpas on September 25, 2018, 11:28:28 pm ---I did a fresh install of Lazarus 1.8.4 (lazarus-1.8.4-fpc-3.0.4-win32.exe) on Windows 10 64 bit.
I set the value of "Run parameters - Command line parameters" to: "first second third" (without quotes).
Running this simple program:
--- 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";}};} ---program test_params; {$IFDEF FPC} {$MODE DELPHI}{$ELSE} {$APPTYPE CONSOLE}{$ENDIF} var i: Integer;begin for i := 1 to ParamCount do WriteLn('Param(', i, ')=', ParamStr(i)); WriteLn('Press Enter to exit ...'); ReadLn;end.
from Lazarus IDE using "Run" (F9) the output is:
Param(1)=first
Param(2)=second
Param(3)=third
Press Enter to exit ...
wich is what I expect.
But when I run the program using "Run without Debugging" (Shift+Ctrl+F9) the output is:
Param(1)=first second third
Press Enter to exit ...
It seems that in the second case Lazarus IDE will send the content of "Command line parameters" as a single parameter to the executable.
--- End quote ---
I can confirm both situations on Microsoft Windows 7.
And I can add that Command Line behavior is correct. See image.
--- 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";}};} ---program Project1; {$mode objfpc}{$H+} uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} Classes { you can add units after this }; var i: Integer;begin for i := 1 to ParamCount do WriteLn('Param(', i, ')=', ParamStr(i)); WriteLn('Press Enter to exit ...'); ReadLn;end.
--- Quote --- Is this a bug or is it "by design" ?
--- End quote ---
I believe it's a bug because "Run" (F9) and "Run without Debugging" (Shift+Ctrl+F9) should have the same behavior and produce the same output.
Please, fill in a bug report.
Ondrej Pokorny:
Patch attached.
JuhaManninen:
--- Quote from: Ondrej Pokorny on September 26, 2018, 09:53:38 am ---Patch attached.
--- End quote ---
Thanks. I applied it in r59168. Please test everybody. It will be merged to 2.0 branch later.
cvpas:
Hi,
Using the patch provided by Ondrej Pokorny I did the following changes to the method TMainIDE.DoRunProjectWithoutDebug in \lazarus\ide\main.pp from Lazarus 1.8.4 original sources:
- declared two additional variables:
--- 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";}};} ---var ExeFile, Params: string;
- replaced the lines:
--- 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";}};} --- Process.Executable := Copy(ExeCmdLine, ExeFileStart, ExeFileEnd-ExeFileStart); Process.Parameters.Text := Copy(ExeCmdLine, ExeFileEnd+ExeFileStart, High(Integer)); with:
--- 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";}};} --- SplitCmdLine(ExeCmdLine, ExeFile, Params); Process.Executable := ExeFile; if Params <> '' then CommandToList(Params, Process.Parameters);
After rebuilding Lazarus IDE I can confirm that "Run without Debugging" produces the same output as "Run".
Thank you for your help and for this great IDE
Navigation
[0] Message Index
[#] Next page