Page Functions

Description

This example shows a more complex use of WebC. There are times when you don't want WebC to provide the function declaration, instead wanting to provide it your self.

The rule that WebC follows is that if you start an HTML block inside of a function (or any scope) then WebC will not write the function declaration and you must provide it your self.

This is usefull if you want to place any of your function after your main HTML block or want to have a different naming convention that what WebC noramlly does.

WebC Code

<?wc

void RepeatAfterMe(int Times,const char *String);

void MyPageFunction(void)
{
?>
<!DOCTYPE HTML>
<html>
    <head>
        <title>Page Functions</title>
    </head>
    <body>
        <?wc RepeatAfterMe(4,"Four is good<br/>"); ?>
    </body>
</html> <?wc ;
}

void RepeatAfterMe(int Times,const char *String)
{
    int r;

    for(r=0;r<Times;r++)
        wcecho(String);
}
?>

C Code

#include "WCWebAPI.h"

void RepeatAfterMe(int Times,const char *String);

void MyPageFunction(void)
{
    wcecho("<!DOCTYPE HTML>\n"
        "<html>\n"
        "   <head>\n"
        "       <title>Page Functions</title>\n"
        "   </head>\n"
        "   <body>\n");
    RepeatAfterMe(4,"Four is good<br/>");
    wcecho("   </body>\n"
        "</html>\n");
}

void RepeatAfterMe(int Times,const char *String)
{
    int r;

    for(r=0;r<Times;r++)
        wcecho(String);
}

Output

<!DOCTYPE HTML>
<html>
   <head>
       <title>Page Functions</title>
   </head>
   <body>
        Four is good<br/>
        Four is good<br/>
        Four is good<br/>
        Four is good<br/>
   </body>
</html>