Lazarus

Miscellaneous => Other => Topic started by: lgrfbs on February 08, 2017, 12:55:40 pm

Title: has no component named Tag
Post by: lgrfbs on February 08, 2017, 12:55:40 pm
- Eng -
In Delphi you can use .tag on all the components to put a numerical value, when I try the same thing in Lazarus, I get the error:< Error: Type TLABEL component has no named Tag. >Have a feeling that I have asked this before, but I did not back to the answer and it has at least been some time since.
Hope i posted in the correct forum.


- Swe -
I Delphi kan man använda .tag på alla komponenterna för att stoppa undan ett numrerisktvärde, när jag provar samma sak i Lazarus så får jag felet:
<Error: Type TLABEL has no component named Tag.>

Har en känsla av att jag har frågat detta förr, men jag hittade inte tillbaka till det svaret och det har ju i alla fall gått en tid sedan dess.
Title: Re: has no component named Tag
Post by: Handoko on February 08, 2017, 01:03:46 pm
I've just tested on my Lazarus 1.6.2 FPC 3.0.0. TLabel.tag works here on my Linux PC.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   Label1.Tag := 1;
  4. end;

Can you provide your code?
Title: Re: has no component named Tag
Post by: lgrfbs on February 08, 2017, 01:27:24 pm
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Button1: TButton;
  16.     Label1: TLabel;
  17.     procedure Button1Click(Sender: TObject);
  18.   private
  19.     { private declarations }
  20.   public
  21.     { public declarations }
  22.   end;
  23.  
  24. var
  25.   Form1: TForm1;
  26.  
  27. implementation
  28.  
  29. {$R *.lfm}
  30.  
  31. { TForm1 }
  32.  
  33. procedure TForm1.Button1Click(Sender: TObject);
  34. begin
  35.   Form1.Label1.Tag:=Form1.Label1.Tag+1;
  36.   Form1.Label1.Caption:=IntToStr(Form1.Label1.Tag)
  37. end;
  38.  
  39. end.
  40.  
  41.  
* Add "Form1.Label1.Tag" to Watch List.
* Then I set a brak on line 36
And now I get "<Error: Type TLABEL has no component named TAG.>" in the Watch List as a Value insteed of 2,3,4,5,6 and so on.

Windows 7 and lazarus 1.6
Title: Re: has no component named Tag
Post by: Thaddy on February 08, 2017, 01:30:37 pm
In Delphi you can use .tag on all the components

That is VB syntax. That doesn't work in Delphi either. (And it implies "with.. ")

If I run your code I see no problem. There may be a debugger issue, though, depending on platform and GDB version.
Title: Re: has no component named Tag
Post by: Handoko on February 08, 2017, 01:37:03 pm
I don't fully understand you problem. But it works on my computer.
Title: Re: has no component named Tag
Post by: balazsszekely on February 08, 2017, 01:40:18 pm
@lgrfbs
That is a limitation of the debugger(or perhaps it's not configured correctly). In fact the label tag was increased by one.
Quote
@Thaddy
That is VB syntax. That doesn't work in Delphi either. (And it implies "with.. ")
Yes it does. You should go into grumpy mode, induced by your own comment :D
Title: Re: has no component named Tag
Post by: Thaddy on February 08, 2017, 01:41:53 pm
< >:D> Yes the code works in Delphi but with do .tag doesn't.< >:D> with do tag does.
Title: Re: has no component named Tag
Post by: lgrfbs on February 08, 2017, 02:07:59 pm
Okay, I see that it works nicely with you.Hmmmmmmm, then it is just for me to update to the latest Lazarus installation.Thanks for all the help.
Title: Re: has no component named Tag
Post by: Handoko on February 08, 2017, 02:33:32 pm
I'm using UbuntuMate. Perhaps you can consider to use Linux.  :D
Title: Re: has no component named Tag
Post by: wp on February 08, 2017, 03:40:39 pm
Okay, I see that it works nicely with you.Hmmmmmmm, then it is just for me to update to the latest Lazarus installation.Thanks for all the help.
If I understand your signature correctly you are using Laz 1.2.6? I still have a Laz 1.2 installed for some backward compatibility tests, and already there TLabel has a property Tag, and I am almost sure that it has been there all the time. So, from this point of view, the Lazarus version is not your problem. Are you sure that Lazarus is installed correctly? Maybe installing the current version 1.6.2 is faster than fixing a faulty old installation...
Title: Re: has no component named Tag
Post by: lgrfbs on February 08, 2017, 04:01:39 pm
Yepp, I have Lazarus 1.2.6 and 1.6 installed on this Windows 7 box and I have always had this error on both installs (different folders). The thing is I are in the middle of a project I started for 4 years ago in 1.2.6 and hope to get to the end of the project.
Title: Re: has no component named Tag
Post by: howardpc on February 08, 2017, 04:38:07 pm
If I understand your signature correctly you are using Laz 1.2.6? I still have a Laz 1.2 installed for some backward compatibility tests, and already there TLabel has a property Tag, and I am almost sure that it has been there all the time.

I believe Tag (and Name) have been declared as published TComponent properties from the time of the first Delphi 1 VCL.
Title: Re: has no component named Tag
Post by: lgrfbs on February 08, 2017, 05:11:13 pm
I think you howardpc have right there. I know it has worked ever since Delphi 3 to Delphi 7. But why it is not working in my Lasaruz.
Could it be that Lazarus does not quite work as a Delphi at this point? (or my install of Lazarus)
Title: Re: has no component named Tag
Post by: Cyrax on February 08, 2017, 10:29:14 pm
Lazarus uses GDB (http://www.gnu.org/software/gdb/ (http://www.gnu.org/software/gdb/)) as its debugger back end.

The GDB shipped with FPC 2.6.4 probably can't show values from class properties or doesn't have support for it.

Oh, I see you have Lazaraus 1.6 too. The GDB doesn't have support for showing values from complex class properties like a property getters...
Title: Re: has no component named Tag
Post by: rvk on February 08, 2017, 10:43:19 pm
GDB on Windows in combination with Lazarus is very very very, and I mean very bad.

I also always have trouble with Ctrl+F7 to see the value of a property. Even hovering over a property when debugging doesn't work. Hovering over the object itself does work but gives you the complete object-source (which is too much sometimes).

No, GDB is really poor on Windows
(or this is a implementation/connection of Lazarus with GDB on Windows that doesn't work).
Title: Re: has no component named Tag
Post by: lgrfbs on February 10, 2017, 11:40:16 am
I'm using UbuntuMate. Perhaps you can consider to use Linux.  :D
I have LinuxMint as testplattform, how do I debug Windows program bugs on that box :P ?
I will make some test on LinuxMint and see if it works better.

But relly what is needed to fix so GDB on Windows in combination with Lazarus will work better? Money, time, more programmers?
Title: Re: has no component named Tag
Post by: Handoko on February 10, 2017, 02:27:54 pm
I'm using UbuntuMate. Perhaps you can consider to use Linux.  :D
I have LinuxMint as testplattform, how do I debug Windows program bugs on that box :P ?

Maybe not the best. But if I were you, I will learn and convert all the old codes to support cross-platform. This is what I currently do. To make win-only codes to become cross-platform is not easy, but actually it's also not too hard.

Alternatively, which is also what I currently do. I write my own debug module to help me to test and debug my algorithms. It's similar to ShowMessage, but with more better features. It overloaded to support different input: string, integer, byte, qword, extended, pointer. It can display the messages (or the values I want to watch) on the mainform's caption, a popup form or a system popup notifier balloon. I'm planning to make it to able to log the messages to a text file. It sounds cool, isn't it?  8-)
Title: Re: has no component named Tag
Post by: lgrfbs on February 20, 2017, 12:38:46 am
The Project I have on my desk just now is no old code at all it is writed for Window and Linux.
I want have a better support for .tag and
Quote from: rvk
I also always have trouble with Ctrl+F7 to see the value of a property. Even hovering over a property when debugging doesn't work. Hovering over the object itself does work but gives you the complete object-source (which is too much sometimes).
So what can I do for help to fix this problems?
Title: Re: has no component named Tag
Post by: rvk on February 20, 2017, 10:05:54 am
The Project I have on my desk just now is no old code at all it is writed for Window and Linux.
I want have a better support for .tag
By now you should have realized that there is absolutely nothing wrong with .tag itself. The tag property works perfectly. It's just that during debugging on Windows you can't view that property in the watch-views. So although the watch-view gives you the error, .tag has a perfectly correct value.

Quote
and
Quote from: rvk
I also always have trouble with Ctrl+F7 to see the value of a property. Even hovering over a property when debugging doesn't work. Hovering over the object itself does work but gives you the complete object-source (which is too much sometimes).
So what can I do for help to fix this problems?
If you have code for Windows AND Linux, you could switch to developing on Linux, where I understand the watch-window works correctly for properties.

Otherwise you could add debug-lines to output to a debug-window (or use plain Showmessages).

Another thing you could do is try to find the relevant bugtrack entry for the lacking watch-window and see if there is still something done about it. If there is nog bug-entry you could add one.

I think it is this one from 2008: http://bugs.freepascal.org/view.php?id=12111.
Why the Linux version can extract that information from GDB and Windows can't, is a mystery to me.
Title: Re: has no component named Tag
Post by: Thaddy on February 20, 2017, 10:31:25 am
I want have a better support for .tag
How can you ask for better support for a nativeint (I always spell it as naiveint in the context of tag for some reason  O:-)) that happens to be mis-used as a pointer to object?
Title: Re: has no component named Tag
Post by: wp on February 20, 2017, 10:31:58 am
The direct properties (for which the getter just returns an internal variable and is not a function) you can type the name of the internal variable to see the property value in the debugger. So, to see the Tag of Button1, enter "Button1.FTag" in the watch window.
Title: Re: has no component named Tag
Post by: Thaddy on February 20, 2017, 10:38:36 am
Correct.
Point I was trying to make is that if you mis-use tag for object storage, you'd better extend your class with an extra property.
Tags are volatile: somebody else in your team might use it too, and your intended functionality is gone to room 101.

As an aside I can confirm I know of a hotel where 101 isn't a toilet and actually pretty decent and recommended: The Hotel Central in Istanbul)
Title: Re: has no component named Tag
Post by: rvk on February 20, 2017, 10:51:11 am
I want have a better support for .tag
How can you ask for better support for a nativeint (I always spell it as naiveint in the context of tag for some reason  O:-)) that happens to be mis-used as a pointer to object?
If you read the topic again from the beginning you'll see the question isn't about using .tag but about viewing the value of .tag in the watch-list (which doesn't work under GDB/Windows). (It's about support in the watch-list for ANY property of an object)

