Issue about assign pointers characteristics lazarus / 55-TAChart ---------------------------------------------------------------------- madepabloh · 2012-10-14 12:45 What i want to do is allow to the user to change in realtime different characteristics of a serieline plot: labels, line and points. So, i included different combobox, spinEdit and Colorbuttons to contain different properties of those elements. For example, one of the combobox contains the list of pointers shapes: Circle, rectangle, star, etc. On change of this comboxbox, i have this code: Code: [Select]Chart3LineSeries1.Pointer.Style := 'ps' + (ComboBox15.Text); but it returned this error: Quoteunit1.pas(784,55) Error: Incompatible type for arg no. 1: Got "TTranslateString", expected "TSeriesPointerStyle" I tryed changing the context of the combox to psCircle, psRectangle, psStar, etc. and this code: Code: [Select]Chart3LineSeries1.Pointer.Style := (ComboBox15.Text); with similar error returning. I have this problem with other comboboxes and othe properties of labels, lines, etc. I tryed to solve creating a variable and using this code: Code: [Select]var   s: TSeriesPointerStyle; begin   s := 'ps'+ (ComboBox15.Text);   Chart3LineSeries1.Pointer.Style := s;    and the error is this: Quoteunit1.pas(212,39) Hint: Parameter "ASender" not used unit1.pas(782,25) Error: Identifier not found "TSeriesPointerStyle" unit1.pas(782,25) Error: Error in type definition unit1.pas(787,39) Error: Incompatible type for arg no. 1: Got "", expected "TSeriesPointerStyle" tatypes.pas(1029,26) Hint: Found declaration: TSeriesPointer.SetStyle(TSeriesPointerStyle); unit1.pas(833) Fatal: There were 3 errors compiling module, stopping What am i doing wrong? Ok, everything, because it doesn´t work. So the question should be: how could i solve it?  Thanks! ---------------------------------------------------------------------- Ask · 2012-10-14 13:33 QuoteIdentifier not found "TSeriesPointerStyle" Add TATypes unit to the "uses" clause. QuoteIncompatible type for arg no. 1: Got "TTranslateString", expected "TSeriesPointerStyle"See the following code: Code: [Select]var   s: TSeriesPointerStyle; begin   ReadStr('ps'+ ComboBox15.Text, s);   Chart3LineSeries1.Pointer.Style := s; However, although the above will solve an immediate problem, the more fundamental issue remains -- you are trying to mix different data types without conversion. I recommend reading some book or manual on Pascal language to better understand data types. For example, Free Pascal Reference Guide. Also, it is preferable to avoid tying user interface strings to the program logic. So, better use item index instead of text value. You can look at almost any demo to see how it is done. ---------------------------------------------------------------------- wp · 2012-10-14 13:38 QuoteChart3LineSeries1.Pointer.Style := 'ps' + (ComboBox15.Text);This will not work because Pointer.Style is not a string, but an enumeration type TSeriesPointerStyle. This is what you have to do (1) fill the combobox with items in the same order they are declared in TSeriesPoinerStyle (unit TATypes) (2) type-cast the selected index of the combobox to TSeriesPointerStyle: Code: [Select]Chart3LineSeries1.Pointer.Style := TSeriesPointerStyle(Combobox15.ItemIndex); So, the solution to all your combobox issues is: use the ItemIndex and typecast the integer to the type of the enumeration. ---------------------------------------------------------------------- madepabloh · 2012-10-14 13:58 @Ask, Thanks so much, also for the link. I will review it in detail. I know it is better to use the itemindex, however, i was trying to do in this other way just for economy of code. In that way i don´t need to manage every option, and just only assign the text to the pointer characteristic. But you are right it is not a good solution at all. Moreover, i can allow to the user only few of the possibilities. @wp, thanks for this simpler idea. In that way i don´t need to management each itemindex, but to assign directly to the pointer. However, with this solution, i must allow to the user all the options. So, thanks to both for your inputs. I learned that in some cases it is better not try to reduce the code... Thanks to both! ---------------------------------------------------------------------- wp · 2012-10-14 15:20 Quotei must allow to the user all the optionsNot necessarily. The combobox items are descendants of TStrings which stores an "object" pointer next to the strings. It is quite common to "abuse" this object and store integers in the space reserved for the pointer. In 32-bit, pointers and integers occupy the same space (4 bytes), and the TSeriesPointerStyle internally is nothing but an integer as well. So, if you want to allow your users only to select between Rectangle and Circle, populate the Combobox manually in the following way: Code: [Select]  Combobox.Items.Clear;   Combobox.Items.AddObject('Circle', pointer(psCircle));   Combobox.Items.AddObject('Rectangle', pointer(psRectangle)); The type-cast to "pointer" is needed because the compiler expects a pointer here. And when you want to see which pointerstyle is selected you do the following: Code: [Select]  pointerstyle := TSeriesPointerStyle(Combobox.Items.Objects[Combobox.ItemIndex]);   Please note, however, that this exact solution will not work in 64-bit applications where pointers and integers have different sizes. In principle, it works also with 64-bits, but I forgot the details of the modification... ---------------------------------------------------------------------- madepabloh · 2012-10-14 15:43 Uhmm! Interesting... Thanks for the lesson. I am really learning a lot with you. Thanks! I will try to apply in that way to my project. Thanks!