You are correct that all global variables that currently have a value set to them will appear in the data viewer.
I would suggest that you not use global variables unless it is absolutely necessary to do so. They can be a challenge to keep track of and since the Data-Viewer is the one way that you can track global variables that currently exist, I wouldn't want them to not be visible in the viewer.
That said, if you use a script to set the variable to a null value such as Set Variable [$$GlobalVariable ; Value: "" ], it should disappear off the data viewer's list.
Correct. There was no reason to use globals for what I want to do. The lifetime of a script (which doesn't call others) is quite enough. Thanks for the tip about null values.
It may be interesting to note all the different ways you can temporarily store data not specific to any one record:
Global Fields-->Can be used for direct data entry by the user. Can be used as a match field in a relationship. Pay attention to how they work differently in networked versus stand alone environments.
$$Global Variables-->created the first time it is assigned a value and persists until the file in which it was created is closed
$Script Variables--> only persist as long as the script that created it is still running. You can get multiple copies of that variable--each with a different value should your script call itself recursively.
Calculation variables (no dollar sign)--created inside a let function and only persist within the confines of the let function's parenthesis. (But let functions can also assign values to global and script variables.)
Script Parameters--much like script variables, the value(s) in a script parameter persist as long as the script to which the parameter was passed is running and can be accessed with get ( ScriptParameter). But unlike a script variable it can allow you to pass data from a specific button click, script trigger trip, or perform script call and the value can even be passed to a different file if Perform Script is used to perform a script in a different file.
Script Results--Value is passed from sub script to calling script via Exit Script [Expression] and then the calling script can use Get ( ScriptResult ) to access the data--which remains accessible only so long as the calling script is still running. Haven't needed to test this, but presumably, exit script can pass data from one file back to the original file much like a script parameter passes data in the opposite direction.