Select

This command changes the current work area. Don't confuse this command with the SELECT-SQL command or with the SELECT() function.

Usage

SELECT cAlias | nWorkArea
SELECT makes the specified work area current. If nWork area is 0, SELECT switches to the lowest-numbered unused work area. This is handy when opening a series of tables.We recommend that you never use SELECT with an explicitly numbered work area (i.e., SELECT 5). There's no reason on earth to have any idea which work area a particular table is open in.

Example

SELECT 0        && move to a new work area
USE Customer
* Move to another area and open another table
SELECT 0
USE Orders
* Switch back to Customer
SELECT Customer
* At the beginning of a "black box" routine,
* it's good to save the work area; then,
* at the end, restore it.
LOCAL nSelect
nSelect = SELECT()
* now do some processing that changes the work area
* now restore using indirect reference
SELECT (nSelect)
The last line of the example makes it look as if SELECT is doing name evaluation and getting a number. In fact, what's really going on is that the parentheses are forcing nSelect to be evaluated before it's used in the command. Without the parentheses, VFP would try to find a work area with an alias of nSelect.It's also worth noting that, generally, it's better to save the work area using SELECT() than using ALIAS(). With ALIAS(), you have to check whether the variable is empty before restoring the work area; since SELECT() always returns the number of a valid work area, it doesn't require that extra check.

See Also

Select-SQL, Select(), Use


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .