home *** CD-ROM | disk | FTP | other *** search
- Unit InField;
-
- Interface
- Uses Crt, Qwik; { This Qwik unit has several functions that I've }
- { added to Jim LeMay's basic gem. }
-
- var SOE, COE, EOB, { Abbreviations mean: }
- EOA, ISnd, Kclk, { Strip On Exit, }
- UseTemp, Keeptemp, { Clear On Entry, }
- CapsOnly, MOK, { ESC On Blank, }
- IExit : boolean; { Exit on Arrow (up or down) key }
- { Sound, }
- { Keyclick, }
- { Use a Template }
- { Keep the Template in rtn string }
- { Convert all letters to capitals }
- { Move cursor on key in template }
- { Global exit flag }
- FKey, TAttr : integer; { Function key number, }
- { Template attribute, }
- StCh, EnCh : char; { Starting and ending character. }
- Template : Strng80; { Template string }
-
- procedure Data_In(Drow, Dcol, MaxWide : integer;
- Var InWord : Strng80;
- Dattr : integer);
- procedure BadChoice;
- procedure Strip(Var Stripit : Strng80);
-
-
- Implementation
- -----------------------------------------------------------------
-
- This is a general data input unit that far outperforms the rest, yet is
- much smaller that others I have seen (only 5k). The basic screen output is
- handled by Jim LeMay's excellent Qwik routines. (QWIK40.ARC - You bet I
- registered!) You set the starting row and column (Beware of setting DRow to
- X and DCol to Y, the normal order for GotoXY. If you don't like this,
- register the LeMay Qwik utility and use GotoRC like I do!), the maximum
- width of the field (this has no effect when you use templates), the string
- to edit and the color of the field. Here is a run down of the various other
- features:
-
- EDITING - It acts like a mini-wordprocessor on a line! You toggle insert
- mode with Ins, and the cursor will get larger in insert mode and
- smaller in overwrite. The cursor is restored to what it was on
- exit. Word right and Word left (Ctrl-arrows) works, and
- PgDn=End=Ctrl-PgDn=Ctrl-End, as well as
- PgUp=Home=Ctrl-PgUp=Ctrl-Home. Del and BackSpace are implemented,
- but Tab has no effect.
-
- SOUND - Can be turned on and off through ISnd. You can also enable a
- keyclick with the Kclk variable. Sound is output when an invalid
- key is pressed, or when you are at the end of the data field, or
- when you press ESC. The global procedure BadChoice is the procedure
- that makes the sound when you press an invalid key.
-
- CLEAR ON ENTRY - if you want the text to be initialized with spaces when
- entering the routine, then set COE to TRUE. Otherwise, the
- current string is displayed in the field, and pressing
- Return will accept that string.
-
- STRIP ON EXIT - If you want to get rid of all spaces and nulls after the text
- is input, set SOE to TRUE, otherwise the string will be left
- alone. The global procedure Strip does the stripping.
-
- COLORS - the attribute byte, Dattr, specifies the main text color. The
- global variable, Tattr, specifies the template attribute. Both of
- these variables are set by the following equation:
- Attr := (background shl 4) + foreground;
- Using Turbo Pascal's color constants is even more friendly:
- Attr := (Blue shl 4) + White;
- You can also specify what the characters at the beginning and end
- of the field are through StCh and EnCh. StCh refers to the
- starting character. EnCh refers to the ending character. To disable
- having a starting and/or an ending character, set StCh and/or EnCh to
- 'N'. By the way, if a template is being used, then StCh and EnCh will
- be ouput using Tattr, the template attribute. Otherwise, they will
- use the normal text color. This is done so that you won't have to
- change Tattr every time you change colors in your program.
-
- CAPSONLY - Forces all characters input to be upper case.
-
- TEMPLATES - You can specify a template around which text will be entered.
- For instance, " / / " can be used for dates " . "
- can be used for file names, etc. When you enter text, the text
- "flows" around the characters in the template. The template is
- specified by setting the global string variable, Template, to
- what you want.
- To use the template, set the global variable UseTemp to TRUE.
- You also have the option of leaving the template in the inputted
- text. This is set through the KeepTemp variable. For example,
- with KeepTemp FALSE, and a template of " / / ", if you input
- "06/04/88", the result in InWord is "060488". But if you set
- KeepTemp to TRUE, the result will be "06/04/88".
- A further option with templates is the Move On Key feature.
- When MOK is TRUE, and the user presses a character that is TO
- THE RIGHT of the cursor position, the cursor position will move
- to one space after the character in the template. To explain,
- say you have a template " . ", and the screen looks
- like this:
- "INTEST▄ . "
- and the user presses the "." key. The screen will then look
- like this:
- "INTEST .▄ "
- It doesn't matter how many of the same characters you have in
- the field, either. For instance, if the screen looked like this:
- "AK005-7721-31 -41▄ - - "
- and the user presses the "-" key, the screen will look like this:
- "AK005-7721-31 -41 -▄ - "
- When MOK is false, of course, none of this happens.
-
- PROGRAMMING - Say you want pop up help from this field? Say you have
- several fields and you want to cursor through them? Infield
- handles these problems, too. Any regular, shifted,
- controlled, or alted (alted?) function key will set the global
- exit flag, Iexit, to TRUE, and the key number will be left in
- FKey. By the way, the key number for the last key pressed
- before exiting is ALWAYS left in Fkey. See the reference
- section of the Turbo Pascal manual for the key numbers. If
- you want to exit on any cursor key, set EOA to TRUE. This
- workes for Up, Down, Left and Right arrow keys, so the Right
- and Left arrow keys are no longer available for editing. This
- is when the EOA flag comes into play, also. If you wish to
- check if the user pressed return on an empty field, set EOA to
- TRUE. Then, if they do that, the global exit flag Iexit will
- be set to TRUE. Fkey will contain 13, the key number for
- Return.
-
-
- DEFAULTS:
- Iexit := false;
- SOE := false;
- COE := false;
- EOB := false;
- EOA := false;
- ISnd := true;
- Kclk := false;
- UseTemp := false;
- Fkey := 0;
- StCh := '[';
- EnCh := ']';
- KeepTemp := false;
- Template := '';
- TAttr := 7;
- MOK := false;
-
-
- If you like this unit and use it, please donate $10 to my college education.
- Even just a letter that reports a bug is GREATLY appreciated. If you send
- anything at all, you would reap several benefits. Not only would feel great
- for supporting the Shareware concept, you will have one up on your computer
- friends ("When was the last time YOU registered for a piece of Shareware
- software?" etc.) Send to:
-
- Kevin Menningen
- W277 S4455 Elk Valley Ct.
- Waukesha, WI 53188-6437
-
- I have an account on Exec-PC BBS, (414) 964-5160, the LARGEST BBS in the
- world. 50+ lines (I can never remember how many), 1.31 gigibyte hard disk
- and PC SIG CD-ROM. This is a pay system (only $45 for an hour a day for a
- year), so you cannot leave mail to me unless you have an account. However,
- feel free to check it out through Telenet Direct Connect, PC PURSUIT or the
- normal telephone network.
-
-