PTM Logo Version 0.5.1 Beta
Home    SVN    Downloads    Documentation    Forum    Contact
This Site is 100%
Powered by PTM

SourceForge.net Logo
Documentation
I   Index
II   GNU GPL
III   Description
IV   Installation
V   Language Overview
VI   Tags
  DO
  DISPLAY
  FILE
  NOHTML
  PREPROCESS
  REQUIRE
  TEMPLATE
VII   Variables
VIII   Functions
IX   Modules
Documentation
View / Download this file.
---------------
PREPROCESS TAGS
---------------

  ----------
  TAG FORMAT
  ----------

    Where "Perl" represents your Perl code:

    <?PREPROCESS Perl; PREPROCESS?>
    <?preprocess Perl; preprocess?>
    <?preprocess Perl; ?>
    <?: Perl; :?>
    <?: Perl; ?>
    <?:
      Perl;
    ?>

  -----------
  DESCRIPTION
  -----------

    The PREPROCESS tag, similar to the DO tag, is designed to allow the
    developer an area in which to put straight Perl code in their PTM documents.
    Any code written here should be formatted the same way in which you would
    write code in a normal Perl/CGI document. This includes the use of
    semicolons (;) at the end of each Perl statement. Unlike the DO tag,
    however, Perl "print" statements should NOT be used in PREPROCESS tags under
    normal circumstances. This is because of the PREPROCESS tag's intended use.
    The contents of PREPROCESS tags are evaluated BEFORE the HTTP headers are
    written for your page. This means that if you want to change the HTTP
    header, or add cookies to the header, this is the time and place to do it.
    Regardless of placement in your PTM documents, PREPROCESS tags will ALWAYS
    be evaluated before your normal PTM scripts. Additionally, the PREPROCESS
    tags have nothing to do with your normal PTM script tags such as DO and
    DISPLAY and are treated as if they were running in a seperate program all
    together. Any variables created or modified in PREPROCESS tags will NOT be
    carried over into your normal PTM script tags. Therefore, if you declare
    variable $x in a PREPROCESS tag, it's value will NOT be accessible in a DO
    tag. The exception to this rule is for predefined global variables. The
    predefined variables such as $_HEADER, %_POST, %_COOKIES, etc. are available
    to you in both PREPROCESS and standard PTM tags, and any modification to
    them WILL be carried over from PREPROCESS to standard tags. The intent here
    is to allow you to preprocess the most important data before anything is
    printed out to your end users on the web.

  --------------
  USAGE EXAMPLES
  --------------

    --------------------------------------------------------------------------
    Example 1: Redirecting to Another Page after 5 seconds Via the HTTP Header
    --------------------------------------------------------------------------

      <?: &set_redirect_header('http://www.mysite.com/page2.ptm', 5); ?>

    --------------------------------------------------------------------------
    Example 2: Starting a Cookie-Based PTM Session Based On a POSTed User Name
    --------------------------------------------------------------------------

      <?:
        if (defined $_POST{'user'}) {
          &start_session($_POST{'user'});
        }
      ?>

    ----------------------------------------------------------------
    Example 3: Deleting a Cookie Named 'COLOR' From the User's Cache
    ----------------------------------------------------------------

      <?:
        if (defined $_COOKIE{'COLOR'})
        {
          &delete_cookie('COLOR');
        }
      ?>
Home    SVN    Downloads    Documentation    Forum    Contact