A sample document

Here is a sample dialog

Save this in test.l
-schema=lrschema.phplib

After-Init:
    (--) Ok                                 -> User-Entered
          + display-homepage
          + terminate-the-program

User-Entered:
    (--) Ok                                 -> Main-Menu-Choice-Made
          + display-message
          + display-main-menu
          + terminate-the-program
    (--) Leave                              -> After-Init
          + display-goodbye-message
          + terminate-the-program

Main-Menu-Choice-Made:
    (--) One                                -> Main-Menu-Choice-Made
          + display-choice-one
          + display-main-menu
          + terminate-the-program
    (--) Two                                -> Main-Menu-Choice-Made
          + display-choice-two
          + display-main-menu
          + terminate-the-program
    (--) Leave                              -> After-Init
          + display-goodbye-message
          + terminate-the-program

Here is the generated .php file

Then run libero on it, you will get a test.d file (which I do not include here) and a .php file.

the php file will look like:

<?php
//=============================================================================
//
//   test.php - description of PHP program
//
//   Written:    99/01/13  Your Name
//   Revised:    99/01/13
//
//   Skeleton generated by LIBERO 2.30 on 13 Jan, 1999,  2:07.
//=============================================================================


class My_Session extends Session {
  var $classname = "My_Session"; ## Persistence support

  var $mode       = "cookie";
  var $lifetime   = 0;            ## use session cookies

  ## DB_Sql subclass and database table to use
  var $database_class = "DB_Poe";
  var $database_table = "active_sessions";
}

$PAGE = 'test.php3';


//----------------------------------------------------------------------------
//   Functions defined by libero dialog - code to be modified by hand
//   Generated by LIBERO 2.30 on 13 Jan, 1999,  2:07.
//   Schema file used: lrschema.php
//----------------------------------------------------------------------------

//-- Function's skeleton is produced by libero dialog ------------------------

// Tip:
//  don't forget that the fsm can reenter any state which generates a
//  terminate-ther-program event (if the user reload the page)

/*########################   INITIALISE THE PROGRAM   #######################*/

function initialise_the_program ()
{
  global $LR_state, $LR_thisState, $LR_nextState;
  global $LR_event, $LR_thisEvent, $LR_nextEvent;
  global $the_next_event;
  global $context_id, $cid, $eid;
  global $sess;

  page_open(array("sess" => "My_Session"));

#  echo "Context match: $context_id <-> $cid
\n"; # echo "State: $LR_thisState -> $LR_nextState
\n"; # echo "Event: $LR_thisEvent -> $eid
\n"; $sess->register("LR_thisState"); $sess->register("LR_thisEvent"); $sess->register("LR_nextState"); $sess->register("context_id"); if ($context_id == $cid and isset($eid)) { $LR_state = $LR_nextState; $LR_event = $eid; } elseif (isset($LR_thisState) and isset($LR_thisEvent)) { $LR_state = $LR_thisState; $LR_event = $LR_thisEvent; } else { $LR_event = $GLOBALS ['ok_event']; } $the_next_event = $LR_event; $context_id = $context_id + 1; # echo "Now in state $LR_state, event $LR_event, context $context_id
\n"; } /*########################## GET EXTERNAL EVENT #########################*/ function get_external_event () { } /*######################## TERMINATE THE PROGRAM ########################*/ function terminate_the_program () { $GLOBALS[ 'the_next_event' ] = $GLOBALS[ 'terminate_event' ]; } /*########################## DISPLAY CHOICE ONE #########################*/ function display_choice_one () { } /*########################## DISPLAY CHOICE TWO #########################*/ function display_choice_two () { } /*####################### DISPLAY GOODBYE MESSAGE #######################*/ function display_goodbye_message () { } /*########################### DISPLAY HOMEPAGE ##########################*/ function display_homepage () { } /*########################## DISPLAY MAIN MENU ##########################*/ function display_main_menu () { } /*########################### DISPLAY MESSAGE ###########################*/ function display_message () { } require 'test.d'; // Include dialog interpreter
NOTICE that I had to move to the last line the "require statement"

Here is the difference I applied to the .php file

*** test.php	Wed Jan 13 02:07:48 1999
--- test_updated.php	Wed Jan 13 02:14:04 1999
***************
*** 92,104 ****

  }

