Recent

Author Topic: Illegal qualifier while trying to split string  (Read 3272 times)

rnfpc

  • Full Member
  • ***
  • Posts: 101
Illegal qualifier while trying to split string
« on: June 26, 2019, 02:55:24 pm »
I am trying following code to split a string:
Code: Pascal  [Select][+][-]
  1. {$mode objfpc}
  2. uses SysUtils;
  3. var
  4.   fullstr: string ;
  5.   strarr: array of string;
  6.   charArray : Array[0..0] of Char = ',';
  7.   item: string;
  8. begin
  9.   fullstr := 'one, two, three';
  10.   strarr := fullstr.split(charArray); //ERROR;
  11.   for item in strarr do writeln(item);
  12. end.

However, I am getting following error:
Code: Pascal  [Select][+][-]
  1. Free Pascal Compiler version 3.0.0+dfsg-11+deb9u1 [2017/06/10] for x86_64
  2. Copyright (c) 1993-2015 by Florian Klaempfl and others
  3. Target OS: Linux for x86-64
  4. Compiling rnsplitstring.pas
  5. rnsplitstring.pas(10,20) Error: Illegal qualifier
  6. rnsplitstring.pas(14) Fatal: There were 1 errors compiling module, stopping
  7. Fatal: Compilation aborted
  8. Error: /usr/bin/ppcx64 returned an error exitcode

Where is the problem and how can it be solved? What is classical way to split a string in Pascal?
« Last Edit: June 29, 2019, 07:00:36 pm by rnfpc »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11445
  • FPC developer.
Re: Illegal qualifier while trying to split string
« Reply #1 on: June 26, 2019, 03:11:35 pm »
Works fine with $mode delphi and 3.0.4

p.s. 3.0.0 is near 4 years old

rnfpc

  • Full Member
  • ***
  • Posts: 101
Re: Illegal qualifier while trying to split string
« Reply #2 on: June 26, 2019, 03:18:21 pm »
It is not working with {$mode delphi} on fpc version 3.0.0 on Debian Stable Linux.

What is the classical way to split a string in Pascal?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11445
  • FPC developer.
Re: Illegal qualifier while trying to split string
« Reply #3 on: June 26, 2019, 03:39:57 pm »
It is not working with {$mode delphi} on fpc version 3.0.0 on Debian Stable Linux.

What is the classical way to split a string in Pascal?

Till Delphi code your own. With Delphi TStringlist.delimitedtext, which got modified in D2006 with strictdelimiter.

In later Delphi XEs (2012 or so) this .split ws added.

Anyway, I suggest you upgrade your version.

Thaddy

  • Hero Member
  • *****
  • Posts: 14359
  • Sensorship about opinions does not belong here.
Re: Illegal qualifier while trying to split string
« Reply #4 on: June 26, 2019, 03:50:28 pm »
The new debian stable (released just now or this week) has 3.0.4, For Debian 9 it is in backports since well over a year. Upgrade!
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

rnfpc

  • Full Member
  • ***
  • Posts: 101
Re: Illegal qualifier while trying to split string
« Reply #5 on: June 27, 2019, 08:44:39 am »
I have upgraded by Debian system. The current version info is:

Code: Pascal  [Select][+][-]
  1. $ lsb_release -a
  2. No LSB modules are available.
  3. Distributor ID: Debian
  4. Description:    Debian GNU/Linux 9.9 (stretch)
  5. Release:        9.9
  6. Codename:       stretch
  7.  

And fpc version is:
Code: Pascal  [Select][+][-]
  1. $ fpc -v
  2. Free Pascal Compiler version 3.0.0+dfsg-11+deb9u1 [2017/06/10] for x86_64
  3. Copyright (c) 1993-2015 by Florian Klaempfl and others
  4. Fatal: No source file name in command line
  5. Fatal: Compilation aborted
  6. Error: /usr/bin/ppcx64 returned an error exitcode
  7.  

But it does not work on my system.

julkas

  • Guest
Re: Illegal qualifier while trying to split string
« Reply #6 on: June 27, 2019, 09:12:36 am »
It is not working with {$mode delphi} on fpc version 3.0.0 on Debian Stable Linux.

What is the classical way to split a string in Pascal?
I use TSringList for FPC 3.0.0.

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Illegal qualifier while trying to split string
« Reply #7 on: June 27, 2019, 10:14:01 am »
What is classical way to split a string in Pascal?

The really "classic" way is repeatedly calling Pos(), Copy() and Delete() until you're left without string.

Available since, at least, Turbo Pascal 1.0 (1983) :)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Thaddy

  • Hero Member
  • *****
  • Posts: 14359
  • Sensorship about opinions does not belong here.
Re: Illegal qualifier while trying to split string
« Reply #8 on: June 27, 2019, 10:30:41 am »
But it does not work on my system.
Reading is an art it seems: I wrote backports.
You have to add backports to obtain and install 3.0.4. to Stretch.
See https://backports.debian.org/Instructions/ if you really do not understand how to do that!
It is quite essential Debian Linux knowledge and I - and others - already explained it many times on this forum....

Bottom line is you should not use 3.0.0 for new features as currently in the 3.0.4 manuals. Or you should not use those features.

BTW you would soon have the same problem with even more new features after 3.2.0 is released....
But then again, you can bootstrap an svn checkout of 3.2.0 since you have the right starting compiler after you added backports: 3.0.4..
Or use fpcdeluxe one time. For noobs that is the better option if you really do not understand backports.
The advantage of  backports over fpcdeluxe is that it is a true Debian supported distribution of Freepascal and built by Debian maintainers.
Debian purists consider it probably essential...But if you want to be really up-to-date, use fpcdeluxe and choose 3.2.0 if you do not use FPC commercially.
Adventurers like me also install trunk separately... 8-)
« Last Edit: June 27, 2019, 10:51:36 am by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1313
Re: Illegal qualifier while trying to split string
« Reply #9 on: June 27, 2019, 09:24:12 pm »
Fpcupdeluxe.  ;)

 

TinyPortal © 2005-2018