Hi
I'm not entirely sure I'd use 'Copy', rather I think I'd make a function / procedure with a small simple 'Finite StateMachine' (parser) to pick the /fields/ in every line...
Just my 2 cent's worth.
Regards Benny
QuoteNo idea what bash has to do with fileio and copy...
Have I ever said that it has anything to do with "copy"? You place words in my mouth.
Maybe read my post before making such claims ?
I said that I might have to use bash through shell commands as it is way-way more powerful than pascal fileio, but definitely slower which is the only drawback..
As speed is not a problem with this program's file io, bash would be a better choice as you dont have to program any Functions just to read something from a file with endless debug as is the case with Pascal.
Pascal/Delphi has been my main programming language my entire life, but the fileio in Pascal is generally horrendous. Same with Fortran.
If there is one thing the dreaded C and it's derivatives did right, is the great fileio they have.
I however just want to see if I cannot keep it in Pascal.
How I would do (because I love regular expressions):
find |grep -i reg |grep -i ppu
./3.2.2/units/i386-linux/fcl-fpcunit/testregistry.ppu
./3.2.2/units/i386-linux/regexpr/uregexpr.ppu
./3.2.2/units/i386-linux/regexpr/oldregexpr.ppu
./3.2.2/units/i386-linux/regexpr/regexpr.ppu
./3.2.2/units/i386-linux/regexpr/regex.ppu
./3.2.2/units/i386-linux/fcl-registry/xmlreg.ppu
./3.2.2/units/i386-linux/fcl-registry/registry.ppu
./3.2.2/units/i386-linux/fcl-db/fpddregstd.ppu
./3.2.2/units/i386-linux/googleapi/googleserviceregistry.ppu
./3.2.2/units/x86_64-linux/fcl-fpcunit/testregistry.ppu
./3.2.2/units/x86_64-linux/regexpr/uregexpr.ppu
./3.2.2/units/x86_64-linux/regexpr/oldregexpr.ppu
./3.2.2/units/x86_64-linux/regexpr/regexpr.ppu
./3.2.2/units/x86_64-linux/regexpr/regex.ppu
./3.2.2/units/x86_64-linux/fcl-registry/xmlreg.ppu
./3.2.2/units/x86_64-linux/fcl-registry/registry.ppu
./3.2.2/units/x86_64-linux/fcl-db/fpddregstd.ppu
./3.2.2/units/x86_64-linux/googleapi/googleserviceregistry.ppu
./2.0.4/units/i386-linux/regexpr/regexpr.ppu
./2.0.4/units/i386-linux/fcl/xmlreg.ppu
./2.0.4/units/i386-linux/fcl/testregistry.ppu
./2.0.4/units/i386-linux/fcl/registry.ppu
user@lt2:
$ ppc386_3.2.2 test_fileio.pas
Free Pascal Compiler version 3.2.2 [2021/05/16] for i386
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Linux for i386
Compiling test_fileio.pas
Compiling math.pas
Compiling regexpr.pas
PPU Loading /usr/lib/fpc/3.2.2/units/i386-linux/rtl/types.ppu
PPU Source: types.pp not available
PPU Source: typshrdh.inc not available
PPU Source: typshrd.inc not available
Recompiling Types, checksum changed for math.ppu {impl}
types.pp(138,10) Fatal: Can't find unit Types used by Classes
Fatal: Compilation aborted
user@t2:
$ ppcx64 test_fileio.pas
Free Pascal Compiler version 3.2.2 [2021/05/16] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling test_fileio.pas
Compiling regexpr.pas
Compiling math.pas
PPU Loading /usr/lib/fpc/3.2.2/units/x86_64-linux/rtl/types.ppu
PPU Source: types.pp not available
PPU Source: typshrdh.inc not available
PPU Source: typshrd.inc not available
Recompiling Types, checksum changed for math.ppu {impl}
types.pp(138,10) Fatal: Can't find unit Types used by Classes
Fatal: Compilation aborted
ppc386_3.2.2 test_fileio.pas
Free Pascal Compiler version 3.2.2 [2021/05/16] for i386
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Linux for i386
Compiling test_fileio.pas
Compiling regexpr.pas
Compiling types.pp
types.pp(101,4) Fatal: Cannot open include file "typshrdh.inc"
Fatal: Compilation aborted
Thank you for your example. I will try it out and see if I can make it work for my purposes.
You are welcome. But I think the example by TRon (https://forum.lazarus.freepascal.org/index.php/topic,70496.msg549581.html#msg549581) is better. :)Although my example is perhaps easier to read it has the drawback that it reads the whole file in memory before processing. In that regards your example is far better for larger files and/or lower row numbers.
Thank you for your example. I will try it out and see if I can make it work for my purposes.
You are welcome. But I think the example by TRon (https://forum.lazarus.freepascal.org/index.php/topic,70496.msg549581.html#msg549581) is better. :)
To answer your question, my example uses the standard RegExpr unit shipped with FPC: you don't have to install anything.
Hi
I'm not entirely sure I'd use 'Copy', rather I think I'd make a function / procedure
Regards Benny