-   require 'test.d';                      //   Include dialog interpreter
-
  /*##########################   DISPLAY CHOICE ONE   #########################*/

  function display_choice_one ()
  {
!
  }


--- 92,104 ----

  }

  /*##########################   DISPLAY CHOICE ONE   #########################*/

  function display_choice_one ()
  {
! ?>
!   You made choice <b>ONE</b><br>
! <?
  }


***************
*** 106,112 ****

  function display_choice_two ()
  {
!
  }


--- 106,114 ----

  function display_choice_two ()
  {
! ?>
!   You made choice <b>TWO</b><br>
! <?
  }


***************
*** 114,120 ****
--- 116,125 ----

  function display_goodbye_message ()
  {
+   global $PAGE, $context_id, $ok_event, $leave_event;

+   echo "<br>Ciao</b><br>";
+   echo "<A href=$PAGE?cid=$context_id&eid=$ok_event>Restart</A><br>";
  }


***************
*** 122,128 ****
--- 127,136 ----

  function display_homepage ()
  {
+   global $PAGE, $context_id, $ok_event, $leave_event;

+   echo "<A href=$PAGE?cid=$context_id&eid=$ok_event>Enter the site</A><br>";
+   echo "<A href=$PAGE?cid=$context_id&eid=$leave_event>Leave</A><br>";
  }


***************
*** 130,136 ****
--- 138,148 ----

  function display_main_menu ()
  {
+   global $PAGE, $context_id, $one_event, $two_event;

+   echo "<A href=$PAGE?cid=$context_id&eid=$one_event>Choice ONE</A><br>";
+   echo "<A href=$PAGE?cid=$context_id&eid=$two_event>Choice TWO</A><br>";
+   echo "<A href=$PAGE?cid=$context_id&eid=$leave_event>Leave</A><br>";
  }


***************
*** 138,143 ****

  function display_message ()
  {
!
  }

--- 150,159 ----

  function display_message ()
  {
! ?>
!   Bienvenue sur notre site<br>
! <?
  }
+
+   require 'test.d';                      //   Include dialog interpreter

When run with debug information, this will gives you the following results:

Hereafter is presented a sample sequence of screens:
  1. Enter the site
    Leave

  2. Context match: 2 <-> 2
    State: 0 -> 1
    Event: 1 -> 1
    Now in state 1, event 1, context 3
    
    User-Entered:
    (--) Ok-Event
    + Display-Message
    Bienvenue sur notre site
    + Display-Main-Menu
    Choice ONE
    Choice TWO
    Leave
    + Terminate-The-Program
    
  3. Context match: 3 <-> 3
    State: 1 -> 2
    Event: 1 -> 2
    Now in state 2, event 2, context 4
    
    Main-Menu-Choice-Made:
    (--) One-Event
    + Display-Choice-One
    You made choice ONE
    + Display-Main-Menu
    Choice ONE
    Choice TWO
    Leave
    + Terminate-The-Program
    
  4. Context match: 4 <-> 4
    State: 2 -> 2
    Event: 2 -> 3
    Now in state 2, event 3, context 5
    
    Main-Menu-Choice-Made:
    (--) Two-Event
    + Display-Choice-Two
    You made choice TWO
    + Display-Main-Menu
    Choice ONE
    Choice TWO
    Leave
    + Terminate-The-Program
    
  5. Context match: 5 <-> 5
    State: 2 -> 2
    Event: 3 -> 2
    Now in state 2, event 2, context 6
    
    Main-Menu-Choice-Made:
    (--) One-Event
    + Display-Choice-One
    You made choice ONE
    + Display-Main-Menu
    Choice ONE
    Choice TWO
    Leave
    + Terminate-The-Program
    
  6. Context match: 6 <-> 6
    State: 2 -> 2
    Event: 2 ->
    Now in state 2, event , context 7
    
    Main-Menu-Choice-Made:
    (--)
    + Display-Goodbye-Message
    
    Ciao
    Restart
    + Terminate-The-Program
    

| << | < | > | >>
| The PHP3 Libero Schema | A sample document