[cgiapp] Program format (this is the way I write my code -help?)

Stewart Heckenberg stewart.heckenberg at gmail.com
Wed Feb 13 19:29:09 EST 2008


Hi Lou,

Actually you're close, but not close enough :)

cgiapp actually allows you to get rid of all your if/else logic and
instead use what are called "run modes", which in terms of your games
are all the action/packets, e.g. instead of:

 if ($Input{Action} eq "Log In")

you would use:

sub login {...

and to trigger that sub to run, you set a query parameter called "rm"
to be "login", e.g. foo.cgi?rm=login

That's how cgiapp works -- instead of if/else blocks for your logic,
you use subs, and to execute a particular sub you merely set the rm
param to be the name of that runmode/sub. Have a look at the cgiapp
documentation for some examples.

Hope this helps :)

Kind regards,
Stew

On 14/02/2008, Lou Hernsen <lhernsen1015 at wowway.com> wrote:
> Hallo
> I am writing an online game. I have a main .cgi and am using packages which
> are "required" as needed.
> My .cgi is one long if-elsif-else all based on what action you make in the
> game. I do it this way so I can complete one packet at a time to do a
> certain thing.
> All files are read in the .cgi and vars passes to packages as needed..... am
> I even close in my method?
>
> >>>>>Mind you, this is a hobby to me.. all self taught....<<<<<<<
>
> ANY suggestion for books on program format would be helpfull.. thanks
> comments welcome.. try not to grind me into the dust, please LOL
> thanks
> Lou
>
> here is an example.
>
>  if ($Input{Action} eq "Log In")
>  {
>   $Pm{Status}=Login::LogIn("$Input{Name}","$Input{PW}");
>   exit;
>  }
>  elsif ($Input{Action} eq "New Player")
>  {
>   Login::NewPlayer();
>   exit;
>  }
>  elsif ($Input{Action} eq "Create Player")
>  {
>   Login::CreatePlayer("$Input{Name}","$Input{PW},"$Input{Gender}";
>   exit;
>  }
>  elsif ($Input{Action} eq "EmailLogin")
>  {
>   $Pm{Status}=Login::EmailLogin("$Input{Name}","$Input{SN}");
>   exit;
>  }
>
>
> #####  CGI::Application community mailing list  ################
> ##                                                            ##
> ##  To unsubscribe, or change your message delivery options,  ##
> ##  visit:  http://lists.openlib.org/mailman/listinfo/cgiapp    ##
> ##                                                            ##
> ##  Web archive:   http://lists.openlib.org/pipermail/cgiapp/   ##
> ##  Wiki:          http://cgiapp.erlbaum.net/                 ##
> ##                                                            ##
> ################################################################
>
>


More information about the cgiapp mailing list