home *** CD-ROM | disk | FTP | other *** search
- strptr nextCharNum(strptr sout,
- int fno, int kno, int charlen, int numlen,
- strptr startstr)
- /***************************************************************************/
- /* This function is designed to determine the next number for a key field */
- /* that is a combination of characters followed by numbers. The caller */
- /* passes in the character part of the key and the function determines the */
- /* next unused number begining with that character sequence. */
- /* */
- /* "sout" is the destination string. */
- /* "fno" and "kno" are the File an Key numbers respectively. */
- /* "charlen" is the length of the character part of the key. */
- /* "numlen" is the length of the numeric part of the key. */
- /* "startstr" is the character part of the key to start with. */
- /* */
- /* For Example:-- charlen numlen start str last key next key */
- /* ------- ------ ---------- ---------- ---------- */
- /* 3 5 abc abc00123 abc00124 */
- /* 1 6 z e000159 z000001 */
- /* */
- /* A call to this function might look like :-- */
- /* nextCharNum(MYAPP1.CHARNUMFIELD,1,2,1,6,'z'); */
- /* */
- /***************************************************************************/
- {
- int i;
- bool savok;
- long tr;
- keystr tk;
-
- savok = ok;
- trim(sout,startstr);
- strconcat(tk,sout,"\xff",NULL);
- searchkey(idxkey[fno][kno],&tr,tk);
- prevkey(idxkey[fno][kno],&tr,tk);
- pad(sout,sout,charlen,Right);
- if (!ok || (strsearch(tk,sout) != tk))
- strcat(sout,istr(tk,1,numlen));
- else
- strcat(sout,istr(tk,ival(strcopy(tk,tk,charlen,numlen))+1,numlen));
- for (i=charlen; i<strlen(sout); i++) {
- if (sout[i] == ' ') sout[i] = '0';
- }
- ok = savok;
- return(sout);
- }
-
-
- /***************************************************************************/
- /* This function could be called by using the F2 function key via the */
- /* "custom_key()" function in the standard skeleton. */
- /* */
- /* You might have an editable field, say with edit sequence 12, in window 1*/
- /* of file 1. This would be a "C"haracter field and could have an input */
- /* picture like A-6# and could be the second key for file 1. */
- /* */
- /* You would copy the standard skeleton to a new name then modify the code */
- /* in Custom_Key to look something like this :-- */
- /***************************************************************************/
-
- bool custom_key(int scr, int fno, int *fld, uchar *key)
- {
- bool tb;
-
- ⁿCODEDISPⁿ
- if ((fno == 1) && (scr == 1) && (*fld == 1) && (*key == F2)) /*NEW*/
- nextCharNum(MYAPP1.CHARNUMFIELD,1,2,1,6,"z"); /*NEW*/
- return(False);
- }
-