Setting and Retrieving Variable Values


One of the tools added to the list of commands that access setups is svalue. This command can be used to both set and retrieve the value of a variable for a particular setup or a list of setups. The syntax for svalue is
    svalue [setup=setupList] [name=variableName] [value=integer]
The name keyword identifies the variable that should be acted on. If it is not present, then it defaults to the variable obscnt. The value keyword provides a new value to be assigned to the variable. If the value keyword is not present, then svalue simply returns the value of variable. For example, calling svalue without any arguments is the same as asking for the current value of the variable obscnt. The value keyword must be an integer but may be either an absolute value or a relative value (so that the current value may be incremented or decremented relative to the current value). For example, if value=+1, then the variable identified by the name keyword (or obscnt) will be incremented by 1. If value=1, the variable is set to 1.

In order to keep variables distinct for each setup, the optional keyword setup may be used. This keyword, if present, is used to prepend the setup name in front of the variable. This keyword can actually be a list of setups. No logic is applied to the list of setups. If more than one setup is present, the value that is written is the sum of the returned values for each setup in the list. For example, the command

    svalue setup='A,B' value=+1
would increment the value of the variable obscnt by 1 for both setups A and B and will echo the sum of the new value of obscnt for each setup. Hence, if the value of obscnt was 2 for setup A and 4 for setup B before svalue was called in the above example, then, after the call, the new value of obscnt would be 3 for setup A and 5 for B. Also, svalue would echo the value of 8 (the sum of 3 and 5 from the two setups).

The svalue command provides a handy way to determine if something has been observed previously and how often. An example of how to use this command in an observing script .


(up to Document Overview, back to Specifying Relative and Absolute Times, on to Questions About Constructing Observing Files)
James Morgan

Page last modified: .