Lazarus

Programming => General => Topic started by: pixelink on May 12, 2019, 11:58:42 pm

Title: [DONE] LazReport - Feature Bug??
Post by: pixelink on May 12, 2019, 11:58:42 pm
Got Laz Report to print normal text fine using a long string in Memo.Text
So, I am trying to add it to my Lyrics Editor that does have markup code in it.

<Title>
<Artist>
<Key: [?]>

So, if i remove all the markup, I do NOT get the error, and displays fine.

Title
Artist
Key: ?

However, If I try to print markup code, I get the error below....



Title: Re: LazReport - Feature Bug??
Post by: lucamar on May 13, 2019, 12:42:15 am
I don't know what's happening (I have zero experience with LazReport) but by the error it sounds like the problem isn't markup in general but the specific text "[?]".

Can it be that LazReport expects to have a field name specified in that way i.e. "[fieldname]"? If so, there must be a way to scape it somehow.
Title: Re: LazReport - Feature Bug??
Post by: pixelink on May 13, 2019, 02:09:04 am
I don't know what's happening (I have zero experience with LazReport) but by the error it sounds like the problem isn't markup in general but the specific text "[?]".

Can it be that LazReport expects to have a field name specified in that way i.e. "[fieldname]"? If so, there must be a way to scape it somehow.

Yeah, Markup text - specific  characters... same thing to me
Its called markup in my app because it is added tags to help make the text code view-able in 3rd party viewer apps, kind of the same as html "<>" are technically characters, but we call it markup... same for BBCode, markup.

Field name... No,  because if that were the case, then it would give me and error saying need to assign field name to data (or similar message).

This is pretty basic stuff.... if normal characters work, and I did a sample project with two pages of plain normal Memo1.text, and it all worked, except that text didn't have any specialized characters.

I am sure this was made like this on purpose, why i don't know.
If that is true, then LAZ Report is pretty much useless if you want to print source code. It can only be used on normal text and database fields.
Title: Re: LazReport - Feature Bug??
Post by: pixelink on May 13, 2019, 02:42:55 am
Just by chance I happened to see a property under options
Where you can turn that error notifier off and allow the special characters.

Awesome... I was disappointed if that was a bug or built  that way... glad I found this... I would rather be wrong than stuck.

Thanks
Title: Re: LazReport - Feature Bug??
Post by: pixelink on May 13, 2019, 03:05:18 am
Well... I got excited to quick.

So, turn off the notifier does allow some characters, but not all.

Look at my screen....

It removed "[?]"

Upon further investigation... if I have a chord "[dm]" or any other chord in between the "[]"'s
It completely removes the '[]" and anything in between.

So, that isn't right, can't have this.

Why are special characters not allowed to be printed???
Title: Re: LazReport - Feature Bug??
Post by: lucamar on May 13, 2019, 03:36:44 am
According to the (FastReport) manual:
({Lazarus}/components/lazreport/doc/fr_eng.pdf)
the notation "[something]" is reserved to insert variables and datafields into the text. It's the very first object described.

There doesn't seem to be any way to escape it if you want it to be taken literally but I've only skimed the text. You should read it and see if I've missed someting. But take into account that the doc is about FastReport; LazReport isn't exactly the same.

An let's hope someone more with more knowledge than I comes and offers a soultion :)
Title: Re: LazReport - Feature Bug??
Post by: Thausand on May 13, 2019, 04:04:45 am
...
There doesn't seem to be any way to escape it if you want it to be taken literally but I've only skimed the text.
...
I not know and make try suggest.

I have make fast look lr_parse and see quote single make text literal ? Then maybe have work <Key: '[?]'> ? (i not know what is mark question for laz report so maybe quote single have other place, example '['?']' )

Title: Re: LazReport - Feature Bug??
Post by: paweld on May 13, 2019, 06:49:56 am
Code: [Select]
<Title>
<Artist>
<Key: ['[?]']>
Title: Re: LazReport - Feature Bug??
Post by: pixelink on May 13, 2019, 12:15:59 pm
If I have to escape every character that is not allowed... then I will need a list of them all.
a "!" is not allowed either, so I need to know what all of them are.
Title: Re: LazReport - Feature Bug??
Post by: lucamar on May 13, 2019, 03:48:21 pm
If I have to escape every character that is not allowed... then I will need a list of them all.
a "!" is not allowed either, so I need to know what all of them are.

