Re: [fpc-pascal] Multi-OS fp.ini and fp.cfg ?
On 08/16/2017 04:27 PM, Ched wrote: Dear FPCers, Would it be not too hard to make fp.ini and fp.cfg containing sections dedicated to one OS (bot read by others, but kept untouched) ? I'm working on my source codes both under Linux and under Windows ; when switching from one to the other, the files are slightly corrupted and should be deleted or copied from a backuped version... can you provide an example of this corruption? are you trying to share these files between OSes? -- NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list unless* *a signed and pre-paid contract is in effect with us.* ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Using other fpc installation
Alright, its compiling! It was wrong path in fpc.cfg. The DEB installation creates a directory structure under the fpc directory that matches this: /lib/fpc/3.1.1/units/$fpctarget Thanks again! On 08/16/2017 11:22 PM, Tomas Hajny wrote: On Wed, August 16, 2017 23:08, kapibara via fpc-pascal wrote: The old SVN version is now in play, so far so good! But then "Can't find unit system" happened: You need RTL (and other required units, e.g. from packages) compiled with that compiler version and provide path to it either using fpc.cfg, or -Fu command line parameter(s). Parameter -vt shows the path used by the compiler when trying to find the appropriate version of a compiled unit. Tomas The working fpc.cfg # Config file generated by fpcmkcfg on 16-8-17 - 23:52:00 # Example fpc.cfg for Free Pascal Compiler # # -- # Defines (preprocessor) # -- # # nested #IFNDEF, #IFDEF, #ENDIF, #ELSE, #DEFINE, #UNDEF are allowed # # -d is the same as #DEFINE # -u is the same as #UNDEF # # # Some examples (for switches see below, and the -? helppages) # # Try compiling with the -dRELEASE or -dDEBUG on the commandline # # For a release compile with optimizes and strip debuginfo #IFDEF RELEASE -O2 -Xs #WRITE Compiling Release Version #ENDIF # For a debug version compile with debuginfo and all codegeneration checks on #IFDEF DEBUG -gl -Crtoi #WRITE Compiling Debug Version #ENDIF # assembling #ifdef darwin # use pipes instead of temporary files for assembling -ap # path to Xcode 4.3+ utilities (no problem if it doesn't exist) -FD/Applications/Xcode.app/ Contents/Developer/usr/bin #endif # # Parsing switches # # Pascal language mode # -Mfpc free pascal dialect (default) # -Mobjfpc switch some Delphi 2 extensions on # -Mdelphi tries to be Delphi compatible # -Mtp tries to be TP/BP 7.0 compatible # -Mgpc tries to be gpc compatible # -Mmacpas tries to be compatible to the macintosh pascal dialects # # Turn on Object Pascal extensions by default #-Mobjfpc # Assembler reader mode # -Rdefault use default assembler # -Ratt read AT style assembler # -Rintelread Intel style assembler # # All assembler blocks are AT styled by default #-Ratt # Semantic checking # -S2same as -Mobjfpc # -Scsupports operators like C (*=,+=,/= and -=) # -Sainclude assertion code. # -Sdsame as -Mdelphi # -Se error options. is a combination of the following: # : compiler stops after errors (default is 1) # w : compiler stops also after warnings # n : compiler stops also after notes # h : compiler stops also after hints # -Sgallow LABEL and GOTO # -ShUse ansistrings # -Sisupport C++ styled INLINE # -Skload fpcylix unit # -SI set interface style to # -SIcomCOM compatible interface (default) # -SIcorba CORBA compatible interface # -Smsupport macros like C (global) # -Sosame as -Mtp # -Spsame as -Mgpc # -Ssconstructor name must be init (destructor must be done) # -Sxenable exception keywords (default in Delphi/ObjFPC modes) # # Allow goto, inline, C-operators, C-vars -Sgic # --- # Code generation # --- # Uncomment the next line if you always want static/dynamic units by default # (can be overruled with -CD, -CS at the commandline) #-CS #-CD # Set the default heapsize to 8Mb #-Ch800 # Set default codegeneration checks (iocheck, overflow, range, stack) #-Ci #-Co #-Cr #-Ct # Optimizer switches # -Osgenerate smaller code # -Oa=N set alignment to N # -O1level 1 optimizations (quick optimizations, debuggable) # -O2level 2 optimizations (-O1 + optimizations which make debugging more difficult) # -O3level 3 optimizations (-O2 + optimizations which also may make the program slower rather than faster) # -Oo switch on optimalization x. See fpc -i for possible values # -OoNO switch off optimalization x. See fpc -i for possible values # -Op set target cpu for optimizing, see fpc -i for possible values #ifdef darwin #ifdef cpui386 -Cppentiumm -Oppentiumm #endif #endif # --- # Set Filenames and Paths # --- # Both slashes and backslashes are allowed in paths # path to the messagefile, not necessary anymore but can be used to override # the default language #-Fr/home/roger/fpc/fpc_svn/lib/fpc/3.1.1/msg/errore.msg #-Fr/home/roger/fpc/fpc_svn/lib/fpc/3.1.1/msg/errorn.msg #-Fr/home/roger/fpc/fpc_svn/lib/fpc/3.1.1/msg/errores.msg #-Fr/home/roger/fpc/fpc_svn/lib/fpc/3.1.1/msg/errord.msg #-Fr/home/roger/fpc/fpc_svn/lib/fpc/3.1.1/msg/errorr.msg # searchpath for units and other system dependent things
Re: [fpc-pascal] Using other fpc installation
To be sure fpc.cfg is found I started the compilation from fpc's bin directory where the fpc.cfg is located. roger@bikupan:~/fpc/fpc_svn/ bin$ ./fpc /home/roger/fpc/fptest_working/fptest.pas Free Pascal Compiler version 3.1.1 [2017/08/16] for x86_64 Copyright (c) 1993-2015 by Florian Klaempfl and others Target OS: Linux for x86-64 Compiling /home/roger/fpc/fptest_working/fptest.pas Fatal: Can't find unit system used by fptest Fatal: Compilation aborted Error: /home/roger/fpc/fpc_svn/compiler/ppcx64 returned an error exitcode Here is the fpc.cfg # # Config file generated by fpcmkcfg on 16-8-17 - 21:46:51 # Example fpc.cfg for Free Pascal Compiler # # -- # Defines (preprocessor) # -- # # nested #IFNDEF, #IFDEF, #ENDIF, #ELSE, #DEFINE, #UNDEF are allowed # # -d is the same as #DEFINE # -u is the same as #UNDEF # # # Some examples (for switches see below, and the -? helppages) # # Try compiling with the -dRELEASE or -dDEBUG on the commandline # # For a release compile with optimizes and strip debuginfo #IFDEF RELEASE -O2 -Xs #WRITE Compiling Release Version #ENDIF # For a debug version compile with debuginfo and all codegeneration checks on #IFDEF DEBUG -gl -Crtoi #WRITE Compiling Debug Version #ENDIF # assembling #ifdef darwin # use pipes instead of temporary files for assembling -ap # path to Xcode 4.3+ utilities (no problem if it doesn't exist) -FD/Applications/Xcode.app/ Contents/Developer/usr/bin #endif # # Parsing switches # # Pascal language mode # -Mfpc free pascal dialect (default) # -Mobjfpc switch some Delphi 2 extensions on # -Mdelphi tries to be Delphi compatible # -Mtp tries to be TP/BP 7.0 compatible # -Mgpc tries to be gpc compatible # -Mmacpas tries to be compatible to the macintosh pascal dialects # # Turn on Object Pascal extensions by default #-Mobjfpc # Assembler reader mode # -Rdefault use default assembler # -Ratt read AT style assembler # -Rintelread Intel style assembler # # All assembler blocks are AT styled by default #-Ratt # Semantic checking # -S2same as -Mobjfpc # -Scsupports operators like C (*=,+=,/= and -=) # -Sainclude assertion code. # -Sdsame as -Mdelphi # -Se error options. is a combination of the following: # : compiler stops after errors (default is 1) # w : compiler stops also after warnings # n : compiler stops also after notes # h : compiler stops also after hints # -Sgallow LABEL and GOTO # -ShUse ansistrings # -Sisupport C++ styled INLINE # -Skload fpcylix unit # -SI set interface style to # -SIcomCOM compatible interface (default) # -SIcorba CORBA compatible interface # -Smsupport macros like C (global) # -Sosame as -Mtp # -Spsame as -Mgpc # -Ssconstructor name must be init (destructor must be done) # -Sxenable exception keywords (default in Delphi/ObjFPC modes) # # Allow goto, inline, C-operators, C-vars -Sgic # --- # Code generation # --- # Uncomment the next line if you always want static/dynamic units by default # (can be overruled with -CD, -CS at the commandline) #-CS #-CD # Set the default heapsize to 8Mb #-Ch800 # Set default codegeneration checks (iocheck, overflow, range, stack) #-Ci #-Co #-Cr #-Ct # Optimizer switches # -Osgenerate smaller code # -Oa=N set alignment to N # -O1level 1 optimizations (quick optimizations, debuggable) # -O2level 2 optimizations (-O1 + optimizations which make debugging more difficult) # -O3level 3 optimizations (-O2 + optimizations which also may make the program slower rather than faster) # -Oo switch on optimalization x. See fpc -i for possible values # -OoNO switch off optimalization x. See fpc -i for possible values # -Op set target cpu for optimizing, see fpc -i for possible values #ifdef darwin #ifdef cpui386 -Cppentiumm -Oppentiumm #endif #endif # --- # Set Filenames and Paths # --- # Both slashes and backslashes are allowed in paths # path to the messagefile, not necessary anymore but can be used to override # the default language #-Fr/home/roger/fpc/fpc_svn/msg/errore.msg #-Fr/home/roger/fpc/fpc_svn/msg/errorn.msg #-Fr/home/roger/fpc/fpc_svn/msg/errores.msg #-Fr/home/roger/fpc/fpc_svn/msg/errord.msg #-Fr/home/roger/fpc/fpc_svn/msg/errorr.msg # searchpath for units and other system dependent things -Fu/home/roger/fpc/fpc_svn/units/$fpctarget -Fu/home/roger/fpc/fpc_svn/units/$fpctarget/* -Fu/home/roger/fpc/fpc_svn/units/$fpctarget/rtl -Fu/home/roger/fpc/pascalscript/Source #IFDEF FPCAPACHE_1_3 -Fu/home/roger/fpc/fpc_svn/units/$fpctarget/httpd13/ #ELSE #IFDEF
Re: [fpc-pascal] Using other fpc installation
On Wed, August 16, 2017 23:08, kapibara via fpc-pascal wrote: > The old SVN version is now in play, so far so good! But then "Can't find > unit system" happened: You need RTL (and other required units, e.g. from packages) compiled with that compiler version and provide path to it either using fpc.cfg, or -Fu command line parameter(s). Parameter -vt shows the path used by the compiler when trying to find the appropriate version of a compiled unit. Tomas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Using other fpc installation
The old SVN version is now in play, so far so good! But then "Can't find unit system" happened: roger@bikupan:~/fpc/fptest_working$ fpc fptest.pas Free Pascal Compiler version 3.1.1 [2017/08/16] for x86_64 Copyright (c) 1993-2015 by Florian Klaempfl and others Target OS: Linux for x86-64 Compiling fptest.pas Fatal: Can't find unit system used by fptest Fatal: Compilation aborted Error: /home/roger/fpc/fpc_svn/compiler/ppcx64 returned an error exitcode Before that I had changed the path: roger@bikupan:~/fpc/fptest_working$ PATH=/home/roger/fpc/fpc_svn/bin:/home/roger/fpc/fpc_svn/compiler:/usr/local/bin:/usr/bin:/bin roger@bikupan:~/fpc/fptest_working$ export PATH=/home/roger/fpc/fpc_svn/bin:/home/roger/fpc/fpc_svn/compiler:/usr/local/bin:/usr/bin:/bin roger@bikupan:~/fpc/fptest_working$ which fpc /home/roger/fpc/fpc_svn/bin/fpc On 08/16/2017 10:27 PM, Tomas Hajny wrote: On Wed, August 16, 2017 22:16, kapibara via fpc-pascal wrote: Ah, so FP has no versions other than the official releases then? (2.6.0, 2.6.2, 2.6.4 and so on) Why doesn't FP use the same compiler revision as the SVN sources it comes with? Because the fp executable is compiled at the same time as fpc? It uses the sources from which it has been compiled (the same way fpc does too). Fp is a separate make target. It may be part of a snapshot, and it may be compiled from SVN sources by you as well (it has some additional prerequisites if you want to have the debugger integrated, and it requires some additional FPC packages compiled first, but nothing special apart from that). Alright then, I'll try instead: fpc test.pas Btw, why have fpc and also ppcx64? Does fpc call ppcx64? Yes - or another compiler binary if (cross-)compiling for a different CPU/platform (e.g. ppc386, ppcarm, ppcjvm, etc.). Tomas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Using other fpc installation
You're right, now I fixed that and "which fpc" reports the SVN version! On 08/16/2017 10:15 PM, Tomas Hajny wrote: On Wed, August 16, 2017 21:15, kapibara via fpc-pascal wrote: I meant to say that system fpc is put AFTER the SVN fpc in the path. Due to the missing slash at the beginning of the PATH value? ;-) Obviously, that only answers the reason of the 'which fpc' command, whereas the compiler version used when compiling from the IDE has already been answered by Marco Tomas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Using other fpc installation
On Wed, August 16, 2017 22:16, kapibara via fpc-pascal wrote: > Ah, so FP has no versions other than the official releases then? (2.6.0, > 2.6.2, 2.6.4 and so on) > > Why doesn't FP use the same compiler revision as the SVN sources it > comes with? Because the fp executable is compiled at the same time as fpc? It uses the sources from which it has been compiled (the same way fpc does too). Fp is a separate make target. It may be part of a snapshot, and it may be compiled from SVN sources by you as well (it has some additional prerequisites if you want to have the debugger integrated, and it requires some additional FPC packages compiled first, but nothing special apart from that). > Alright then, I'll try instead: > > fpc test.pas > > > Btw, why have fpc and also ppcx64? Does fpc call ppcx64? Yes - or another compiler binary if (cross-)compiling for a different CPU/platform (e.g. ppc386, ppcarm, ppcjvm, etc.). Tomas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Multi-OS fp.ini and fp.cfg ?
Dear FPCers, Would it be not too hard to make fp.ini and fp.cfg containing sections dedicated to one OS (bot read by others, but kept untouched) ? I'm working on my source codes both under Linux and under Windows ; when switching from one to the other, the files are slightly corrupted and should be deleted or copied from a backuped version... Cheers, Ched' ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Using other fpc installation
On Wed, August 16, 2017 21:15, kapibara via fpc-pascal wrote: > I meant to say that system fpc is put AFTER the SVN fpc in the path. Due to the missing slash at the beginning of the PATH value? ;-) Obviously, that only answers the reason of the 'which fpc' command, whereas the compiler version used when compiling from the IDE has already been answered by Marco Tomas > > On 08/16/2017 09:09 PM, kapibara wrote: >> PATH=home/roger/fpc/fpc_svn/bin:/home/roger/fpc/fpc_svn/compiler:/usr/local/bin:/usr/bin:/bin >> >> export >> PATH=home/roger/fpc/fpc_svn/bin:/home/roger/fpc/fpc_svn/compiler:/usr/local/bin:/usr/bin:/bin >> >> Despite the path, if I run "which fpc" from commandline I get >> "usr/bin/fpc" anyway. How is that possible when that fpc is not in the >> path? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Using other fpc installation
Ah, so FP has no versions other than the official releases then? (2.6.0, 2.6.2, 2.6.4 and so on) Why doesn't FP use the same compiler revision as the SVN sources it comes with? Because the fp executable is compiled at the same time as fpc? Alright then, I'll try instead: fpc test.pas Btw, why have fpc and also ppcx64? Does fpc call ppcx64? On 08/16/2017 09:45 PM, Marco van de Voort wrote: In our previous episode, kapibara via fpc-pascal said: I want to use the fp editor to run the test, but it seems as the "systemic" 2.6.4 is being used for compiling instead of the SVN version. Then you use a 2.6.4 FP. FP does not call the compiler, it has an own version of it internally. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Using other fpc installation
In our previous episode, kapibara via fpc-pascal said: > > I want to use the fp editor to run the test, but it seems as the > "systemic" 2.6.4 is being used for compiling instead of the SVN version. Then you use a 2.6.4 FP. FP does not call the compiler, it has an own version of it internally. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Using other fpc installation
I meant to say that system fpc is put AFTER the SVN fpc in the path. On 08/16/2017 09:09 PM, kapibara wrote: PATH=home/roger/fpc/fpc_svn/bin:/home/roger/fpc/fpc_svn/compiler:/usr/local/bin:/usr/bin:/bin export PATH=home/roger/fpc/fpc_svn/bin:/home/roger/fpc/fpc_svn/compiler:/usr/local/bin:/usr/bin:/bin Despite the path, if I run "which fpc" from commandline I get "usr/bin/fpc" anyway. How is that possible when that fpc is not in the path? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Using other fpc installation
For debugging reasons I have installed fpc 2.6.4 on Debian so I can compile some old SVN revisions, number 32959 for example. I want to use the fp editor to run the test, but it seems as the "systemic" 2.6.4 is being used for compiling instead of the SVN version. The bug doesn't show up in 2.6.4, only in some 2.7.1 revisions and later. How can I make sure the SVN version is used and not the systems 2.6.4? The following paths was added to fp editor in Options->Units: /home/roger/fpc/fpc_svn/lib/fpc/2.7.1/unitsx86_64-linux /home/roger/fpc/fpc_svn/lib/fpc/2.7.1/unitsx86_64-linux/* /home/roger/fpc/fpc_svn/lib/fpc/2.7.1/unitsx86_64-linux/rtl Also, both the directories of fpc and ppcx64 was added to the path from commandline: PATH=home/roger/fpc/fpc_svn/bin:/home/roger/fpc/fpc_svn/compiler:/usr/local/bin:/usr/bin:/bin export PATH=home/roger/fpc/fpc_svn/bin:/home/roger/fpc/fpc_svn/compiler:/usr/local/bin:/usr/bin:/bin Despite the path, if I run "which fpc" from commandline I get "usr/bin/fpc" anyway. How is that possible when that fpc is not in the path? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Defining sonames?
On 2017-08-16 18:14, Sven Barth via fpc-pascal wrote: Wrong. Take an empty program that includes the X unit: In private I emailed Fred the following URL - it explains in plain English what is required and what really happens in the ELF binary format and such. Fred finally understood. On a side note: I learned something new too. :) The information in your last reply was spot. Here is the URL I send Fred. For anybody else, read the question and the first two answers - that should give you all the information anybody needs to understand the process. https://unix.stackexchange.com/questions/475/how-do-so-shared-object-numbers-work Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Defining sonames?
On 14.08.2017 15:19, Fred van Stappen wrote: > A concrete example. > > A Linux/FreeBSD fpc release was compiled using the pascal headers for > libX11.so.6 and using symlink libX11.so >> libX11.so.6.0.8. > > This release was installed on a system (with libX11-dev too to make it > work). > > If, some time later, a system-update was done to the brand new version > libX11.so.7.0.1, > this will update also libX11-dev >> libX11.so >> libX11.so.7.0.1. > > And using fpc, there will be a error because libX11.so does not point to > a libX11.so.6 version. Wrong. Take an empty program that includes the X unit: === code begin === program tsoname; uses X; begin end. === code end === The X unit simply contains a "$linklib x11" which is equivalent to importing specific functions using "external 'x11' name ...". My system looks like this: === listing begin === lrwxrwxrwx 1 root root 15 27. Feb 17:54 /usr/lib/libX11.so -> libX11.so.6.3.0 lrwxrwxrwx 1 root root 15 27. Feb 17:54 /usr/lib/libX11.so.6 -> libX11.so.6.3.0 -rwxr-xr-x 1 root root 1306096 27. Feb 17:54 /usr/lib/libX11.so.6.3.0 === listing end === And the resulting binary links this (objdump -x output) === listing begin === (...) Dynamic Section: NEEDED libX11.so.6 NEEDED libc.so.6 (...) === listing end === As you can see the program will work correctly as long as the libX11.so.6 file exists (even though that is a symlink itself, but the X11 project guarantees that different libX11.so.6.x.y are compatible to eachother), because the linker picks the SONAME that is set inside the binary. And the libX11.so.6 symlink is part of the non-devel package. > But if the same Linux/FreeBSD fpc release was compiled using symlink > libX11.so.6, there, no problem, it will use the still installed symlink > libX11.so.6. > > Or, if libX11.so.6 is no more installed, fpc could say "libX11.so.6 not > found" (because fpc knows now what version of libX11 he needs). Neither FPC nor the linker know anything about library versions. They only know the filenames and the SONAMEs. If either can't find the filename it needs than though luck. And the SONAME is the one that's used for the real lookup, but the linker needs the file for that. > Other thing. > > If your way *is* the way to do, why fpc does not use libc6-dev (that > will create symlink libc.so) but uses LIBC_SO = 'libc.so.6' instead of > LIBC_SO = 'libc.so' ? And did you even look at the code? 1. the libc unit is deprecated and only exists for Kylix compatibility 2. the LIBC_SO constant is used nowhere (the library constant is "clib" and has the value 'c') The only other use of "libc.so.6" is in iconvenc_dyn.pas, but that is because it is loading the library dynamically and there the real file *must* be used as the development symlink might not exist after all. Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TStringList - Strange quotation mark handling
Hi, very stupid defaults indeed. I just had a bug last week, because I was using TStringList as map and forgot to change it to case-sensitive Cheers, Benito Am 16.08.2017 um 15:48 schrieb Gabor Boros: 2017. 08. 16. 15:21 keltezéssel, Michael Van Canneyt írta: Because the quotes must be the first and last character of each string (or "cell"). As noted in another reply, set the quote character to something unused, and it will disable (or circumvent) quoting altogether. SL2.QuoteChar:=#0; solved my problem. But strange if the TStringList think from a starting " the string is quoted. For example if data.cvs contains "abc|89|0 I got the next result with my example program (without QuoteChar trick): 0 * abc|89|0 Gabor ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TStringList - Strange quotation mark handling
On 2017-08-16 14:48, Gabor Boros wrote: SL2.QuoteChar:=#0; solved my problem. But strange if the TStringList think from a starting " the string is quoted. For example if data.cvs contains "abc|89|0 I got the next result with my example program (without QuoteChar trick): 0 * abc|89|0 Try using tiOPF's tiUtils.pas unit. More specifically the tiNumToken() and tiToken() functions. No quatechar tricks and such are needed. These function can also be used independently without needing anything else from the tiOPF framework. https://github.com/graemeg/tiopf/blob/tiopf2/Core/tiUtils.pas#L783..L837 Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TStringList - Strange quotation mark handling
2017. 08. 16. 15:21 keltezéssel, Michael Van Canneyt írta: Because the quotes must be the first and last character of each string (or "cell"). As noted in another reply, set the quote character to something unused, and it will disable (or circumvent) quoting altogether. SL2.QuoteChar:=#0; solved my problem. But strange if the TStringList think from a starting " the string is quoted. For example if data.cvs contains "abc|89|0 I got the next result with my example program (without QuoteChar trick): 0 * abc|89|0 Gabor ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TStringList - Strange quotation mark handling
2017. 08. 16. 15:15 keltezéssel, Kevin Jesshope írta: Setting the quotechar to something impossible (linefeed, #0 etc) stops the quote processing. SL2.QuoteChar:=#0; solved my problem. Thank you! Gabor ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TStringList - Strange quotation mark handling
On Wed, 16 Aug 2017, Gabor Boros wrote: Hi All, With the attached example program and data.csv I got the next result: 0 * 84392 1 * asfds 2 * hytr 3 * 43421454 4 * O 5 * fdsfds 6 * 654645645 "O" fdsfsd 7 * hgfgfedw 8 * fg 9 * 321.544 10 * 89 11 * 0 "O" fdsfds - broken into two parts which is bad from my POV. See 4 * O and 5 * fdsfds. Why? Because the quotes must be the first and last character of each string (or "cell"). As noted in another reply, set the quote character to something unused, and it will disable (or circumvent) quoting altogether. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TStringList - Strange quotation mark handling
Setting the quotechar to something impossible (linefeed, #0 etc) stops the quote processing. SL2.QuoteChar:=#10; results in 0 * 84392 1 * asfds 2 * hytr 3 * 43421454 4 * "O" fdsfds 5 * 654645645 "O" fdsfsd 6 * hgfgfedw 7 * fg 8 * 321.544 9 * 89 10 * 0 Regards Kevin Jesshope - In Touch Computer Support Supporting Aberfoyle Hub R-7 and Happy Valley Primary Schools On Wed, Aug 16, 2017 at 9:58 PM, Gabor Boroswrote: > Hi All, > > With the attached example program and data.csv I got the next result: > > 0 * 84392 > 1 * asfds > 2 * hytr > 3 * 43421454 > 4 * O > 5 * fdsfds > 6 * 654645645 "O" fdsfsd > 7 * hgfgfedw > 8 * fg > 9 * 321.544 > 10 * 89 > 11 * 0 > > > "O" fdsfds - broken into two parts which is bad from my POV. See 4 * O and > 5 * fdsfds. Why? > > Gabor > > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal > ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] TStringList - Strange quotation mark handling
Hi All, With the attached example program and data.csv I got the next result: 0 * 84392 1 * asfds 2 * hytr 3 * 43421454 4 * O 5 * fdsfds 6 * 654645645 "O" fdsfsd 7 * hgfgfedw 8 * fg 9 * 321.544 10 * 89 11 * 0 "O" fdsfds - broken into two parts which is bad from my POV. See 4 * O and 5 * fdsfds. Why? Gabor 84392|asfds|hytr|43421454|"O" fdsfds|654645645 "O" fdsfsd|hgfgfedw|fg|321.544|89|0program Project1; uses Classes, sysutils; var SL,SL2:TStringList; i:integer; begin SL:=TStringList.Create; SL.LoadFromFile('data.csv'); SL2:=TStringList.Create; SL2.StrictDelimiter:=True; SL2.Delimiter:='|'; SL2.DelimitedText:=SL[0]; for i:=0 to SL2.Count-1 do WriteLn(IntToStr(i)+' * '+SL2[i]); ReadLn; end.___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Best way to insert bytes into a TBytes variable?
On Wed, 16 Aug 2017, Graeme Geldenhuys wrote: On 2017-07-25 09:54, Bo Berglund wrote: buffer in an old application, so I need to write efficient replacements for certain string functions (Delete, Insert, Copy etc). Now I am wondering if there is a better way to do the Insert() command than this: Reading that... All I can think of is the 1000's of Linked-List implementations I had to implement when I was studying Turbo Pascal all that years ago. Delete, Insert and Copy would be so easy to do. :-) What does TBytes use internally to store its data? It is an array. Hence a continuous block of memory. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal