Hi Michael,

It may be useful for the prerun_mode() function to auto-log any changes
(in an arrayref of some sort) for access later via
get_previous_runmodes(). 

However, prerun_mode() can only be called during cgiapp_prerun(). Things
get a little odd when we start doing things like Cory suggests (return
$self->main_menu()) in the middle of runmode execution.

I would probably stick with custom logging of runmodes in order to keep
track of all changes:

--- 8< ------
sub log_mode {
        my $self = shift;
        my $mode = shift;
        my $prev = $self->param( '_PREV_MODES' );
        $prev    = [] unless $prev;

        push @$prev, $mode;

        $self->param( '_PREV_MODES' => $prev );
}
--- 8< ------

So, you can access an arrayref of previous runmodes in any function you
desire.

You would have to manually call it before any switches:

$self->log_mode( 'thismode' );
return $self->main_menu;

or in cgiapp_prerun:

$self->log_mode( $mode ); # $mode being what was passed to cgiapp_prerun
$self->prerun_mode( "mainmenu" );

It's easy to see how things went:

my $prev = $self->param( '_PREV_MODES' );
print "prev: $_\n" foreach @$prev;

$prev->[0] being the initial runmode, $prev->[ -1 ] being the runmode
prior to the current one.

Someone may have a better solution...

-Brian Cassidy

> -----Original Message-----
> From: Michael Hirmke [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, July 16, 2003 11:18 AM
> To: [EMAIL PROTECTED]
> Subject: [cgiapp] get_previous_runmode() ?
> 
> Hi *,
> 
> one more question:
> 
> Would it be possible for C::A to not only maintain the current
runmode,
> but also the previous one? A function like get_previous_runmode()
would
> be really nice. What do you think about it?
> 
> I know, I can implement it in my own code - that is, what I do at the
> moment - but IMHO it would be a desirable improvement for C::A.


http://www.gordano.com - Messaging for educators.

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[EMAIL PROTECTED]/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to