[TOC] [Prev] [Next] [Bottom]



<@VAR>

Syntax

<@VAR NAME=name [SCOPE=scope] [FORMAT=format] [APREFIX=aprefix] [ASUFFIX=asuffix] [RPREFIX=rprefix] [RSUFFIX=rsuffix] [CPREFIX=cprefix] [CSUFFIX=csuffix]
[TYPE=
text] [ENCODING=encoding]>

Description

<@VAR> retrieves the contents of a variable, and, depending on the operation being performed, formats the data appropriately. Any of the attribute values of <@VAR> may be specified by other meta tags.

Scalars

When retrieving the contents of a scalar (standard variable), the result of <@VAR> is always a text string.

Arrays

<@VAR> may also be used to retrieve an array. However, <@VAR> does different things to arrays based on context: <@VAR> converts the array to text whenever the result of the tag is returned in Results HTML, or when TYPE=text is specified; <@VAR> returns an internal reference to the array when it is used to copy an array from one place to another. So, if <@VAR> is used within <@ASSIGN>, then no conversion to text is performed (unless the TYPE="text" attribute is specified).

The format outputted is specified by the following attributes:

APREFIX: the array prefix string
ASUFFIX: the array suffix string
RPREFIX: the row prefix string
RSUFFIX: the row suffix string
CPREFIX: the column prefix string
CSUFFIX: the column suffix string

For more information, see "aPrefix", "aSuffix" , "cPrefix" , "cSuffix" , "rPrefix" and "rSuffix" .

These attributes are used for defining the appropriate text for display, before and after the specific components of the array are displayed. This is useful for automatically displaying the contents of arrays as tables or ordered lists. The default values of these attributes are set by configuration variables with the same name.

Scoping Rules

Scoping is the method by which variables can be organized and disposed of in an orderly and convenient fashion. There are various levels of scoping, each of which has an appropriate purpose:

For more information, see "Configuration Variables".

  • System Scope contains any variables that are general to all users. This scope contains only server configuration variables. To use this scope, specify SCOPE=system or SCOPE=sys.

For more information, see "domainScopeKey".

  • Domain Scope contains variables that a class of users can share. These variables can be accessed from any application file run by any user within the class. This scope is defined by setting the system configuration variable domainScopeKey appropriately; that is, setting it to a value that can differentiate such users. To use this scope, specify SCOPE=domain.

For more information, see "userKey, altuserKey".

  • User Scope contains variables that a user defines and expects to be able to access from many application files or invocations of single application files. To use this scope, specify SCOPE=user or SCOPE=usr.
  • Local Scope contains variables that should be unique to every invocation of any application file. For example, this scope could be used for temporary variables that reformat output from a search action. All variables of this scope are removed when the application file concludes execution. To use this scope, specify SCOPE=local, or SCOPE=doc.
  • Cookie Scope contains variables that are sent to the user's Web browser as cookies (that is, a small text file kept by the Web browser for a specified amount of time). To use this scope specify SCOPE=cookie.
Specifying Scopes

There are two methods of specifying a variable with a particular scope.

  • Use the SCOPE=scope attribute.
  • Leave out the SCOPE=scope attribute and specify a variable name as scope$myvariable; scope may be any valid scope specifier.

Behavior is undefined when both methods are used at once.

Scoping Precedence

When no scope is specified, Tango must find the variable by looking for the variable name within the various scopes. Tango has a set order in which it tries to find scopes. They are:

local--»user--»domain--»system


!Note: Variable scoping precedence for variables and configuration variables does not check cookie scope.


For more information, see "domainScopeKey".

If domainScopeKey resolves to empty for this user, then domain is not checked.

Variable Shortcut Syntax

There is a shortcut syntax for returning variables as well, with or without scope: use a double "@" and the name of the variable. The following two notations in each of the examples are equivalent:

<@VAR NAME="homer">
@@homer

<@VAR NAME="homer" SCOPE="domain">
@@domain$homer

Configuration Variables

For a detailed list of configuration variables, see Chapter 2 of the Meta Tags and Configuration Variables manual.

Tango reserves special variables that contribute to the configuration of the server and also that provide default behaviors for users.

For more information, see "About Variables" in Chapter 7 of the User's Guide. For more information on setting configuration variables using the config.taf file, see "Tango Server Configuration File" in the User's Guide.

System variables that contribute to the basic configuration of the server only exist in the system scope. System variables that provide default behaviors for users are subject to the full scoping mechanism described previously. Default values read from the preference file are stored in the system scope.

Examples

Accessing a local variable:

<@VAR NAME="foo" SCOPE="local">
<@VAR NAME="local$foo">
@@local$foo

Accessing a user variable:

<@VAR NAME="foo" SCOPE="user">
<@VAR NAME="user$foo">
@@user$foo
<@VAR NAME="foo" SCOPE="usr">
<@VAR NAME="usr$foo">
@@usr$foo

Accessing a system scope variable:

<@VAR NAME="foo" SCOPE="system">
<@VAR NAME="system$foo">
@@system$foo
<@VAR NAME="foo" SCOPE="sys">
<@VAR NAME="sys$foo">
@@sys$foo

Accessing a domain scope variable:

<@VAR NAME="foo" SCOPE="domain">
<@VAR NAME="domain$foo">
@@domain$foo

Accessing variable using scoping precedence:

<@VAR NAME="foo" >
@@foo

Getting an array and formatting it for Results HTML:

<@VAR NAME="array">

Getting part of an array and formatting it for Results HTML:

<@VAR NAME="array[3,*]">

Getting an array and formatting it for Results HTML with attributes:

<@VAR NAME="array" APREFIX='<TABLE BORDER="2">' ASUFFIX= </TABLE>' RPREFIX='<TR>' RSUFFIX='</TR>' CPREFIX='<TD BORDER="2">' CSUFFIX='</TD>'>

Copying an array without formatting it:

<@ASSIGN NAME="array2" VALUE="<@VAR NAME='array'>">

Copying part of an array without formatting it:

<@ASSIGN NAME="array2" VALUE="<@VAR NAME='array[*,4]'>">

Copying the formatted representation of an array to a variable:

<@ASSIGN NAME="array2" VALUE="<@VAR NAME='array'
FORMAT=text>">

See Also

<@ARRAY>
<@ASSIGN>
Encoding Attribute
Format Attribute



[TOC] [Prev] [Next] [Bottom]



docs@pervasive.com

Copyright © 1998, Pervasive Software Inc. All rights reserved.