Nowhere in this topic I see mentioned that .tag is being used as "pointer".
The fact it is used as pointer a lot doesn't mean it is in this case.

@wp, I didn't know you could use the direct FProperty in the watch-list. Thanks for the tip.
Title: Re: has no component named Tag
Post by: Thaddy on February 20, 2017, 10:56:50 am
I was fully aware of that.But you CAN actually see it and you CAN even also cast it in the debugger. So I don't see the problem.
Title: Re: has no component named Tag
Post by: rvk on February 20, 2017, 11:01:18 am
I was fully aware of that.But you CAN actually see it and you CAN even also cast it in the debugger. So I don't see the problem.
Not on Windows. On Windows you can't add Object.Tag in de watch-list and see the value (like already mentioned in this topic). And even if you use only Object you see a large list and you would need to scroll/search for the property. In the hoover-mouse-over you can't see the value.

On Linux it seems that you can add Object.Tag in the watch-list, but OP is on Windows.

You can, like wp mentioned, use Object.FTag (which I wasn't aware of).
Title: Re: has no component named Tag
Post by: Thaddy on February 20, 2017, 12:38:43 pm
I was fully aware of that.But you CAN actually see it and you CAN even also cast it in the debugger. So I don't see the problem.
Not on Windows. On Windows you can't add Object.Tag in de watch-list and see the value (like already mentioned in this topic). And even if you use only Object you see a large list and you would need to scroll/search for the property. In the hoover-mouse-over you can't see the value.

On Linux it seems that you can add Object.Tag in the watch-list, but OP is on Windows.

You can, like wp mentioned, use Object.FTag (which I wasn't aware of).
Why does it work on windows too when you cast it? Is there a GDB issue? is it maybe GDBMI?
Title: Re: has no component named Tag
Post by: rvk on February 20, 2017, 12:49:38 pm
Why does it work on windows too when you cast it? Is there a GDB issue? is it maybe GDBMI?
How do you cast over a property in the watch-list?

Even if I do integer(Button1.tag) in the watch-list I get "A syntax error in expression, near `TAG)'".

Doing Integer(Button1.FTag) or just Button1.FTag it show the value of .tag.

If this works on Linux, then yes, it might be a combined GDB/Lazarus_for_Windows issue.
Title: Re: has no component named Tag
Post by: lgrfbs on February 21, 2017, 06:30:59 pm
If this works on Linux, then yes, it might be a combined GDB/Lazarus_for_Windows issue.
And how do we fix this so it works on Windows to?


If you have code for Windows AND Linux, you could switch to developing on Linux, where I understand the watch-window works correctly for properties.
Yes, I can  switch to Linux, but that will not fix the bug on Windows and than I get a bug in my code as only is in Windows code I is in the watch-list bug and must do low level debuging by dialogboxes or labels and that sucks then we have a tool as nearly works.
I hope on a debug tool as work in all OS as Lazarus can run.  :)

//Sorry for broken English.
Title: Re: has no component named Tag
Post by: Thaddy on February 21, 2017, 06:58:39 pm
I wish Borland never added that notorious tag that I mis-used myself so many times in  the nineties of the last century and noobs still try to use to store objects today.
DON'T. Mea Culpa, limited to High(QWORD) Culpa.
I am 59 today. >:( >:( >:( >:D >:D >:D
I have the right to a nice birthday dinner. (Which I will get, thank you).

Derive a new class.... I already told you that. Forget about "tag". <sigh>
Tags are for Dogs and Cats and even in Amsterdam they are abolished, late, but since last year,  for those too. O:-)

I know that there are quite a few more here that are of the same opinion.

Hence I can drink my proper Burgundy in peace.

If you want to give me a nice birthday present, simply don't use tag...... ever....Derive a new class... and keep your mouth shut.

Next year I am 60. Then I will ask the Laz developers to mark tag as deprecated... THAT would be a nice present!! :D
Title: Re: has no component named Tag
Post by: jacmoe on February 21, 2017, 07:11:19 pm
Here's to you, mate Thaddy - I'm hitting 49 this may; the body gets older and the spirit gets younger. Enjoy your day, and burgundy! ;D ;D 8)
Title: Re: has no component named Tag
Post by: lgrfbs on February 21, 2017, 08:17:21 pm
Can we calm down a little bit?
"Write Once
Compile Anywhere"
Sounds great ...

Okey, .tag was a bad example, but the problem is still there.
I have now been advised not to use the .tag, okey will do so.

Windows - Lazarus 1.6 r51630 FPC 3.0.0 i386-win32-win32/win64
Ctrl-F5 key do not work for me.
Watch List do not work with .tag (Just I shall not use it)


This feels like a wrench without the roller, use it as a hammer instead.  %)
Title: Re: has no component named Tag
Post by: rvk on February 21, 2017, 08:31:32 pm
Happy Birthday Thaddy.

Like I said before... the watch-list doesn't work for ANY property under Windows.
Are you saying you can view for instance TButton.Caption or TEdit.Text in a watch-list under Windows ????

Even if you create a new class and make a new property... THAT property can't be shown in the watch-list (under Windows). Only the direct class-variables (like FCaption, FTag etc.) can be shown in the watch-list. But this topic was about using direct "property" in the watch-list !!!

So, although the advise about not (mis)using tag is sound... it doesn't help OP to show a (or any) property in the watch-list.
Title: Re: has no component named Tag
Post by: lgrfbs on March 14, 2022, 03:40:17 pm
Hello to you, 5 years later, is it still true what rvk wrote in the post: #31 on: February 21, 2017, 08:31:32 pm ?
I tested in the Lazarus that is installed right now:
Lazarus 2.0.6 r62129 FPC 3.0.4 x86_64-win64-win32/win64

and it doesn't work there, it would be really nice /good if that function came to life.
Ctrl+F5 is working in this version.
Is there any small possibility that it works in the newest Lazarus?
Title: Re: has no component named Tag
Post by: rvk on March 14, 2022, 05:12:29 pm
Is there any small possibility that it works in the newest Lazarus?
I don't think it will ever work with GDB as debugger.

But you can try "FpDebug internal Dwarf-debugger". I saw that one does show properties in the Watch-window.
(at least in trunk)

You can set it under Tools > Options > Debugger > Debugger backend
Title: Re: has no component named Tag
Post by: dseligo on March 14, 2022, 05:55:20 pm
Hello to you, 5 years later, is it still true what rvk wrote in the post: #31 on: February 21, 2017, 08:31:32 pm ?
I tested in the Lazarus that is installed right now:
Lazarus 2.0.6 r62129 FPC 3.0.4 x86_64-win64-win32/win64

and it doesn't work there, it would be really nice /good if that function came to life.
Ctrl+F5 is working in this version.
Is there any small possibility that it works in the newest Lazarus?

It works in Lazarus 2.2.0 with FpDebug.
Title: Re: has no component named Tag
Post by: Thaddy on March 14, 2022, 05:59:40 pm

It works in Lazarus 2.2.0 with FpDebug.
It partly works with fpdebug, but only for fields and not for getters and setters.
Title: Re: has no component named Tag
Post by: dseligo on March 14, 2022, 06:07:38 pm

It works in Lazarus 2.2.0 with FpDebug.
It partly works with fpdebug, but only for fields and not for getters and setters.

Well, he asked if it works with Tag, and it does. :)
TinyPortal © 2005-2018