The problem is the square brackets [ and ]. The square-brackets are used to insert variables and datafields but apparently (from the answers above) you can use them also to add literals, so when you have in your text p.e. [Dd] you have to replace it with ['[Dd]'].

It's not so difficult: just replace every instance of "[" by "['[' and instances of "]" with "]']" before printing and back after printing.

That should do the trick :)
Title: Re: LazReport - Feature Bug??
Post by: pixelink on May 13, 2019, 04:16:50 pm
If I have to escape every character that is not allowed... then I will need a list of them all.
a "!" is not allowed either, so I need to know what all of them are.

The problem is the square brackets [ and ]. The square-brackets are used to insert variables and datafields but apparently (from the answers above) you can use them also to add literals, so when you have in your text p.e. [Dd] you have to replace it with ['[Dd]'].

It's not so difficult: just replace every instance of "[" by "['[' and instances of "]" with "]']" before printing and back after printing.

That should do the trick :)

Yeah... I already got that from above.

I need a list of all the characters that LAZ Report excludes so I can code accordingly.

You never know what characters a user may insert into any string.

Thanks
Title: Re: LazReport - Feature Bug??
Post by: pixelink on May 13, 2019, 09:55:06 pm
I am still needing the list of all excluded characters from the LAZ Report
Title: Re: LazReport - Feature Bug??
Post by: lucamar on May 14, 2019, 02:45:01 am
I am still needing the list of all excluded characters from the LAZ Report

What do you mean by "excluded characters"? You mean that if you add, for example, "sacre bleu!!!" LazReport will silently delete the "!"? Or that adding this question it deletes the "?"?

I find that hard to believe but, as I said above, I have zero experience with it ...

In any case, it shouldn't be difficult to ascertain: prepare a text with all characters and send it to a report to see which characters are silently dropped. Only, take care to exclude the square brackets from it: you already know those are special.
Title: Re: LazReport - Feature Bug??
Post by: pixelink on May 14, 2019, 08:36:11 am
I am still needing the list of all excluded characters from the LAZ Report

What do you mean by "excluded characters"? You mean that if you add, for example, "sacre bleu!!!" LazReport will silently delete the "!"? Or that adding this question it deletes the "?"?

I find that hard to believe but, as I said above, I have zero experience with it ...

In any case, it shouldn't be difficult to ascertain: prepare a text with all characters and send it to a report to see which characters are silently dropped. Only, take care to exclude the square brackets from it: you already know those are special.

All I need it a list of all the characters that LAZ Reports hides from the printed page, so I know which characters I am supposed to escape in code.

Title: Re: LazReport - Feature Bug??
Post by: lucamar on May 14, 2019, 10:54:50 am
What do you mean by "excluded characters"? You mean that if you add, for example, "sacre bleu!!!" LazReport will silently delete the "!"? Or that adding this question it deletes the "?"?

All I need it a list of all the characters that LAZ Reports hides from the printed page, so I know which characters I am supposed to escape in code.

Yeah, I got that, but you don't answer my question: Do you mean LazReports eats-up some characters wherever they are and not just when they are between square brackets?
Title: Re: LazReport - Feature Bug??
Post by: pixelink on May 14, 2019, 12:41:14 pm
What do you mean by "excluded characters"? You mean that if you add, for example, "sacre bleu!!!" LazReport will silently delete the "!"? Or that adding this question it deletes the "?"?

All I need it a list of all the characters that LAZ Reports hides from the printed page, so I know which characters I am supposed to escape in code.

Yeah, I got that, but you don't answer my question: Do you mean LazReports eats-up some characters wherever they are and not just when they are between square brackets?

Sorry,
Correct...as I mentioned above it also ate the "!" character which is not between "[]"'s
Title: Re: LazReport - Feature Bug??
Post by: lucamar on May 14, 2019, 01:18:08 pm
Correct...as I mentioned above it slao ate the "!" character which is not on between "[]"'s

OK, let me investigate a little ... though it will be mostly googling around: I don't have LazReport installed (never use it).
Title: Re: LazReport - Feature Bug??
Post by: Thausand on May 14, 2019, 04:46:13 pm
OK, let me investigate a little ... though it will be mostly googling around: I don't have LazReport installed (never use it).
Is not need install. maybe read 15 second ?  :-X

