Recent

Author Topic: [Solved] Illegal expression for plus sign  (Read 204 times)

nikel

  • Full Member
  • ***
  • Posts: 244
[Solved] Illegal expression for plus sign
« on: March 15, 2025, 12:41:03 pm »
Hello, I'm trying to set and get some variables in my project. When I run the code below, I'm getting Illegal expression error.

Code: Pascal  [Select][+][-]
  1. ...
  2. var
  3.   Application: TMain;
  4.  
  5. {$R *.res}
  6.  
  7. begin
  8.   Application:=TMain.Create (nil);
  9.  
  10.   Application.SetConfigFile(ParamStr(0)) + C_DELIMITER + 'config.txt');
  11.  
  12.   Application.Title:='Playlist Program';
  13.   Application.Run;
  14.   Application.Free;
  15. end.

How can I fix this error?

Modify:
I'm using TCustomApplication in my class.
« Last Edit: March 15, 2025, 12:56:42 pm by nikel »

cdbc

  • Hero Member
  • *****
  • Posts: 2067
    • http://www.cdbc.dk
Re: Illegal expression for plus sign
« Reply #1 on: March 15, 2025, 12:52:51 pm »
Hi
ParamStr(0) returns the whole program-name as called from the OS, on winders, that includes '.exe' extension, on unices it doesn't have to have an extension.
Which brings us to "C_DELIMITER", what the h*ll is that?!? Is it a hyphen '-' or what?!?
Third point:
Code: Pascal  [Select][+][-]
  1. Application.SetConfigFile(ParamStr(0)) + C_DELIMITER + 'config.txt');
There's 1 too many ')' in this "ParamStr(0))", remove the last one, so that the entire becomes:
Code: Pascal  [Select][+][-]
  1. Application.SetConfigFile(ParamStr(0) + C_DELIMITER + 'config.txt');
...Then your config-file may be named '/home/you/myapp-config.txt' at least on a *nix-box...
I'm grasping here, due to the lack of info...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

nikel

  • Full Member
  • ***
  • Posts: 244
Re: Illegal expression for plus sign
« Reply #2 on: March 15, 2025, 12:56:23 pm »
Thank you sir. I deleted one of the double brackets and it's working fine.

 

TinyPortal © 2005-2018