Re: [Lazarus] record literal in FPC?

2013-01-10 Thread Michael Schnell
On 01/09/2013 07:48 PM, Hans-Peter Diettrich wrote: A "with" should evaluate to an address IMHO this is an "implementation detail", that any compiler can handle as it likes to. It also could just work as if in the source the appropriate record elements code are prefixed by the "with" argument.

Re: [Lazarus] record literal in FPC?

2013-01-09 Thread Hans-Peter Diettrich
xrfang schrieb: I don't know if it's related to the fact that TEdit.CaretPos.X (or Y) is read only, or as Mattias said, the with syntax cannot work with record anyway... :-) A "with" should evaluate to an address, but a Delphi compatible *property* doesn't have an address. DoDi --

Re: [Lazarus] record literal in FPC?

2013-01-09 Thread Andreas Schneider
On Wednesday, January 9, 2013, 01:40pm Paul Ishenin wrote: > First check whether it works delphi mode. Apparently, it even works in mode objfpc. But only when the property directly reads/writes a member. If there is a setter method, it will still compile but NOT actually change the record

Re: [Lazarus] record literal in FPC?

2013-01-09 Thread Paul Ishenin
09.01.13, 20:34, Mattias Gaertner пишет: Apparently it doesn't - at least not always. Could be by design, could be a bug. I'll check the bug tracker later and may report that. (You can do that yourself, if you want, but sooner or later I would like that functionality to work too, so I've a pers

Re: [Lazarus] record literal in FPC?

2013-01-09 Thread Mattias Gaertner
On Wed, 09 Jan 2013 13:27:50 +0100 Andreas Schneider wrote: > Interesting. IIRC that worked correctly in Delphi 2010 (it's been a > while ...). This /might /be a bug in FPC. > > The root of the problem is how properties are handled. Afaics however, > the use of /with/ should cause it to assign t

Re: [Lazarus] record literal in FPC?

2013-01-09 Thread xrfang
I don't know if it's related to the fact that TEdit.CaretPos.X (or Y) is read only, or as Mattias said, the with syntax cannot work with record anyway... :-) This should be a problem (if any) with lazarus not fpc. Shannon 在 三, 1月 9, 2013 at 8:27 下午,Andreas Schneider 写道: Interesting. IIRC that

Re: [Lazarus] record literal in FPC?

2013-01-09 Thread Andreas Schneider
Interesting. IIRC that worked correctly in Delphi 2010 (it's been a while ...). This /might /be a bug in FPC. The root of the problem is how properties are handled. Afaics however, the use of /with/ should cause it to assign the final record afterwards. Apparently it doesn't - at least not always.

Re: [Lazarus] record literal in FPC?

2013-01-09 Thread Mattias Gaertner
On Wed, 09 Jan 2013 12:27:33 +0008 xrfang wrote: > Hi Adreas, > > I just tried, your method did not work as expected.  It compiled ok, but > didn't put the cursor at the end of the line as I wanted.  However, assign > CaretPos a new TPoint worked. > > Regards, > > 在 三, 1月 9, 2013 at 4:47 下午,

Re: [Lazarus] record literal in FPC?

2013-01-09 Thread xrfang
Hi Adreas, I just tried, your method did not work as expected.  It compiled ok, but didn't put the cursor at the end of the line as I wanted.  However, assign CaretPos a new TPoint worked. Regards, 在 三, 1月 9, 2013 at 4:47 下午,Andreas Schneider 写道: Hi, you could also use the with-statement, th

Re: [Lazarus] record literal in FPC?

2013-01-09 Thread xrfang
ell, but it's just my thought. I never really compare the generated code... -- View this message in context: http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-record-literal-in-FPC-tp4028464p4028478.html Sent from the Free Pascal - Lazarus mailing lis

Re: [Lazarus] record literal in FPC?

2013-01-09 Thread leledumbo
would be the same. Well... maybe you'll need some other directives as well, but it's just my thought. I never really compare the generated code... -- View this message in context: http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-record-literal-in-FPC-tp4028464p4028478.html Se

Re: [Lazarus] record literal in FPC?

2013-01-09 Thread Andreas Schneider
Hi, you could also use the with-statement, that is pretty handy in such cases: |with Edit1.CaretPos do begin X := 0; Y := 0; end;| Best Regards, Andreas On 08.01.2013 16:30, xrfang wrote: > Hi, > > Is there "record literal in FPC? e.g. normally, you do: > > var >cp : TPoint; > > cp.X

Re: [Lazarus] record literal in FPC?

2013-01-08 Thread Xiangrong Fang
t; the same with that literal record. > > > > -- > View this message in context: > http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-record-literal-in-FPC-tp4028464p4028474.html > Sent from the Free Pascal - Lazarus mailing

Re: [Lazarus] record literal in FPC?

2013-01-08 Thread leledumbo
If you declare an inline function producing the record, the effect would be the same with that literal record. -- View this message in context: http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-record-literal-in-FPC-tp4028464p4028474.html Sent from the Free Pascal - Lazarus mailing list

Re: [Lazarus] record literal in FPC?

2013-01-08 Thread xrfang
Thanks, but what I want is to AVOID any kind of declarations. So I will use the Point() function suggested by ik. 在 三, 1月 9, 2013 at 12:26 上午,Howard Page-Clark 写道: On 08/1/13 3:30, xrfang wrote: > I would like to use literal directly, such as: > > Edit1.CaretPos := (X: 0, Y: 0); You can us

Re: [Lazarus] record literal in FPC?

2013-01-08 Thread Howard Page-Clark
On 08/1/13 3:30, xrfang wrote: I would like to use literal directly, such as: Edit1.CaretPos := (X: 0, Y: 0); You can use a typed constant thus: const Origin: TPoint = (x:0; y:0); begin ... Edit1.CaretPos := Origin; ... -- ___ Lazarus mailing l

Re: [Lazarus] record literal in FPC?

2013-01-08 Thread ik
On Tue, Jan 8, 2013 at 5:30 PM, xrfang wrote: > Hi, > > Is there "record literal in FPC? e.g. normally, you do: > > var >cp : TPoint; > > cp.X := 0; > cp.Y := 0; > Edit1.CaretPos := cp; > > I would like to use literal directly, such as: > > Edit1.CaretPos := (X: 0, Y: 0); > > But the above syn

[Lazarus] record literal in FPC?

2013-01-08 Thread xrfang
Hi,  Is there "record literal in FPC? e.g. normally, you do: var    cp : TPoint; cp.X := 0; cp.Y := 0; Edit1.CaretPos := cp; I would like to use literal directly, such as: Edit1.CaretPos := (X: 0, Y: 0);  But the above syntax is wrong. Is there such thing exists? Thanks, Shannon-- __