home *** CD-ROM | disk | FTP | other *** search
- /*
- This useful hint show how to change the "dbnames" array. This is the array
- of file names that will be used by DOS to store the data records and index
- key strings.
-
- The approach taken is to re-set all names to the base name selected via
- a choose box, however simple modifications of this routine could be made
- so that only some names were modified, or so that different sets of names
- could be used.
-
-
- Step 1. Create a function to prompt for user input, then use the response
- to select the names to be used. Create a function files called
- DBNAMES.FUN and put the following code into it...
-
- */
- void setDBNames(void)
- {
- int i, j, l, p;
- uchar dummy[81];
- uchar baseName[7];
-
- strcpy(baseName,"BOOK");
- choose(dummy,"BOOK|CASH|MINE|YOURS","1 - BOOK|2 - CASH|3 - MINE|4 - YOURS",baseName);
- for (i=1; i<=maxfilno; i++) {
- for (j=0; j<=maxkeyno; j++) {
- strip(dbnames[i][j],dbnames[i][j]);
- l = strlen(dbnames[i][j]);
- p = strposch('.',dbnames[i][j]);
- if (p < 2) p = 2;
- strconcat(dbnames[i][j],baseName,strcopy(dummy,dbnames[i][j],p-2,l-(p-3)),NULL);
- }
- }
- }
-
-
- Step 2. Once this routine has been written you need to create a custom
- version of the standard skeletons to make a call to it before
- it opens the files...
-
- i) COPY DBC.SKL DBCN.SKL
- ii) COPY DBCFIX.SKL DBCFIXN.SKL
- iii) COPY DBCREP.SKL DBCREPN.SKL
-
- Now modify the three skeletons by adding a "#include" directive
- at the top of the program. Add this following line after the all
- variable declarations in each of the three skeletons...
-
- #include "dbnames.fun"
-
- The second modification is to add a call to the "setDBNames()"
- function near the start of the main program block in each
- skeleton. We will add this statement just after the test for
- a valid path has been completed...
-
- ...
- else if (!validpath()) {
- audible(Error);
- dspmsge(LSC_BaseError,LSC_AbortBadPath,4.0);
- }
- else {
- setDBNames(); /* Inserted this line */
- ...
-
- Step 3. Simply generate your programs using these modified skeletons,
- when the generated and compiled program is run a choose will
- first appear to prompt for the base name to use.