servervariables(
DATABASE
)

The servervariables( function returns the names and values of all server variables associated with a database. The names and values are returned in a dictionary.


Parameters

This function has one parameter:

database – name of the shared database that contains the server variables. If this parameter is missing or empty, the current database is assumed.


Description

This function returns the names and values of all server variables associated with a database. The names and values are returned in a dictionary, individual values can be extracted with the getdictionaryvalue( function. Depending on your network speed and how busy the server is, there may be a slight delay before this function returns the requested data.

This example uses the dumpdictionary( function to display all of the server variables associated with the current database.

message dumpdictionary(servervariables())

If you want to access an individual server variable, it’s usually more convenient to use the servervariable( function. But if you want to access multiple variables at once, the servervariables( function will usually be faster since it gets all of the variables at once, instead of making separate requests across the network. (The one possible exception would be if there are one or more server variables that contain huge amounts of data, that you don’t need to access at the moment. In that case separately accessing the variables with the small amount of data might be faster. But we generally don’t recommend storing huge amounts of data in a server variable anyway.)

Here is an example that gets the name of the city, state, and sales representative that have been stored as server variables with this database. If this had been done with the servervariable( function it would have required three network requests, but this example gets all the data with a single request.

let vars = servervariables()
let city = getdictionaryvalue(vars,"CITY")
let state = getdictionaryvalue(vars,"STATE")
let salesrep = getdictionaryvalue(vars,"REPRESENTATIVE")

The servervariables( function normally returns the server variables 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 accesses the server variables in the Contacts database instead of the current database.

let vars = servervariables("Contacts")
let city = getdictionaryvalue(vars,"CITY")
let state = getdictionaryvalue(vars,"STATE")
let salesrep = getdictionaryvalue(vars,"REPRESENTATIVE")

See Also


History

VersionStatusNotes
10.2NewNew in this version.