convertvariablestoconstants
ORIGINALFORMULA
,
NEWFORMULA

The convertvariablestoconstants statement converts all of the variables in a formula into constant values.


Parameters

This statement has two parameters:

originalformula – source text of formula.

newformula – field or variable to receive the modified formula. If this parameter is missing, the first parameter must be a field or variable containing the formula, and the modified formula will be placed back into that field or variable.


Description

This statement converts all of the variables in a formula into constant values. This essentially “freezes” the formula, allowing it to be used later in a different context where the original variables may no longer be available. For example, you could transfer the formula from one computer to another (perhaps client to server), or store the formula and use it again at a later time.

For example, consider this program that prompts for a zip code and distance, and then saves a formula in a permanent variable named searchFormula.

let searchZip = ""
gettext "Zip Code",searchZip
let searchDistance = "10"
gettext "Search Distance (miles)",searchDistance
searchDistance = val(searchDistance)
letpermanent searchFormula = {zipdistance(searchZip,ZipCode)<searchDistance}
convertvariablestoconstants searchFormula

Suppose you run this formula, and enter 91306 as the zip code and 15 as the distance. The formula stored in the permanent variable has been converted from:

zipdistance(searchZip,ZipCode)<searchDistance

into:

zipdistance("91306",ZipCode),15

As you can see, the two variables in this formula have been replaced with their actual values. (The ZipCode field in the formula has not been touched.)

Later you can run another program that uses this formula to run a selection:

execute "select "+searchFormula

This selection will work fine even though the searchZip and searchDistance variables don’t exist any more. Even though the variables are gone, their values have been hard coded into the saved formula.

Here’s a slightly different version of the original program. In this case, the original formula has been embedded into the convertvariablestoconstants statement directly, with the result coming into the second parameter (searchFormula). When using two parameters like this, the formula should not be quoted as it was in the first example).

let searchZip = ""
gettext "Zip Code",searchZip
let searchDistance = "10"
gettext "Search Distance (miles)",searchDistance
searchDistance = val(searchDistance)
permanent searchFormula
convertvariablestoconstants zipdistance(searchZip,ZipCode)<searchDistance,searchFormula

These examples may seem a bit contrived, obviously you could arrange to store the searchZip and searchDistance values separately in permanent variables. The advantage of the convertvariablestoconstants statement is that it allows you to construct and save an arbitrarily complex formula as a single entity, with no special arrangements for saving whatever variables are included. This statement is used this way internally by ProVUE for several features in Panorama Server, especially for passing formulas between computers.


See Also


History

VersionStatusNotes
10.2NewNew in this version.