I seem to have a global variable with a value left over from a previous report when it doesn't have a value in the current report. What's the best way to make sure that doesn't happen?
Two dollar signs in front of a variable makes it global. One dollar sign is local. Example $$Test is a global variable, $Test is a local.
I understand that. I need it to be a global variable because it is passed betwen scripts. The problem is that is that when I run another report later that doesn't happen to use it (a CC email address), it still has the value from the previous report. Should I just set it to a blank value " " at the beginning of each report script?
Home > Reference > Script steps reference > Control script steps > Set Variable
It depends on your layout. You could set it to blank. You could delete the variable from that report that doesn't use it. If this is a printout report you could also use "hide when printing" option in the inspector.
I should have been more specific. I have a sub-routine that sends email by filling in the email address, CC email address, subject, and message from global variables that are set in the the script that calls the generic email script. Some reports use the CC email, and some don't, but the global variable is in the sub-routine regardless. If I don't set the global variable for the CC email, I need it to be blank rather than using the last value it held.
Would this work at the beginning of each report script: Set Variable [$$TargetCC, Value: " "] I just don't know the best way to reset it to a blank value.
Yes that will blank $$TargetCC. If the variable is displayed on the screen then you may need to refresh the window, to update the display.
You also do not need the space between your quotes though doing so in this context appears harmless. You could use:
Set Variable [$$TargetCC, Value: ""]
Retrieving data ...