Variable Initialization

Stimulsoft Reports.WEB discussion
Daniel Schmitz
Posts: 32
Joined: Tue Jul 03, 2012 2:16 pm

Variable Initialization

Post by Daniel Schmitz »

Hello.

I'm trying to initialize a variable using the "expression" option, and setting it's value to a field in my Bussiness Objects.
But when I run my report, I get an generic error message.
My code seems like:

myIntVar = MyBussinessObject.AnIntValue

Thanks.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Variable Initialization

Post by HighAley »

Hello.

Where do you try to initialize variable with this expression?
Please, describe your issue more detailed.

Thank you.
Daniel Schmitz
Posts: 32
Joined: Tue Jul 03, 2012 2:16 pm

Re: Variable Initialization

Post by Daniel Schmitz »

Hello.

I'm trying to initialize the variable in the New Variable window.
I've attached a printscreen of what I'm trying to do.

Thanks.
Attachments
Var.png
Var.png (14.06 KiB) Viewed 4595 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Variable Initialization

Post by HighAley »

Hello.

Please, try to enable the Read Only option. Then the variable will be calculated each time.

Thank you.
Daniel Schmitz
Posts: 32
Joined: Tue Jul 03, 2012 2:16 pm

Re: Variable Initialization

Post by Daniel Schmitz »

Hello.

Thanks for the quickly reply.
It worked, but sometimes this variable needs to be reassigned, as I use it as a counter.
So in my case, I cannot set it as Read Only.
What can I do?

Thanks.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Variable Initialization

Post by HighAley »

Hello, Daniel.

You could change the variable's value in a BeforePrint event of a Data Band or some where else. And don't use the init expression.

Thank you.
Daniel Schmitz
Posts: 32
Joined: Tue Jul 03, 2012 2:16 pm

Re: Variable Initialization

Post by Daniel Schmitz »

Hello.

Yes, I'm changing it's value in the BeforePrint event of my PageHeader, in this case counting the number of pages, incrementing it's value by 1.
But I need to initialize it by a value that comes from my bussiness object.
So, if my BO has the value 5, I need start counting from page 6: 6, 7, 8, ...
Sorry if I was not so clear before.

Thanks.
Daniel Schmitz
Posts: 32
Joined: Tue Jul 03, 2012 2:16 pm

Re: Variable Initialization

Post by Daniel Schmitz »

Hello.

I was debugging my code, searching for something, and the error I got in the file I've attached.
I got the same error debugging your sample code.

Another solution I've tryied was to use the PageNumber property.
It worked fine, but I could'nt get how do I reset the counter, as I need it to happen when PageNumber get equals to a parameter I have.

Thanks.
Attachments
Error.txt
(4.69 KiB) Downloaded 457 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Variable Initialization

Post by HighAley »

Hello, Daniel.
Daniel Schmitz wrote:I was debugging my code, searching for something, and the error I got in the file I've attached.
I got the same error debugging your sample code.
It seems that you are using partial trust mode. Please, try to set next option:

Code: Select all

StiOptions.Engine.FullTrust = false;
Daniel Schmitz wrote:Another solution I've tryied was to use the PageNumber property.
It worked fine, but I could'nt get how do I reset the counter, as I need it to happen when PageNumber get equals to a parameter I have.
You could try to use Reset Page Number property of the Page Header.

Thank you.
Daniel Schmitz
Posts: 32
Joined: Tue Jul 03, 2012 2:16 pm

Re: Variable Initialization

Post by Daniel Schmitz »

Hello.

I tried to set FullTrust = false, but now the report don't load any of my data.

I've also tried to use the Reset Page Number property in the AfterPrint event of my PageHeaderBand1, with a text displaying the PageNumber in it:
if(PageNumber == 10)
{
PageHeaderBand1.ResetPageNumber = true;
}
else
{
PageHeaderBand1.ResetPageNumber = false;
}

But for some reason, PageNumber == 10 it's getting true when my text is displying 8.
Is there something wrong?

Thanks
Post Reply