home *** CD-ROM | disk | FTP | other *** search
- (***************************************************************************
- How to edit fields from the same file on different windows.
-
- This code enables the "PgDn" and "PgUp" keys so that they can be used to
- switch to a different window containing more editable fields from the
- current file.
-
- The "PgDn" and "PgUp" functionallity can be used either while at the menu
- bar, or while editing/adding/copying the records.
-
- You may start the Edit/Add/Copy from any window with editable fields, you
- do not have to start from the first window.
-
- When selecting Add or Copy the program will force the user to edit all
- windows that contain editable fields for that file. This ensures that
- field validation will be conducted on all fields that are new to the
- record. When selecting Edit editing other that the current window is
- optional.
-
- 1) Copy DBC.SKL to MSCRS.SKL (MultiSCReenS skeleton)
-
- i) Modify the edit_rec() procedure so that it looks like this :--
-
- void edit_rec(int fld)
- {
- edthook = tandk;
-
- reDisplayAll(); /**/
- resetBeenIn(); /**/
- do { /**/
-
- ⁿIFDEF TABLESⁿ
- ⁿMODNAMEⁿ_edt(filno,fld,tabidx[filno] - 1);
- ⁿELSEDEFⁿ
- ⁿMODNAMEⁿ_edt(filno,fld,0);
- ⁿENDDEFⁿ
- switchScreen(exitcode); /**/
- if ((exitcode == XeptKey) && /**/
- goThruAll && !beenInAll()) { /**/
- dberrm(Msg_GoThroughAll); /**/
- exitcode = Nul; /**/
- } /**/
- } while ((exitcode != XeptKey) && (exitcode != QitKey)); /**/
-
- edthook = NULL;
- }
-
- ii) Modify the edit_record() function, just before the call to
- "edit_rec(0)" you add the line "goThruAll = False;" which will
- allow the user to edit only the fields on the current window,
- set "goThruAll = True;" if you want to force the operator to go
- through all windows that have editable fields if the current file.
- ie :--
-
- goThruAll = False; /**/
- edit_rec(0);
- changedkey = False;
-
- iii) Modify the add_record() function, just before the call to
- "edit_rec(0)" you add the line "goThruAll = True;" This
- will force the operator to edit go through all the windows that
- contain editable fields of the current file. ie :--
-
- {} goThruAll = True;
- edit_rec(0);
- if (exitcode != QitKey) {
-
- 2 iv) At the end of the function "do_proc()" add a call to
- "reDisplayAll". This call will ensure that each window has its
- contents re-displayed when using processes like Next, Prev, Add
- and Copy. ie :--
-
- } /* switch procno */
- reDisplayAll(); /**/
- }
-
- v) In the procedure "do_menu()" add a clause to the sitch statement to
- deal with the "PgDn" and "PgDn" keys when pressed while at the
- menu. ie :--
-
- /**/ case PgUp :
- /**/ case PgDn : switchScreen(ctlkey); break;
- case UArr : goud(&dm,Up); break;
- case DArr : goud(&dm,Down); break;
-
-
- 2) Copy DBCINC.SKL to MSCRSINC.SKL (MultiSCReenS INClude skeleton)
- 6 to 8 lines from the bottom of the function ⁿMODNAMEⁿ_edt() add a new
- line to allow "PgDn" and "PgUp" to leave the editing loop ie.:--
-
- if (exitcode == PgDn) edt.bypass = True; /**/
- if (exitcode == PgUp) edt.bypass = True; /**/
- if (exitcode == XeptKey) edt.bypass = True;
- if (exitcode == QitKey) edt.finished = True;
-
- 3) When defining your database put editable fields from the same file
- into different windows. Also use the "Include" menu option from the
- "Fields/More/More" menu and add a new function file name to the list.
- If your database applicatin is called TEST then you could add a file
- called ZTEST.FUN.
-
- 5) Create the ZTEST.FUN function include file with the following code:--
-
- uchar Msg_GoThroughAll[] = "Please use PgUp and PgDn to traverse all screens !";
-
- byte switchNextScr[17][17] =
- /* Each line represents the possible screens to "PgDn" to for the
- correspond file. The way this one is set up simply means that
- if you are editing file 1 then pressing PgDn when in window 1 will
- take you to window 2.
- */
- {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}};
-
- byte switchPrevScr[17][17] =
- /* Each line represents the possible screens to "PgUp" to for the
- correspond file. The way this one is set up simply means that
- if you are editing file 1 then pressing PgUp when in window 2 will
- take you to window 1.
- */
- {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}};
-
- bool goThruAll;
- bool beenInScreen[17];
-
- void resetBeenIn(void)
- {
- int i;
-
- for (i = 1; i<=16; i++) beenInScreen[i] = False;
- beenInScreen[scrno] = True;
- }
-
- bool beenInAll(void)
- {
- int i;
- bool tb;
-
- tb = True;
- for (i = 1; i <= 16; i++) {
- if (switchNextScr[filno][i] != 0)
- tb = tb && beenInScreen[switchNextScr[filno][i]];
- if (switchPrevScr[filno][i] != 0)
- tb = tb && beenInScreen[switchPrevScr[filno][i]];
- }
- return(tb);
- }
-
- void reDisplayAll(void)
- {
- int i;
- bool savDispState[17];
-
- for (i = 1; i <= 16; i++) {
- if (switchPrevScr[filno][i] != 0) {
- savDispState[i] = (uw.wa[switchPrevScr[filno][i]])->disp;
- (uw.wa[switchPrevScr[filno][i]])->disp = False;
- }
- }
-
- for (i = 1; i <= 16; i++) {
- if (switchPrevScr[filno][i] != 0)
- displayrec(filno,switchPrevScr[filno][i]);
- }
-
- for (i = 1; i <= 16; i++) {
- if (switchPrevScr[filno][i] != 0)
- if (savDispState[i]) hidewin(T_ON,uw.wa[switchPrevScr[filno][i]]);
- }
- }
-
- void switchScreen(uchar inKey)
- {
- switch(inKey) {
- case PgDn : if (switchNextScr[filno][scrno] != 0) {
- scrno = switchNextScr[filno][scrno];
- hidewin(T_ON,uw.wa[scrno]);
- displayrec(filno,scrno);
- beenInScreen[scrno] = True;
- } break;
- case PgUp : if (switchPrevScr[filno][scrno] != 0) {
- hidewin(T_OFF,uw.wa[scrno]);
- scrno = switchPrevScr[filno][scrno];
- displayrec(filno,scrno);
- beenInScreen[scrno] = True;
- } break;
- }
- }
-