how to set a default for a script variable?
I often have a memo containing a script variable to show the year the report is about eg [thefeeyear] whose value I pass in at run time.
How can I set a default value so that I can check the preview of the form during design time (ie without compiling and running the whole program without it generating an error like this?
Comments
I'm not sure if this is supported in FR4, but in FR5 and 6 you can create Report Variables in the Designer and assign them a value, which you can override in code before using the report. They may not behave quite the same way, but its what I use.
Thank you. Please can you tell me how you do that so I can look in the right place in FR4. I don't think I've ever seen that feature but I might not be looking in the right place.
Ah! Found it, It's under the report|variables menu option. I didn't realise you could create a new variable there and give it a value at the same time. Thanks for your help, it saves a lot of time when developing
Just remember that report variables are more like macros, they are evaluated as expressions so you have to put quotes IN the variable value for strings. See the Programmers Manual Chapter 2.
I have found that if a FastReport variable's new value has a CRLF in it, then the outer quotes get printed, otherwise they are required to stop FR doing a recursive variable lookup.
I have a function like this: