# # General logic stub -- template # # This file plugs into state.cgi as in-line code, and is executed # at line 7 of exec_script(). Thus, it inherits full access to everything # visible from exec_script(). # # Later, this mechanism may be abstracted into something to do with the # AutoLoader. # # # Requirements: # # 1. Determine what state we're in by checking which 'submit' button # was pressed. # # 2. From (1), change $s->STATE and $s->NEXT accordingly. # # If we've gone BACK: # scan $s->SEQ for STATE followed by NEXT # set STATE to whatever came before STATE, and NEXT to STATE # If we're going NEXT: # set STATE to NEXT, and NEXT to whatever comes afterwards # # 3. If a radical flow-of-control branch is indicated, re-write @{ $s->SEQ } # # 4. Any Other Business [logic] # # 5. End with a true statement (e.g. 1;), like an olde-worlde perl4 package # ############################################################################# # # 1. Do forward/back button state adjustments # if (grep(/next/i, $c->param()) != 0) { # we have a NEXT button warn "FORWARD button pressed\n"; $s = forward($s); } elsif (grep(/back/i, $c->param()) != 0) { # we have a BACK button warn "BACK button pressed\n"; $s = rewind($s); } else { # something else warn "EEk! I couldn't tell which submit button was pressed!\n"; warn '[', join('][', $c->param()), ']'; } warn "3.pl: set STATE to ", $s->{'STATE'}, " and NEXT to ", $s->{'NEXT'}, "\n"; # # 3. Re-write @{$s->{'SEQ'}} if necessary # $CGI::ApacheState::MONITOR && warn "re-writing s->SEQ here ... \n"; # # 4. Business logic! # $CGI::ApacheState::MONITOR && warn "Executing business logic\n"; if ($s->{'STATE'} eq $s->{'NEXT'}) { $s->{'GLOBALERR'} = "You are in the prefix state. if this was a " . "real application you would be logged off " . " -- you can't go back before the beginning."; } # we're not doing anything here -- we're in the final state # # 5. And revert back to exec_script() ... # 1;