home *** CD-ROM | disk | FTP | other *** search
- This useful hint shows how to "automate" a number of menu keystrokes.
-
-
- 1) First copy the standard skeleton, (DBC.SKL), to one that you can safely
- modify without havin to worry about destroying the original.
-
- COPY DBC.SKL DBCAUTO.SKL
-
-
- 2) The first modification is to add a new global "string" variable. This
- string will act as the storage place for our "automatic" input. At the
- bottom of the current global variable declarations, just before the
- DataBoss ⁿRECMODⁿ generation macro insert the line :--
-
- string autoInput; /*MOD*/
-
-
- 3) We will initialise the new variable to a null string, (no automatic
- input to begin with). This is done by adding the following line to the
- top of the "initialize" function:--
-
- void initialize(void)
- {
- strcpy(autoInput,""); /*MOD*/
-
-
- 4) Now move down into the "do_menu()" function, (closer to the end of
- skeleton file). This is where user input is collected. Make the
- following modifications after the "do {" statement begins :--
-
- do {
- if (dm.curitm->sec > gvar->sec) {
- if (dm.curmnu->mtyp == Vert) goud(&dm,Down);
- else gorl(&dm,Right);
- }
- if (strlen(autoInput) > 0) { /*MOD*/
- ctlkey = autoInput[0]; /*MOD*/
- strdelete(autoInput,0,1); /*MOD*/
- } /*MOD*/
- else { /*MOD*/
- hbar(&dm);
- tandk(0,0,uw.wa[scrno]);
- ctlkey = upperch(getkey());
- } /*MOD*/
-
-
- 5) Now it just remains for you to decide how/when to create automatic input.
-
-
- i) For example say you want the database program to start up adding a new
- child record to the last record of file 1. Instead of initialising
- "autoInput" to a null string you would set it thus :--
-
- strcpy(autoInput,"L+A");
-
- The "L" does a "Last", the "+" swaps to the second file, and the "A"
- begins the "Add".
-
- ii) Another example might be that if the user selects "Edit" when on the
- second file that you really want to go back to file 1 and do the edit
- on the parent record, then swap back to file 2 when complete.
-
- To achieve this you would add the following code to the "do_menu()"
- function, (just after our existing modifications for "autoInput") :-
-
- if ((ctlkey == 'E') && (filno == 2)) { /* if edit file 2 */
- ctlkey = ' '; /* Nullify the Edit Command */
- strcpy(autoInput,"-E+"); /* Swap to Parent, Edit, Swap to Child */
- }
-
-
- All that remains is to remember to generate you program using the custom
- skeleton, DBCAUTO.SKL, so the program will inherit the new functionallity.