When programming a single user database, you can store values (text or numbers) that you want to keep in one or more permanent variables. These values will be saved when you save the database. Permanent values can be used with shared databases, but they aren’t shared. Each local copy of the database has it’s own private copy of the permanent variables. There is no way that one user can find out what another user’s permanent variables contain, and no way to change what values are stored in another user’s variables.

If you want to share a variable across the network, you have to use a new kind of variable, a server variable. As you might guess, server variables are kept on the server. Panorama has several statements and functions that allow a procedure to create, modify and access server variables. The rest of this page introduces these operations, with links to further information.

Creating and Accessing Server Variables

The most common way to create a server variable is with the letservervariable statement. This is like an assignment statement, but instead of creating a variable on the local computer, it creates it on the server computer. This code creates a server variable named flagURL and stores the URL for a photo of an american flag in the variable. (Note that all of these examples assume that the currently active database is a shared database.)

letservervariable flagURL = "https://www.worldatlas.com/r/w728-h425-c728x425/upload/8e/6f/eb/shutterstock-61933045.jpg"

Later, anyone on any computer that shares this database can access this URL by using the servervariable( function, like this:

let myflag = servervariable("flagURL")

Now we’ve got this flag url and we could use it to download the JPG image, display it in a web browser view, or whatever we want.

Creating a Shared Counter

A common use for server variables is to create a counter that is shared among all of the users of the database. Using the adjustservervariable( function, any user can increment or decrement the value of the counter, and best of all, they can do so in an “atomic” way that is guaranteed to be cooperative between multiple users, even if multiple computers want to change the count at one time.

To illustrate this, suppose you want to keep track of how many times invoices have been printed to a PDF file – keeping track of the count no matter what computer was used to do the printing. This example shows how this can be done.

let ipcount = adjustservervariable("InvoicePrintCount",1)
printtopdf "invoices.pdf","Form","Invoice Template"

Each time this code runs, the InvoicePrintCount server variable is incremented by one (1, 2, 3, 4, etc.). This calculation is done on the server and stored on the server. The adjustservervariable( function allows you to access the calculated number, in case you want to use it somewhere else (you don’t have to use it anywhere else, though).

Destroying a Server Variable

If we’re done with a web server variable it can be destroyed with the undefineservervariable function, like this.

undefine "flagURL"

This removes the variable from the server, so no one will be able to access it or its contents any more. So take care with this statement. Note: This statement can only destroy one server variable at a time, if you want to destroy many variables, you’ll have to use this statement over and over.

Getting Information about Sever Variables

To get a list of all the server variables belonging to a database, use the servervariables( function.


This function returns a carriage return delimited list of the available server variables. You could use this list to see if a particular server variable has even been created yet.

To get both the list of variables and the contents themselves, use the servervariables( function. This returns a dictionary that contain all of the server variable names and their values. For example, if you are not sure what server variables belong to the Contacts database, you can use this code to access and display all of the variables.


Or you could grab the dictionary and then extract values from individual items, like this.

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

Keep in mind when you do this that these values immediately start going stale. If a user on another computer updates the CITY server variable 5 minutes from now, you’re copy will still have the old copy. So it’s best not to hold on to these values for very long, unless you’re not worried about them being stale.

Learn More

See Also