topical media & game development
lib-ch-example-sample-calculator.cgi / cgi
#!/bin/ch
/* Copyright (c) 2001 by SoftIntegration, Inc. All Rights Reserved */
/* Web Calculator source code written in Ch */
include <cgi.h>
void sendApplet(char *x, char *y, char *expr) {
class CResponse Response;
Response.setContentType("application/x-chs");
Response.begin();
printf("#include<stdio.h>\n");
printf("int main() {\n");
printf(" double x = \%s;\n", x);
printf(" double y = \%s;\n", y);
printf(" printf(\"x = %%f, \", x);\n");
printf(" printf(\"y = %%f \\n\", y);\n");
printf(" printf(\"\%s = %%f\\n\", \%s);\n", expr, expr);
printf(" getchar();\n"); // Hold result for display in windows
printf("}\n");
Response.end();
}
void errorHandler(char *reason) {
class CResponse Response;
Response.begin();
Response.title("Web Calculator");
fprintf stdout << ENDFILE
<H3>Web Calculator Failed</H3>
Your mathematical expression has not been submitted to Web Calculator
because
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.