home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Guide / c-cplusplus-interactive-guide.iso / c_ref / csource1 / chint / useful04.hnt < prev    next >
Encoding:
Text File  |  1992-08-13  |  1008 b   |  34 lines

  1. (*
  2.   A function that lists using one key but returns a field other that the
  3.   Key Field.  Use this in the Error Message associated with a "found()" in
  4.   the Validation Expression.
  5.  
  6.   Example call :--     listOther(2,1,{2.CODE_DESCR},{})
  7.  
  8.   This will list file "2" using key "1" to sequence the records.  When the
  9.   user picks from the list the description from the code file,
  10.   "{2.CODE_DESCR}" is placed into the current field, "{}".
  11.  
  12.   Example call :--     listOther(2,2,{2.CUST_ID},{})
  13.  
  14.   This will list file "2" using key "2" to sequence the records.  When the
  15.   user picks from the list the customer id. from the code file,
  16.   "{2.CUST_ID}" is placed into the current field, "{}".
  17.  
  18. *)
  19.  
  20. strptr listOther(int fno, int kno, string fromFld, string toFld)
  21. {
  22.   uchar dummy[81];
  23.   string ts;
  24.   int savelen;
  25.  
  26.   savelen = strlen(toFld);
  27.   strcpy(ts,"");
  28.   list(dummy,fno,kno,ts);
  29.   strcopy(ts,fromFld,0,savelen);
  30.   pad(ts,ts,savelen,Right);
  31.   strcpy(toFld,ts);
  32.   return(dummy);
  33. }
  34.