home *** CD-ROM | disk | FTP | other *** search
- /*
- demoflod.c
-
- jmd 6/89
-
- Copyright (c) 1989, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- This program demonstrates loading a sed from a screen file.
-
- It loads the sed named "test" from the screen file "test.lnf"
-
- You must generate this file with the DEMOFSAV example program
- before using this.
-
- Revision History:
- -----------------
- 6/06/90 jmd changed main to return an int
- 8/06/90 jmd added code to pull data out of sed
- 9/14/90 bkd changed to use exit(0) instead of return(0).
- 10/19/90 pmcm included ostdlib.h for exit(), added return(1)
- 12/01/90 ted prototyped main, except if Turbo C++.
- 12/04/90 ted restored "" includes for C-scape headers (not <> includes).
- */
-
- #include <stdio.h>
- #include <string.h>
-
- #include "cscape.h"
- #include "ostdlib.h" /* for exit() */
- #include "sfile.h"
-
- /* function symbol table */
-
- fsyminit_struct my_list[] = {
-
- {FSYM_CLASS},
- {"sedwin_Class", (VOID_FPTR) sedwin_Class , NULL },
-
- {FSYM_FIELDFUNCS },
- {"bob_funcs", FNULL, (VOID *) &bob_funcs},
- {"string_funcs", FNULL, (VOID *) &string_funcs},
- {"cmoney_funcs", FNULL, (VOID *) &cmoney_funcs},
-
- {FSYM_USER },
-
- {FSYM_BORDER },
- {"bd_prompt", (VOID_FPTR) bd_prompt, NULL},
-
- {FSYM_MOUSE },
- {FSYM_MOVEMETHOD },
- {FSYM_EXPLODE },
- {FSYM_SPECIAL },
- {"spc_Embed", (VOID_FPTR) spc_Embed, NULL },
-
- {FSYM_AUX },
- {FSYM_LISTEND}
- };
-
- /* Turbo C++ complains if main is prototyped */
- #ifndef TCP
- int main(void);
- #endif
-
- int main(void)
- {
- sed_type sed, ised;
- sfile_type sfile;
-
- char customer[50], boatname[50], list[10][30];
- long boatcost = 0L;
- int i;
- boolean gotdata = FALSE;
-
- customer[0] = '\0';
- boatname[0] = '\0';
-
- /* Initialize the display */
- disp_Init(def_ModeText, FNULL);
-
- sfile = sfile_Open("test.lnf", my_list);
-
- /* Load the sed */
- sed = sfile_LoadSed(sfile, "test", SED_ALLOC);
-
- if (sed != NULL) {
- sed_Repaint(sed);
- sed_Go(sed);
-
- /* get the data (assume the fields exist) */
- strcpy(customer, (char *) sed_GetNameVar(sed, "customer"));
- strcpy(boatname, (char *) sed_GetNameVar(sed, "boatname"));
- boatcost = *((long *) sed_GetNameVar(sed, "boatcost"));
-
- /* get data from the inner sed */
- ised = sed_GetBob(sed_GetFieldBob(sed, sed_GetNameNo(sed, "list")));
-
- for (i = 0; i < 10; i++) {
- strcpy(list[i], (char *) sed_GetVar(ised, i));
- }
-
- gotdata = TRUE;
-
- sed_Close(sed);
- }
-
- sfile_Close(sfile);
- disp_Close();
-
- if (gotdata) {
- printf("Customer: %s\n", customer);
- printf("Boat Name: %s\n", boatname);
-
- printf("Boat Cost: %.2f\n", (float) boatcost / 100.0 );
-
- for (i = 0; i < 10; i++) {
- printf(" %d: %s\n", i, list[i]);
- }
- }
-
- exit(0);
- return(0);
- }
-
-