home *** CD-ROM | disk | FTP | other *** search
- #include <sybfront.h>
- #include <sybdb.h>
- #include <sybfrs.h>
-
- #if MSDOS
- # include "aforms.h"
- #endif /* MSDOS */
-
- /* MAIN body of the Sales Entry System.
- **
- ** Open a connection to the SQL Server and set the database context
- ** to the database that is to receive the new sales data. If that
- ** succeeds, install the procedures called by the form, and turn
- ** control over to the forms run-time system.
- */
-
- extern int gthdr();
- extern int strin();
- extern int titin();
- extern int dscin();
- extern int rgdsc();
- extern int adisc();
- extern int clrfd();
- extern int inval();
- extern int printform();
- extern int msg_handler();
- extern int err_handler();
-
- static FSPROCEDURE procarray[] = {
- {"gthdr", gthdr, NULL, SYB_C},
- {"strin", strin, NULL, SYB_C},
- {"titin", titin, NULL, SYB_C},
- {"dscin", dscin, NULL, SYB_C},
- {"rgdsc", rgdsc, NULL, SYB_C},
- {"adisc", adisc, NULL, SYB_C},
- {"clrfd", clrfd, NULL, SYB_C},
- {"inval", inval, NULL, SYB_C},
- {"printform", printform, NULL, SYB_C},
- {NULL, NULL, NULL, SYB_C}, };
-
- main(argc, argv)
- int argc;
- char *argv[ ];
- {
- LOGINREC *loginrec;
- DBPROCESS *dbproc;
- FORM *salesform;
- POINTER argarray[1];
- FSPROCEDURE *oldprocarray;
-
- /* Initialize the terminal environment. Fsopenscreen uses
- ** non-NULL parameters if it is running on a bitmap terminal.
- ** In other environments, non-NULL parameters are simply ignored.
- */
- if (fsopenscreen(&argc, argv, "Sales Application") == FAIL)
- {
- printf("Couldn't initialize the screen.\n");
- exit(STDEXIT);
- }
-
- #if BDS42 || VMS
- /* Initialize DB-Library. */
- if (dbinit() == FAIL)
- exit(ERREXIT);
- #endif /* BSD42 || VMS */
-
- /* Call login routine, which opens a DBPROCESS and allocates
- ** a LOGINREC structure. loginrec must be a pointer to
- ** a pointer.
- */
- if ((dbproc = fsdblogin(&loginrec, "Sales Entry Login") ) == NULL)
- {
- /* User backed out of login screen. */
- fsclosescreen();
- dbexit();
- exit(STDEXIT);
- }
-
- /* Install message and error handlers. */
- dbmsghandle(msg_handler);
- dberrhandle(err_handler);
-
-
- /* The forms run-time system needs a DBPROCESS for the Values Key. This
- ** application can share the DBPROCESS, since the application queries are
- ** fully finished at all times that the user has control of the screen.
- */
- fsdbproc(dbproc);
-
- /* Change to the PUBS database. */
- dbuse(dbproc, "pubs");
-
- /* Load the form. */
- if (( salesform = fsgetform("sntr", "3") ) == NULL)
- {
- fsabort("Unable to open form sntr 3.\n");
- }
-
- /* Install the array of external procedures which will be called by
- ** the form. Save the previous array of procedures so that it can
- ** be restored when this module ends.
- */
- oldprocarray = fsinstallproc(procarray);
-
- /* Set the parameter(s) for the external procedures. */
-
- argarray[0] = (POINTER) dbproc;
- fsprocargs("inval", argarray);
- fsprocargs("gthdr", argarray);
- fsprocargs("strin", argarray);
- fsprocargs("titin", argarray);
- fsprocargs("dscin", argarray);
-
-
- /* Turn control over to the forms run-time system. */
- fscallform(salesform);
-
- /* Clean up! */
-
- dbclose(dbproc);
- dbexit();
- fsclosescreen();
-
- /* Restore the old procedure array--pointless since this is
- ** the main routine, but normally a good idea.
- */
- fsinstallproc(oldprocarray);
-
- exit(STDEXIT);
-
- } /* End of program. */
-