共用方式為


TAG( ) Function

Returns a tag name from an open, multiple-entry compound .CDX index file or the name of an open, single-entry .IDX index file.

TAG([CDXFileName[, nTagNumber[, nWorkArea | cTableAlias]]])

Return Values

Character

Parameters

  • CDXFileName
    Specifies the name of the multiple-entry compound .cdx index file from which TAG( ) returns a tag name.

  • nTagNumber
    Specifies a number corresponding to the order in which a tag was created in the compound index file. For example, if nTagNumber is 1, TAG( ) returns the name of the first tag created in the compound index file. If nTagNumber is 2, TAG( ) returns the name of the second tag created, and so on. TAG( ) returns the empty string when nTagNumber exceeds the number of tag names.

    If you omit CDXFileName, TAG( ) returns compound index file tag names and single-entry index file names in a specific order as follows.

    • Names of single-entry index files are returned based on their order in the INDEX clause of USE or SET INDEX.
    • Tag names from the structural compound index file (if one exists for the table) are returned.
    • Tag names from other open compound index files are returned, again in the order in which the tags were created in the compound index files and in the order in which the compound index files are specified in the INDEX clause for USE or SET INDEX.
  • nWorkArea | cTableAlias
    Returns tag names and index file names from files open in another work area. nWorkArea specifies a work area number and cTableAlias specifies a table alias. By default, tag names and index file names are returned from files in the current work area.

Remarks

Tags are index entries in multiple-entry compound .cdx index files created with INDEX.

Note   Multiple-entry compound .cdx index files and single-entry .idx index files can be opened for a table with the INDEX clause in USE or with SET INDEX. A structural compound .cdx index file is automatically opened with its table.

Example

The following example opens the customer table in the testdata database. FOR ... ENDFOR is used to create a loop in which CDX( ) is used to display the name of each structural index.

CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'data\testdata')
USE Customer     && Open customer table

CLEAR
FOR nCount = 1 TO 254
   IF !EMPTY(TAG(nCount))  && Checks for tags in the index
   ? CDX(nCount)     && Display .CDX names
   ELSE
      EXIT  && Exit the loop when no more tags are found
   ENDIF
ENDFOR

See Also

CDX( ) | INDEX | MDX( ) | NDX( ) | SET INDEX | SYS(14) - Index Expression | USE Command