Recent

Author Topic: split string using TstringList  (Read 7179 times)

BubikolRamios

  • Sr. Member
  • ****
  • Posts: 267
split string using TstringList
« on: July 29, 2016, 02:03:01 pm »
First result looks bad. Expected 1,2.Why is that ?
The second is OK
Code: Pascal  [Select][+][-]
  1. var
  2. T: String;
  3. sl: TstringList;
  4. begin
  5.    sl := TstringList.Create;
  6.    sl.StrictDelimiter:=true;
  7.    sl.LineBreak:='","';
  8.    sl.Text:= '1","2';
  9.    SynEdit1.Lines.Add(sl.CommaText);//-->1
  10.    sl.Text:= '11","22';
  11.    SynEdit1.Lines.Add(sl.CommaText);//-->11,22
  12.  
  13. end;  
  14.  
« Last Edit: July 29, 2016, 02:15:31 pm by BubikolRamios »
lazarus 3.2-fpc-3.2.2-win32/win64

rvk

  • Hero Member
  • *****
  • Posts: 6169
Re: split string using TstringList
« Reply #1 on: July 29, 2016, 03:18:43 pm »
It was a bug in TStringList.
The last line/item wasn't included with LineBreak.
See http://bugs.freepascal.org/view.php?id=29150

It's fixed now in FPC 3.1.1 (trunk)
I think the fix will be in the upcoming FPC 3.0.2 (and following 1.6.2).

Thaddy

  • Hero Member
  • *****
  • Posts: 14377
  • Sensorship about opinions does not belong here.
Re: split string using TstringList
« Reply #2 on: July 29, 2016, 03:32:48 pm »
Yes that's correct. I was wondering why I could not replicate it.
This complete program works compiled with trunk:
Code: Pascal  [Select][+][-]
  1. program testdelim;
  2. {$mode objfpc}
  3. uses classes;
  4. var
  5. T: String;
  6. sl: TstringList;
  7. begin
  8.    sl := TstringList.Create;
  9.    sl.StrictDelimiter:=true;
  10.    sl.LineBreak:='","';
  11.    sl.Text:= '1","2';
  12.    writeln(sl.CommaText);//-->1,2
  13.    sl.Text:= '11","22';
  14.    writeln(sl.CommaText);//-->11,22
  15. end.  
  16.  
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

BubikolRamios

  • Sr. Member
  • ****
  • Posts: 267
Re: split string using TstringList
« Reply #3 on: July 30, 2016, 06:27:19 am »
 FPC 3.1.1 (trunk)

Where to get it, how to install ? Can't find anything ...
lazarus 3.2-fpc-3.2.2-win32/win64

Thaddy

  • Hero Member
  • *****
  • Posts: 14377
  • Sensorship about opinions does not belong here.
Re: split string using TstringList
« Reply #4 on: July 30, 2016, 07:29:56 am »
You have to build it from source. There are no installers for it because it changes daily.

See http://www.freepascal.org/develop.var and the wiki on how to do that.

You may want to use fpcup/fpclazup from https://github.com/LongDirtyAnimAlf/Reiniero-fpcup for that.
Or one of the scripts on getlazarus.org.

Note both options are THIRD PARTY and success may vary.

Imho it is easier to learn to build trunk from source once and forget about it. But they can be life savers if there is no suitable starting compiler.

Another option for fpc:
- Download the daily snapshot
- Unpack in a new directory, say name it "fpctrunk"
- goto "fpctrunk"
- run: make clean all install

This only works if you already have fpc 3.0.o installed.
Lazarus is similar but I don't know the exact steps apart from the last (I always checkout the sources with svn)
- create a new directory, say, "laztrunk"
- goto "laztrunk"
- run: make bigide
« Last Edit: July 30, 2016, 07:45:19 am by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

BubikolRamios

  • Sr. Member
  • ****
  • Posts: 267
Re: split string using TstringList
« Reply #5 on: July 30, 2016, 12:42:55 pm »
So, I'm fishing in dark here.
If I go and download from upper link http://www.freepascal.org/develop.var fpc-3.1.1.x86_64-win64.zip
the directory structure there is almost same as on lazarus fpc directory, + bin/x86_64-win64 drectory where in lazarus fpc original instalation is fpc.exe and stuff, is missing.

My best guess ppcrossx64.exe that comes packed in zip should do the magic and make fpc.exe and all the rest, right ?

Anyone with any tip how to use that ?

« Last Edit: July 30, 2016, 12:47:41 pm by BubikolRamios »
lazarus 3.2-fpc-3.2.2-win32/win64

kapibara

  • Hero Member
  • *****
  • Posts: 610
Re: split string using TstringList
« Reply #6 on: July 31, 2016, 12:24:29 am »
FPC development version is compiled with the last released version. Building trunk can be challenging, I tried my best to write a step by step guide two years ago:

http://forum.lazarus.freepascal.org/index.php/topic,24045.msg144389.html#msg144389

I use 32 bit FPC and Lazarus even if Windows is 64 bit, because FPC 32 compiles somewhat faster than FPC 64 on Windows.
« Last Edit: July 31, 2016, 12:45:25 am by kapibara »
Lazarus trunk / fpc 3.2.2 / Kubuntu 22.04 - 64 bit

Handoko

  • Hero Member
  • *****
  • Posts: 5158
  • My goal: build my own game engine using Lazarus
Re: split string using TstringList
« Reply #7 on: July 31, 2016, 04:45:20 am »
Wow! I thought everything that is 64-bit always better and faster than the 32-bit version. Updating my brain now.

rvk

  • Hero Member
  • *****
  • Posts: 6169
Re: split string using TstringList
« Reply #8 on: July 31, 2016, 06:13:32 am »
... Building trunk can be challenging
And building 64bit is especially challenging. As far as I know there is no official FPC 3.0 64bit release so you would (officially) need 2.6.4 to build 3.0 with which you can build 3.1.1. Yeah, real "easy".

Easiest is fpc(laz)up. It won't build it the official way (I think it uses 2.6.4) but at least it works. Unless one of the experts can give a clear description how to build 3.1.1 64 bit officially. (They all say you need the last official release but since I couldn't find FPC 3.0 64bit it's really not that easy as they say)

kapibara

  • Hero Member
  • *****
  • Posts: 610
Re: split string using TstringList
« Reply #9 on: July 31, 2016, 07:40:59 am »
@rvk The 64bit version of FPC 3.0.0 used to come with Lazarus 1.6 (64bit) for Windows. Should still be the case?

I'm on Linux, but someone could check it:
https://sourceforge.net/projects/lazarus/files/Lazarus%20Windows%2064%20bits/Lazarus%201.6/
Lazarus trunk / fpc 3.2.2 / Kubuntu 22.04 - 64 bit

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1739
Re: split string using TstringList
« Reply #10 on: July 31, 2016, 07:44:08 am »
The bug was fixed in FPC revision 32765

So, you could try (with fpclazup, for Windows):

Code: [Select]
fpclazup.exe --installdir="C:\MyFPCFix\" --fpcURL="trunk" --lazURL="trunk" --getfullrepo --fpcrevision="32765" --verbose

rvk

  • Hero Member
  • *****
  • Posts: 6169
Re: split string using TstringList
« Reply #11 on: July 31, 2016, 10:26:12 am »
@rvk The 64bit version of FPC 3.0.0 used to come with Lazarus 1.6 (64bit) for Windows. Should still be the case?
The version that comes with Lazarus is also not considered an "official" release by the FPC developers. (Plus I'm not going to install a complete Lazarus version just to get FPC 3.0, to install Lazarus)

The fact is that this is just not that easy. That they don't provide a bootstrap compiler... Ok, that I can understand (barely) but no release for 64bit... At this point there is no easy way to compile FPC trunk "officially" from scratch without extra steps.

 

TinyPortal © 2005-2018