Recent

Author Topic: Problem with variables in LazReport  (Read 3958 times)

janasoft

  • New Member
  • *
  • Posts: 19
Problem with variables in LazReport
« on: September 19, 2015, 07:44:59 pm »
I'm starting to use LazReport and I've found an extrange behaviour when I use variables.

Like  the manual says, I've preceded the name of the the variable with one space, but when I tried to use it inside LR to assign some value, it's impossible. However when the variable has two spaces in the beginning I'm able to assign the correct value. Anyway, in that case there are also problems, because I must refer to the variable without spaces, when I do it in the editor, and without square brackets, when I do it in the scripts. Any other way I get an error. For example

If Var1 is defined like ' Var1' -> Impossible to assign any value
If Var1 is defined like '  Var1' (with 2 spaces). I can assign values if I put [Var1] (without spaces) in the editor, and simply 'Var' (without square brackets) in the scripts. Any other way to refer to the variable in the script ([Var] or [ Var]) becomes an error. If I try to acces to that that variable from code inside Lazarus I must say ' Var1' (with one space)

Attached is a demo to show what I'm trying to say.

Please, could someone tell what I'm doing wrong?

I'm using Lazarus 1.4.2-32 bits and Windows 10-64 bits, but it happens the same in Windows 8
Lazarus v1.0.14 + FPC:2.6.2 + W8 64 bits

taazz

  • Hero Member
  • *****
  • Posts: 5365
Re: Problem with variables in LazReport
« Reply #1 on: September 19, 2015, 08:26:15 pm »
correct. the variable editor makes a few assumptions specificaly no spaces in front is not a variable is a group of variables. Adding the two spaces you instruct the parser to interpret it as a variable. Those spaces are for the parser only they are not used outside the variable editor.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

janasoft

  • New Member
  • *
  • Posts: 19
Re: Problem with variables in LazReport
« Reply #2 on: September 20, 2015, 12:50:00 pm »
Thanks for your hekp taazz, but I think that it doesn't answer my question.

Lazreport tutorial (http://wiki.freepascal.org/LazReport_Tutorial#Setting_up_variables) says that 'variables start with a space'. I suppose that it means only one space. My problem is that if I define the variable with one space only, the parser, in preview and in runtime mode, doesn't recognize the variable.

If I put two spaces, I can work with the variable, but it's name its not 'var1' but ' var1' (with one space at the beginning), which it's annoying because, for example, when you insert a reference to that variable using the Editor it's necesary to delete the leading space. Also when you refer to that variable inside Lazarus code, for example with the instruccion FindVariable, you must put ' var1' (again with one space) not 'var1' which would be the correct name.

If you want, you can try the program that I've attached to check if you get the same behaviour.
 
Regards
Lazarus v1.0.14 + FPC:2.6.2 + W8 64 bits

 

TinyPortal © 2005-2018