Re: [Lazarus] LongString does not work?

2013-03-04 Thread Luca Olivetti
Al 03/03/13 21:52, En/na Sven Barth ha escrit: On 03.03.2013 20:32, Luca Olivetti wrote: Al 03/03/13 14:34, En/na Sven Barth ha escrit: For packed there is the guarantee though that the layout will stay the same. Are you sure? Does the same guarantee apply to bitpacked? Lately I've become

Re: [Lazarus] LongString does not work?

2013-03-04 Thread Sven Barth
Am 04.03.2013 17:10, schrieb Luca Olivetti: Al 03/03/13 21:52, En/na Sven Barth ha escrit: On 03.03.2013 20:32, Luca Olivetti wrote: Al 03/03/13 14:34, En/na Sven Barth ha escrit: For packed there is the guarantee though that the layout will stay the same. Are you sure? Does the same

[Lazarus] LongString does not work?

2013-03-03 Thread Xiangrong Fang
Hi All, This does not work: TConfiguration = record DataFolder: string[MaxPathLen]; end Error: string length must be a value from 1 to 255 I already have this on the top of my uinit file: {$mode objfpc}{$H+}{$LONGSTRINGS ON} Working with Lazarus 1.0.6/FPC2.6.0 on Linux 3.5/x86_64 Any

Re: [Lazarus] LongString does not work?

2013-03-03 Thread Sven Barth
On 03.03.2013 09:35, Xiangrong Fang wrote: Hi All, This does not work: TConfiguration = record DataFolder: string[MaxPathLen]; end Error: string length must be a value from 1 to 255 I already have this on the top of my uinit file: {$mode objfpc}{$H+}{$LONGSTRINGS ON} Working with

Re: [Lazarus] LongString does not work?

2013-03-03 Thread Xiangrong Fang
Ok, My purpose is to write the record into stream, so I cannot use variable length. Now I use an array [0..MaxPathLen] of Char. 2013/3/3 Sven Barth pascaldra...@googlemail.com On 03.03.2013 09:35, Xiangrong Fang wrote: Hi All, This does not work: TConfiguration = record

Re: [Lazarus] LongString does not work?

2013-03-03 Thread Sven Barth
On 03.03.2013 10:57, Xiangrong Fang wrote: Ok, My purpose is to write the record into stream, so I cannot use variable length. Now I use an array [0..MaxPathLen] of Char. If you want to write a complete record to stream (and not write it's elements manually) you should declare your record as

Re: [Lazarus] LongString does not work?

2013-03-03 Thread Xiangrong Fang
Hi Sven, {$mode objfpc}{$H+} TConfiguration = packed record DataFolder: string; end; does not work, but: TConfiguration = packed record DataFolder: array [0..MaxPathLen] of Char; end; worked. My save procedure is: function SaveParams(var Buffer; Count: Integer; FileName:

Re: [Lazarus] LongString does not work?

2013-03-03 Thread Jürgen Hestermann
Am 2013-03-03 13:49, schrieb Xiangrong Fang: Hi Sven, {$mode objfpc}{$H+} TConfiguration = packed record DataFolder: string; end; does not work, but: A (Ansi)string in {$H+} mode is just a pointer (to the characters of the string). So sizeof(DataFolder)=4 (or 8) in all cases. There

Re: [Lazarus] LongString does not work?

2013-03-03 Thread Sven Barth
On 03.03.2013 13:49, Xiangrong Fang wrote: Hi Sven, {$mode objfpc}{$H+} TConfiguration = packed record DataFolder: string; end; does not work, but: TConfiguration = packed record DataFolder: array [0..MaxPathLen] of Char; end; worked. My save procedure is:

Re: [Lazarus] LongString does not work?

2013-03-03 Thread Xiangrong Fang
A (Ansi)string in {$H+} mode is just a pointer (to the characters of the string). So sizeof(DataFolder)=4 (or 8) in all cases. There is no room for the string unless I guess this is the cause, but then there is no need to specify packed if I just use array of char. --

Re: [Lazarus] LongString does not work?

2013-03-03 Thread Sven Barth
On 03.03.2013 14:26, Xiangrong Fang wrote: A (Ansi)string in {$H+} mode is just a pointer (to the characters of the string). So sizeof(DataFolder)=4 (or 8) in all cases. There is no room for the string unless I guess this is the cause, but then there is no need to specify packed if I just use

Re: [Lazarus] LongString does not work?

2013-03-03 Thread Bart
On 3/3/13, Xiangrong Fang xrf...@gmail.com wrote: TConfiguration = packed record DataFolder: array [0..MaxPathLen] of Char; end; worked. My save procedure is: function SaveParams(var Buffer; Count: Integer; FileName: string): Boolean; var fs: TFileStream; begin Result

Re: [Lazarus] LongString does not work?

2013-03-03 Thread Xiangrong Fang
I was using an INI file, but record make things a lot easier. 2013/3/3 Bart bartjun...@gmail.com On 3/3/13, Xiangrong Fang xrf...@gmail.com wrote: TConfiguration = packed record DataFolder: array [0..MaxPathLen] of Char; end; worked. My save procedure is: function

Re: [Lazarus] LongString does not work?

2013-03-03 Thread leledumbo
/Lazarus-LongString-does-not-work-tp4029606p4029624.html Sent from the Free Pascal - Lazarus mailing list archive at Nabble.com. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Re: [Lazarus] LongString does not work?

2013-03-03 Thread Luca Olivetti
Al 03/03/13 14:34, En/na Sven Barth ha escrit: For packed there is the guarantee though that the layout will stay the same. Are you sure? Does the same guarantee apply to bitpacked? Lately I've become lazy, and instead of manually decoding data (bits, bytes, words) read from a device, I'm

Re: [Lazarus] LongString does not work?

2013-03-03 Thread Sven Barth
On 03.03.2013 20:32, Luca Olivetti wrote: Al 03/03/13 14:34, En/na Sven Barth ha escrit: For packed there is the guarantee though that the layout will stay the same. Are you sure? Does the same guarantee apply to bitpacked? Lately I've become lazy, and instead of manually decoding data