Application Variables
Application variables are similar to aliases, in that you define application variables for each profile in your project. However, unlike aliases, the Web Application Server does not replace references to application variables at publish time. Instead, Web Application Server resolves application variables when a page is executed.
Application variables are "page global" variables, which persist for the lifetime of the session. They can be "seen" by all of the code that executes in an .a5w page. Application variables are always character variables.
Note: You can change an application variable's value, but the new value will not be available in the next session.
How Application Variables Work
When you publish your application, the Web Application Server creates a special file called a5_variables.a5i that it publishes along with all of the other files in your Web Application. Whenever the Web Application Server processes an .a5w page, the a5_variables.a5i page is automatically included in the page, making the variables defined in the a5_variables.a5i pages visible to the Xbasic defined in the page.
For example, assume that for the "Local Webroot" profile you have defined the following Application variables:
appvar1 = "this is the value of appvar1" appvar2 = "this is the value of appvar2" |
When your Web Application is published, Alpha Five will publish the following a5_variables.a5i page:
<%a5 DIM Global appvar1 as C DIM Global appvar2 as C appvar1 = "this is the value of appvar1" appvar2 = "this is the value of appvar2" %> |
Using Application Variables in Xbasic Code
You use an Application variable in your Xbasic code in the same way that you would use any other variable. For example, if you created an .A5W page with this Xbasic:
<%a5 ?"The value of the appvar1 application variable is: " + appvar1 +"<br>" %> |
then, when this page was executed, the browser would show:
"this is the value of appvar1"
In a more practical example, you might have defined an application variable called dataPath whose value is c:\Program files\a5v6\samples\alphasports. Your .A5W page might contain this code:
<%a5 dim t as P t = table.open(dataPath + chr(92) + "customer.dbf") t.order("customer_ID") t.fetch_find(session.customer_id) lastname = t.lastname t.close() %> |
As you see, in this example, the Application variable serves the same purpose as a path Alias, but it works in a different way.
How Alpha Five Searches for the A5_Variables.A5I Page
When executing a .A5I page, the Web Application Server looks in the same folder as the .A5W page for the A5_Variables.A5I page. If an A5_Variables.A5I page is not found in that folder, then it looks in this folder"s parent folder for a A5_Variables.A5I page. If a A5_Variables.A5I is not found in this folder, then it keeps looking up one level in the folder hierarchy until it reaches the top level folder of the Web root.
Creating Application Variables
You can create Application Variables when you define the properties of your profiles.
From the Web Projects Control Panel, click the Profiles button on the toolbar. This displays the Profile Editor.
Select General > Application Variables. This displays the Application Variables Editor. [Picture]

See Also
Creating a New Profile, Using Variables on A5W Pages, Path and Connection String Aliases
Supported By
Alpha Five Version 6 and Above
Limitations
Web publishing applications only.