GetOptionValue in CLI application lazarus / 61-Beginners ---------------------------------------------------------------------- francisco1844 · 2017-02-07 10:10 Trying to follow  the examples in http://wiki.freepascal.org/Command_l ine_parameters_and_environment_variables Im am not using Lazarus, yet, and trying to figure out best way to parse parameters for CLI applications. This works Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1; {$mode objfpc}{$H+} var  I: Integer;begin  WriteLn('Program: ', ParamStr(0));  for I := 1 to ParamCount do    WriteLn('Param ', I, ': ', ParamStr(I)); end. But when I tried to add:   WriteLn('f=', GetOptionValue('f', 'file')); Get the error: sample.pas(12,17) Error: Identifier not found "GetOptionValue" What do I need to include to get HasOption and GetOptionValue to work in a CLI application? [Edit] using FPC 3.0.0. ---------------------------------------------------------------------- Handoko · 2017-02-07 10:31 Hello francisco, Welcome to this forum. GetOptionValue is a method of TCustomApplication: http://www.freepascal.org/docs- html/fcl/custapp/tcustomapplication.getoptionvalue.html In short, you can use it if your project is an Application (not simple program). To do it: Start Lazarus > on the main menu > New > Project > Application ---------------------------------------------------------------------- francisco1844 · 2017-02-07 21:56 Thanks for the reply. So what, if any, is the easiest way to handle parameters to a CLI program? ---------------------------------------------------------------------- howardpc · 2017-02-07 22:55 You could adapt this skeleton: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1; {$mode objfpc}{$H+} uses  {$IFDEF UNIX}{$IFDEF UseCThreads}  cthreads,  {$ENDIF}{$ENDIF}  SysUtils, CustApp; type   TTestCLIApplication = class(TCustomApplication)  protected    procedure DoRun; override;  public  end; procedure TTestCLIApplication.DoRun;var  i: integer;begin  inherited DoRun;  for i := 1 to ParamCount do    WriteLn(Params[i]);  WriteLn('HasOption(''param1'') is ',HasOption('param1'));  ReadLn;  Terminate;end; var  app: TTestCLIApplication; begin  app:=TTestCLIApplication.Create(nil);  app.Title:='Test CLI application';  app.Run;  app.Free;end.