Please enable JavaScript to view this site.

R:BASE 11 Help

Navigation: Glossary > A

ampersand variable

Scroll Prev Top Next More

Sets the first variable equal to the exact contents of a second variable; the ampersand tells R:BASE to evaluate the contents of the variable first.

 

For example, if varname=(2+3), then &varname will be the value 5.

 

You use dot and ampersand (&) variables differently. A dot variable stores a single value. An ampersand variable holds any portion or all of one command, such as a list of column names or a complete expression. If you store an expression in an ampersand variable, the result of the expression is used in the command.

 

SET VARIABLE vcollist = 'transid, custid, empid'

SELECT &vcollist FROM transmaster

 

The result of the SELECT command is the same as entering:

 

SELECT transid, custid, empid FROM transmaster

 

You can include commands in an ampersand variable since R:BASE interprets the contents of the variable before using it. Thus an ampersand variable could contain all or a portion of a command such as a WHERE clause. However, the variable cannot contain more than one complete command or be used inside parentheses. In addition, you cannot use a semicolon to string together multiple commands within an ampersand variable.