In pages (.pg) you can use directives as described in previous chapters. But you can use following variables, too:
Global hash which is often used for transporting values between action and page. Be careful, its validity is limited by one masser cycle (which means that it's cleared after processing all actions and pages in one request).
So you cannot use it to remember values between two requests (you cannot know which masser will process request if there is running more than one). You must use HTML and/or HTTP ways to do it (hidden fields, cookies). See persistent hash described in next text.
While coding you can use G(item) form, so print G(name);
and
print $g{'name'};
are equal.
Global hash. Main difference from %g is its persistence between requests. You can use it mainly for data filled to it in init action or to remember some value between two masser cycles (request process).
Be careful, this is very limited in case masser is running as more than one instance (fast-cgi technology enables this and it's very useful). No one can say you, what masser instance (process) will get next request. This hash is persistent only in one instance of masser!
Be careful while using this variable, it's not intended to store large pieces of data.
You cannot use it to send information between two applications even in one masser instance, every application has its own hash.
This hash contains texts loaded from language file according to selected language (LANG variable). Read only (changes will be dropped after processing request).
This hash contains configuration read from <app>.conf. Read only (changes will be dropped after processing request).
This variable contains actual application (as param('APP')).
This variable contains actually running page (as param('PG')).
This variable contains actually selected language (as param('LANG'));
These variables contain DeltaX::Database objects numbered according to application configuration (see dbX_* parameters). Note: $db = $db1.
You can use following functions in your code:
error, warn, info, debug, trace
Functions from DeltaX::Trace, used for printing messages to application log.
break_page
This function allows you to change page, which is processed by masser (value of $pg and param('PG'), but you cannot do this by changing these values).
The only parameter of this function is new page name. Masser then does this:
Remember that everything, what was printed till calling this function, cannot (and is not) be undone.
... <? if ($something) { ?> <?!include file1.inc> <? } else { ?> <?!include file2.inc> <? } ?>
You can use everything (except break_page) as in pages here (see previous chapter). I only want to recommend here to use actions for doing some work and pages for printing output. It's not technical but logical difference. There are situations in which it probably cannot be done, but at least try to do it.
Modules for masser are in fact same as "classic" perl modules. There are only two differences: You can place it outside perl lib directory (but masser must find it) and you can use some variables from masser (they are %conf, %txt, %g, %p, $app, $pg, $lang, $db, $dbX) this way:
package xy; ... use vars qw/%txt %conf $app/; import main; ...
I only want to discuss here using GLB(...) for inserting information from global hash %g: You must remember that this replacement is done in function page_start, so this hash (or at least keys used in javascript or css files) must be filled before calling page_start() (so calling function which fills it, include, module or code which fills it) must be placed before its calling.