defineservervariable
DATABASE
,
VARIABLE
,
VALUE

The defineservervariable statement defines the value of a permanent variable on the server. If the variable already exists, it is not touched.


Parameters

This statement has three parameters:

database – name of the database. If this parameter is omitted or is empty, the current database is assumed.

variable – name of the variable. The variable can be specified directly (not quoted), or with a formula.

value – new value to be assigned to the variable. Any type of value is allowed: text, numeric, date, even binary values like dictionaries.


Description

This statement defines the value of a permanent variable on the server associated with the current shared database. If the variable already exists, it is not touched. This statement is useful when you want to initialize a server variable if it has not already been set up, but leave it alone if it has already been set up before.

This example initializes the shared variable defaultAreaCode with the text 714.

defineservervariable defaultAreaCode,"714"

Later, the value could be modified by using the letservervariable, assignservervariable or adjustservervariable statements, but using the defineservervariable statement again will not modify the variables value.

To access this variable, use the servervariable( function, as shown in the example below. This variable can be accessed from any computer that has the shared file that contains the variable open.

servervariable("defaultAreaCode") ☞ 714

If the variable name contains spaces or other punctuation, you must surround the variable name with chevrons (Option-\ and Shift-Option-), like this:

defineservervariable «Default Area Code»,"415"

Normally the variable name is “hard coded” into the code as shown in the examples above, but you have the option of calculating the variable name with a formula. This example will create a different variable depending on the day of the week – MondayClose, TuesdayClose, WednesdayClose, etc.

defineservervariable datepattern( today(),"DayOfWeek")+"Close",time("8pm")

The defineservervariable statement normally initializes a server variable belonging to the current database, but you can specify a different database if you want. The specified database must be a shared database, and it must be currently open. Here is a revised version of the previous example that initializes the server defaultAreaCode variable in the Contacts database instead of the current database.

defineservervariable "Contacts",defaultAreaCode,"213"

See Also


History

VersionStatusNotes
10.2NewNew in this version.