Code: Pascal  [Select][+][-]
  1. function GetBrackedVariable(s: String; var i: integer; out j: Integer): String;
  2. var
  3.   c: Integer;
  4.   fl1, fl2: Boolean;
  5. begin
  6.   j := i; fl1 := True; fl2 := True; c := 0;
  7.   Result := '';
  8.   if s = '' then Exit;
  9.   Dec(j);
  10.   repeat
  11.     Inc(j);
  12.     if fl1 and fl2 then
  13.       if s[j] = '[' then
  14.       begin
  15.         if c = 0 then i := j;
  16.         Inc(c);
  17.       end
  18.       else if s[j] = ']' then Dec(c);
  19.     if fl1 then
  20.       if s[j] = '"' then fl2 := not fl2;
  21.     if fl2 then
  22.       if s[j] = '''' then fl1 := not fl1;
  23.   until (c = 0) or (j >= Length(s));
  24.   Result := Copy(s, i + 1, j - i - 1);
  25. end;
  26.  
Title: Re: LazReport - Feature Bug??
Post by: lucamar on May 14, 2019, 08:52:44 pm
OK, let me investigate a little ... though it will be mostly googling around: I don't have LazReport installed (never use it).
Is not need install. maybe read 15 second ?  :-X

That's where the parts enclosed in square brackets are treated. We already knew that. Maybe read 20 seconds? ;)

Now serious: It seems the problem is that other characters beyond the square brackets are also treated as "special". Pixelink needs to know what those are to, if needed, scape them (probably by replacing them with ["somechar"].

If you have LazReport installed or the sources at hand, maybe you could look into that?
Title: Re: LazReport - Feature Bug??
Post by: jesusr on May 14, 2019, 09:18:40 pm
Now serious: It seems the problem is that other characters beyond the square brackets are also treated as "special". Pixelink needs to know what those are to, if needed, scape them (probably by replacing them with ["somechar"].

If you have LazReport installed or the sources at hand, maybe you could look into that?

What is between "[" and "]" must be a valid expression (see "Using strings and variables" in the pdf doc file), if it works with 'strings' that do not represent fields and is not documented, we have to check if it is an undocumented feature or a bug.

If the removal of the ! or "other special" character is confirmed, then it's a bug and a bug report is in order, but here I couldn't confirm this, also the posted image shows that the !s aren't removed.
Title: Re: LazReport - Feature Bug??
Post by: Thausand on May 14, 2019, 09:28:28 pm
That's where the parts enclosed in square brackets are treated. We already knew that. Maybe read 20 seconds? ;)
:D

Quote
Now serious: It seems the problem is that other characters beyond the square brackets are also treated as "special". Pixelink needs to know what those are to, if needed, scape them (probably by replacing them with ["somechar"].
Me serious.

Answer already write more before  :)

If want have literal then make literal.

No need have know characters special. Lazreport have support many special function and make add (+), subtract (-) , and, or, fraction, round mod and have many more. Is no can filter easy ?

Quote
If you have LazReport installed or the sources at hand, maybe you could look into that?
Literal = literal and no literal= parse special and have function and calculate.

no can change how work laz report ?

https://github.com/alrieckert/lazarus/blob/master/components/lazreport/source/lr_pars.pas

add:

....
You never know what characters a user may insert into any string.
...
Have same answer. Make literal.
Title: Re: LazReport - Feature Bug??
Post by: pixelink on May 14, 2019, 11:37:36 pm
1) The other the "!" was missing, not sure what happened , but its there now.

2) Doesn't really matter anyways.... Can't use the [fields] in LazReport for this project, because the Lyrics Chord text is manually typed in by the user (just like coding). And if what you are saying is that because it's an invalid "field, it will remove what's in between. Then why should I go through all this work for.....

3) I have already figured out how to print the entire text (with word-wrap - and multiple pages) using just the printer.canvas.

No need for all this complication for something that I can easily print with Printer.Canvas and not worry about missing characters,

So, LAZ Report is really made for db's and user value fields and not straight print. Which is cool. I will use LAZR when i need to print fields on a form.

So, I am done with this thread and I want to THANK EVERYONE FOR YOUR HELP!!
Title: Re: [DONE] LazReport - Feature Bug??
Post by: Jurassic Pork on October 31, 2020, 09:04:11 am
hello,
i think that i have found a solution to print everything in lazreport :
use a variable string  (see attachment)
resultat and demo project (print the content of a tmemo with printers or lazreport)  in attachment

Friendly, J.P
TinyPortal © 2005-2018