home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / strings / infield / infield.doc < prev    next >
Encoding:
Text File  |  1988-06-06  |  8.7 KB  |  167 lines

  1. Unit InField;
  2.  
  3. Interface
  4. Uses Crt, Qwik;  { This Qwik unit has several functions that I've   }
  5.                  { added to Jim LeMay's basic gem.                  }
  6.  
  7. var    SOE, COE, EOB,             { Abbreviations mean:             }
  8.        EOA, ISnd, Kclk,           { Strip On Exit,                  }
  9.        UseTemp, Keeptemp,         { Clear On Entry,                 }
  10.        CapsOnly, MOK,             { ESC On Blank,                   }
  11.        IExit           : boolean; { Exit on Arrow (up or down) key  }
  12.                                   { Sound,                          }
  13.                                   { Keyclick,                       }
  14.                                   { Use a Template                  }
  15.                                   { Keep the Template in rtn string }
  16.                                   { Convert all letters to capitals }
  17.                                   { Move cursor on key in template  }
  18.                                   { Global exit flag                }
  19.           FKey, TAttr : integer;  { Function key number,            }
  20.                                   { Template attribute,             }
  21.            StCh, EnCh : char;     { Starting and ending character.  }
  22.              Template : Strng80;  { Template string                 }
  23.  
  24. procedure Data_In(Drow, Dcol, MaxWide : integer;
  25.                           Var InWord : Strng80;
  26.                                Dattr : integer);
  27. procedure BadChoice;
  28. procedure Strip(Var Stripit : Strng80);
  29.  
  30.  
  31. Implementation
  32. -----------------------------------------------------------------
  33.  
  34.       This is a general data input unit that far outperforms the rest, yet is 
  35. much smaller that others I have seen (only 5k). The basic screen output is 
  36. handled by Jim LeMay's excellent Qwik routines. (QWIK40.ARC - You bet I 
  37. registered!)  You set the starting row and column (Beware of setting DRow to
  38. X and DCol to Y, the normal order for GotoXY.  If you don't like this, 
  39. register the LeMay Qwik utility and use GotoRC like I do!), the maximum 
  40. width of the field (this has no effect when you use templates), the string 
  41. to edit and the color of the field.  Here is a run down of the various other 
  42. features: 
  43.  
  44. EDITING - It acts like a mini-wordprocessor on a line!  You toggle insert 
  45.           mode with Ins, and the cursor will get larger in insert mode and 
  46.           smaller in overwrite.  The cursor is restored to what it was on 
  47.           exit.  Word right and Word left (Ctrl-arrows) works, and 
  48.           PgDn=End=Ctrl-PgDn=Ctrl-End, as well as 
  49.           PgUp=Home=Ctrl-PgUp=Ctrl-Home.  Del and BackSpace are implemented,
  50.           but Tab has no effect.
  51.  
  52. SOUND - Can be turned on and off through ISnd.  You can also enable a 
  53.         keyclick with the Kclk variable.  Sound is output when an invalid 
  54.         key is pressed, or when you are at the end of the data field, or 
  55.         when you press ESC.  The global procedure BadChoice is the procedure 
  56.         that makes the sound when you press an invalid key. 
  57.  
  58. CLEAR ON ENTRY - if you want the text to be initialized with spaces when
  59.                  entering the routine, then set COE to TRUE. Otherwise, the
  60.                  current string is displayed in the field, and pressing
  61.                  Return will accept that string.
  62.  
  63. STRIP ON EXIT - If you want to get rid of all spaces and nulls after the text
  64.                 is input, set SOE to TRUE, otherwise the string will be left
  65.                 alone.  The global procedure Strip does the stripping.
  66.  
  67. COLORS - the attribute byte, Dattr, specifies the main text color.  The
  68.          global variable, Tattr, specifies the template attribute.  Both of
  69.          these variables are set by the following equation:
  70.               Attr := (background shl 4) + foreground;
  71.          Using Turbo Pascal's color constants is even more friendly:
  72.               Attr := (Blue shl 4) + White;
  73.          You can also specify what the characters at the beginning and end
  74.          of the field are through StCh and EnCh.  StCh refers to the
  75.          starting character.  EnCh refers to the ending character.  To disable
  76.          having a starting and/or an ending character, set StCh and/or EnCh to
  77.          'N'.  By the way, if a template is being used, then StCh and EnCh will 
  78.          be ouput using Tattr, the template attribute.  Otherwise, they will 
  79.          use the normal text color.  This is done so that you won't have to 
  80.          change Tattr every time you change colors in your program. 
  81.  
  82. CAPSONLY - Forces all characters input to be upper case.
  83.  
  84. TEMPLATES - You can specify a template around which text will be entered.
  85.             For instance, "  /  /  " can be used for dates "        .   "
  86.             can be used for file names, etc.  When you enter text, the text
  87.             "flows" around the characters in the template.  The template is
  88.             specified by setting the global string variable, Template, to 
  89.             what you want.  
  90.             To use the template, set the global variable UseTemp to TRUE.  
  91.             You also have the option of leaving the template in the inputted 
  92.             text.  This is set through the KeepTemp variable.  For example, 
  93.             with KeepTemp FALSE, and a template of "  /  /  ", if you input 
  94.             "06/04/88", the result in InWord is "060488".  But if you set 
  95.             KeepTemp to TRUE, the result will be "06/04/88". 
  96.             A further option with templates is the Move On Key feature.  
  97.             When MOK is TRUE, and the user presses a character that is TO 
  98.             THE RIGHT of the cursor position, the cursor position will move 
  99.             to one space after the character in the template.  To explain, 
  100.             say you have a template "        .   ", and the screen looks 
  101.             like this: 
  102.                  "INTEST▄ .   "
  103.             and the user presses the "." key.  The screen will then look
  104.             like this: 
  105.                  "INTEST  .▄  "
  106.             It doesn't matter how many of the same characters you have in 
  107.             the field, either.  For instance, if the screen looked like this: 
  108.                  "AK005-7721-31 -41▄   -    -   " 
  109.             and the user presses the "-" key, the screen will look like this: 
  110.                  "AK005-7721-31 -41    -▄   -   "
  111.             When MOK is false, of course, none of this happens.
  112.  
  113. PROGRAMMING - Say you want pop up help from this field?  Say you have 
  114.               several fields and you want to cursor through them?  Infield 
  115.               handles these problems, too.  Any regular, shifted, 
  116.               controlled, or alted (alted?) function key will set the global 
  117.               exit flag, Iexit,  to TRUE, and the key number will be left in 
  118.               FKey.  By the way, the key number for the last key pressed 
  119.               before exiting is ALWAYS left in Fkey.  See the reference 
  120.               section of the Turbo Pascal manual for the key numbers.  If 
  121.               you want to exit on any cursor key, set EOA to TRUE.  This 
  122.               workes for Up, Down, Left and Right arrow keys, so the Right 
  123.               and Left arrow keys are no longer available for editing.  This 
  124.               is when the EOA flag comes into play, also.  If you wish to
  125.               check if the user pressed return on an empty field, set EOA to 
  126.               TRUE.  Then, if they do that, the global exit flag Iexit will 
  127.               be set to TRUE.  Fkey will contain 13, the key number for 
  128.               Return. 
  129.  
  130.  
  131. DEFAULTS:
  132.    Iexit := false;   
  133.      SOE := false;   
  134.      COE := false;       
  135.      EOB := false;
  136.      EOA := false;  
  137.     ISnd := true;   
  138.     Kclk := false;   
  139.  UseTemp := false;
  140.     Fkey := 0;      
  141.     StCh := '[';    
  142.     EnCh := ']';    
  143. KeepTemp := false;
  144. Template := '';    
  145.    TAttr := 7;
  146.      MOK := false;
  147.  
  148.  
  149. If you like this unit and use it, please donate $10 to my college education.  
  150. Even just a letter that reports a bug is GREATLY appreciated.  If you send 
  151. anything at all, you would reap several benefits.  Not only would feel great 
  152. for supporting the Shareware concept, you will have one up on your computer 
  153. friends ("When was the last time YOU registered for a piece of Shareware 
  154. software?" etc.)  Send to: 
  155.  
  156.     Kevin Menningen
  157.     W277 S4455 Elk Valley Ct.
  158.     Waukesha, WI  53188-6437
  159.  
  160. I have an account on Exec-PC BBS, (414) 964-5160, the LARGEST BBS in the 
  161. world.  50+ lines (I can never remember how many), 1.31 gigibyte hard disk 
  162. and PC SIG CD-ROM.  This is a pay system (only $45 for an hour a day for a 
  163. year), so you cannot leave mail to me unless you have an account.  However, 
  164. feel free to check it out through Telenet Direct Connect, PC PURSUIT or the 
  165. normal telephone network. 
  166.  
  167.