Can I put Multiple handlers in a CGI script?
Phil Davis
phildavis at attbi.com
Tue Aug 27 19:50:01 EDT 2002
----- Original Message -----
From: "Rich Mooney" <tech at paynesparkman.com>
To: "MetaCard Mail List" <metacard at lists.runrev.com>
Sent: Tuesday, August 27, 2002 3:35 PM
Subject: Can I put Multiple handlers in a CGI script?
> As I understand it, a CGI needs to be in the following format:
>
> #! mc
> on Startup
> #script
> end Startup
>
> I also have the impression that any script in this CGI had to be between "on
> Startup" and "end Startup".
Nope. The 'startup' message is the only message MC sends/fires in a CGI script (I think), but it's just another Metatalk message and follows all the same rules as all the others (no nested handlers). From within the 'startup' handler, you can reference any number of other standard or custom handlers/functions/etc. Like this:
-- start of script --
on startup
if firstchar(the platform) = char 1 of the systemVersion then
doDance "Windows?"
else
doDance "Mac?"
end if
writeSomething
end startup
function firstChar pCharString
return char 1 of pCharString
end firstChar
on doDance pDanceType
tellSomeone "Are you running" && pDanceType
end doDance
on tellSomeone pMessage
put "Content Type: text/html" & cr \
& "Content Length:" && length(pMessage) & cr & cr
put pMessage
end tellSomeone
on writeSomething
put "Uhhhhh...."
end writeSomething
-- end of script --
> So does this mean that one CGI file is one handler and that I can't pass
> arguments to it or can I do something like this:
The 'startup' message has no params, but you can create other handlers in your CGI script that use'em (see above).
Phil
>
> #! mc
> on Startup
> on handler1 param1 param2
> # do stuff
> end handler1
> function dosomething
> # do stuff
> end dosomething
> end Startup
>
> Rich Mooney
> Payne Sparkman Mfg.
> shop at paynesparkman.com
>
> _______________________________________________
> metacard mailing list
> metacard at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/metacard
More information about the metacard
mailing list