Recent

Author Topic: Operator += not working with Tmemo Text property  (Read 1645 times)

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Operator += not working with Tmemo Text property
« on: April 19, 2018, 11:56:24 pm »
hello,
I have a compiler error ( unit1.pas(114,32) Error: Variable identifier expected ) on the line with MemConsole of this code :
Code: Pascal  [Select][+][-]
  1. var str1,str2: string;
  2. begin
  3.   str1 := 'hello ';
  4.   str2 := 'world';
  5.   str1 += str2;
  6.   MemConsole.Lines.Text += str1;
  7. end;  
MemConsole is a TMemo. Lazarus 1.8.2  Windows 10, option Style Operator C (*=, +=, /= et -=) (-Sc, {$COPERATORS ON}) is checked.
Friendly, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

jamie

  • Hero Member
  • *****
  • Posts: 6077
Re: Operator += not working with Tmemo Text property
« Reply #1 on: April 20, 2018, 12:08:42 am »
Reading properties involves using functions to fetch the value and then use a function to set it..

 Using the += will fetch it but will only effect the fetched value and not write back the results via the
Setter function of the property..

 I suppose it could be fixed but in the background it would be the same as what you do now with normal
code..

 MemConsoleLines.Text := MemConsole.Lines.Text + strl;

 With this the compiler does the RIGHT side to resolve the value using the getter functions and then
does the LEFT side using the Setter procedure etc..

 So when it comes to properties you need to adhere to the Pascal standard..

 Maybe the DEV boys could simulate the same when properties come into play at some later date.
 
The only true wisdom is knowing you know nothing

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Operator += not working with Tmemo Text property
« Reply #2 on: April 20, 2018, 12:19:16 am »
Ok, Thanks Jamie ! Then i stay with the code :
Code: Pascal  [Select][+][-]
  1. MemConsole.Lines.Text := MemConsole.Lines.Text + str1;
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

 

TinyPortal © 2005-2018