Applies To:
  • CitectSCADA 3.00

Summary:
Question: I read the online help on the "Page Environment Dialog Box" but I'm not sure what a page environment variable is or what I can use it for? 

Solution:
A page environment variable is a read only variable that is associated with a given page, template, library object or genie. Because it is read only it can only be set from within Graphics Builder by using the page environment dialog box. The value of the environment variables associated with a given page can be read using the DspGetEnv() cicode function. Page environment variables were introduced into Citect to give added flexibility in making version 3 backward compatible with version 2. In version two pages, page cicode was used to put standard buttons onto pages (page next, page last etc.). In version 3 templates these buttons are already defined so this cicode should not be used. This is controlled by the PageCicodeOn environment variable.

Typically you might use a page environment variable to specify some form of behaviour which is unique to a page. This way you can write a generic piece of cicode which then gets the value of the page environment variable and then uses that data to modify its behaviour. This way you don't have to write a unique piece of cicode for each page. A common example of this would be when creating a menu system. So from a main menu you can press buttons to goto sub pages, then from the sub pages you can press a button which goes back to the higher level menu. You could create unique buttons commands on each page to do this for example:

Page Button Command
Menu1 Sub1 PageDisplay("Sub1");
Menu1 Sub2 PageDisplay("Sub2");
Sub1 Menu PageDisplay("Menu1");
Sub2 Menu PageDisplay("Menu1");

This will be fine for simple menus however when you have many menus this can become complex. It is far better to put a command on the Sub pages which gets the value of a page environment variable and uses that variable to goto the required menu. As this code will be the same for all pages you can then put this code in a template and so you don't have to modify it for any of your pages. For example:

Page Button Command
anypage Menu PageDisplay(DspGetEnv("Menu"));

Then when you create the Sub1 page you put the page environment variable "Menu=Menu1". This is a much cleaner way to configure menus.

This is a very handy feature and you should try to put as much data which is local to that page in the page environment variables. This will make you project much easier to configure and maintain.

 

Keywords:
 

Attachments