Forum > General

The separator in the command line

(1/5) > >>

DEN1983:
Hi everybody!

How can I change the command line parameter separator?
I want to change the space to a backslash so that the ParamStr and ParamCount functions parse the string by backslash(\).
Maybe there is something like DefaultFormatSettings.......Separator ?

I have Windows 10 and Lazarus 3.4

TRon:

--- Quote from: DEN1983 on July 18, 2024, 07:30:33 am ---How can I change the command line parameter separator?

--- End quote ---
You can't for Paramstr and Paramcount unless you modify the compiler's RTL.

You would have to implement your own parameter handling if you want something like that.

DEN1983:

--- Quote from: TRon on July 18, 2024, 07:39:22 am ---You would have to implement your own parameter handling if you want something like that.

--- End quote ---
Thank you.
I'm ready.
Where to start throw links..

TRon:

--- Quote from: DEN1983 on July 18, 2024, 07:50:32 am ---I'm ready.
Where to start throw links..

--- End quote ---
This is not a Pascal related question rather an OS one.

Just like any other programing language the commandline is always assumed to have arguments separated by a space so all existing functionality is geared towards that.

So your google is just as good as mine (which btw landed me here)

The rest is a matter of parsing the resulting string exactly the way you want it to be parsed.

Thaddy:
If you can guarantee there are no spaces, but only slashes, this is quite easy.
--- 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 sep;{$mode objfpc}uses  classes; var  l:Tstringlist;begin  if paramcount > 0 then  try    l:=Tstringlist.create;    l.adddelimitedtext(paramstr(1),'\',true);        writeln(l.text);  finally    l.free;  end;end.
--- Code: Bash  [+][-]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";}};} ---D:\>sep test\me\a\bittestmeabitIf there are spaces in the input it becomes a bit more complex, because the spaces increase the paramcount. (that is, unless the input is a quoted string)

Navigation

[0] Message Index

[#] Next page

Go to full version