I have a problem with the IIF
PNJs."GAB" is integer field.
In the TfrxMemoView (from Fast-Report last version) I wrote this:
[IIF(<PNJs."GAB">=0, '',<PNJs."GAB">)] : The result is empty, why?
Or
[PNJs."GAB"] : The result is the integer good !
I use DoublePasse engine option !
Help me !
In the TfrxMemoView (from Fast-Report last version) I wrote this:
[IIF(<PNJs."GAB">=0, '',<PNJs."GAB">)] : The result is empty, why?
Or
[PNJs."GAB"] : The result is the integer good !
I use DoublePasse engine option !
Help me !
This discussion has been closed.
Comments
your true value is your false value is not a string
try
'[PNJs."GAB"] '
Could you explain it to me again or show me the complete syntax ?
read the description of the function carfully
you will see that the first parameter is an expression that equates to a boolean value
the truevalue and false values are variants and it returns a variant for a result.
now think about what is allowed in the memo of the text object, text, and/or expressions enclosed in a singleset of []
the script parser like delphi strips leading and trailing apostrophes.
a field in a memo [datasetname."fieldname"] is a valid expression which when handled by the evaluator
returns the value of the field as text or formatted text if the display format is set.
to pass an expression in true value or false value you need to have '[expression]' then the expression will be further evaluated.
to pass the value of a variable or field you need to wrap it with suitable functions.
ie this would be valid
[IIF(<Page> > 1,'continued from Page: ' +VarToStr(<Page> -1),'Page: '+Vartostr(<Page>))]
the result is a variant string.
the vartostr() function is used to stop the parser from throwing an error.
PNJs."FOR", this is a integer value which in my example vacuum corresponds to the value 18.
I tested this and nothing appears in the memo.
[IIF(<PNJs."FOR">>0, 'Empty', 'Full')]
If I understand your explanation it would appear the word 'full' and this is not the case !!!
translate this to words and you will see why you are getting the true value rather than the false value.
[IIF(<PNJs."FOR">>0, 'Empty', 'Full')]
if <pnjs.for> is greater than 0 then 'empty' else 'full'
18 is greater than 0 and equates to true. therefore you get the true value not the false valu
It's true (sorry for this), but if I made like this: [IIF(<PNJs."FOR">>0, 'True', 'False')] , the test is still empty whereas if I just: [PNJs."FOR"] I can see that my whole 18, why ?
Gork Thank you for taking time to help me in my problem...
i messed up my explanation a bit
had to look at my old notes
run the main demo pick the simple list report
change te contents of memo8
to
[IIF(<Customers."Company"> = 'Action Diver Supply','true',vartostr(<Customers."Company">))]
what we are doing is putting a final value into the text of the memo
the above sample puts the value of the field into the memo except when the expression is true then it puts the word true.
you must always pass values when working with the iif function so to get the value of a field you need to use the vartostr()function
you can only pass expressions into a memos text only when working from the band or another object
and they must be contained in '[]'.
ie
procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
begin
memo3.lines.clear;
memo3.lines.add('[Customers."Company"]');
memo3.lines.add('[Customers."Addr1"]');
if (<Customers."Addr2"><>'') then memo3.lines.add('[Customers."Addr2"]');
if (<Customers."City"><>'') then memo3.lines.add('[Customers."City"]');
if (<Customers."State"><>'')then memo3.lines.add('[Customers."State"]');
if (<Customers."Zip"><>'') then memo3.lines.add('[Customers."Zip"]');
end;
I tested this with success, I even did the same test in another report on a field of type integer with success too.
[IIF(<PNJs."FOR"> = 0,' := 0 ', vartostr(<PNJs."FOR">))]
But when I made my report to me this does not work, whereas if I just put this [PNJs."FOR"] in the Memo it works, I do not really see where this bug may come ...
This is very strange for me...
since you know the function works passes the true or false value when the expression equates to boolean true or false then you must look at your expression portions contents to find the error, as it is never equating to true or false.
since you are using a tclientdataset
make sure that the underlying field type is what you expect. you are expecting an integer according to your current expression portion and since it seems to be failing, it is probably not an integer field. it might be
a formated string with no decimals.
the problem is not in the function itself but in what you are using in the expression portion.
Why ?
please show the whole iif function
None of the functions does in TfrxMemoView in my report.
Here is how my program:
TfrxReport in TForm (main form).
TfrxDBDataset in TDatamodule.
TFrxDesigner in TFrame in TForm (main form)
And use TntWare (Unicode) !
Is it possible that the use of TFrame be the cause of the problem?
PS: this zip containt my app and reports !
To use the internal designer then click on the ComboBox and choose "Concepteur de modeles"!
The reports are in the folder under "Feuilles".
The report I test and who is not working "V2_Standard.fr4" it is used in the selection "Tirage rapide de PNJ" or "Feuille de personnages" of the ComboBox.
XML files that are used are in the folder under "Data"
the only other thing i can think of that would not allow the expression to work
is the convert null setting of the report engine if set to false you will not get a zero and the expression will not equate to a boolean result when a null value is encountered.