home *** CD-ROM | disk | FTP | other *** search
- ReadStuff version 1.0 released 8-11-86
- update 1.01 8-13-86
- some documentation 8-15-86
- code cleaning 8-19-86
- update 1.02 8-27-86
-
- Copyright 1986 by Gary Wheaton.
-
- This is a group of procedures and fuctions whose final purpose is to have
- formated keyboard entry.
-
- The main reason that I'm making this available is that I would like to
- make it better. If you go through the code and find something that you
- can make faster, smaller or more powerful, please send this info to me
- via CompuServe EasyPlex [73547,2322] or mail to:
-
- Gary Wheaton
- P.O. Box 68271
- Portland, OR
- 97268-0271
-
- Contributions can be sent to the above address.
-
- For reading this, editing the code and any other editing functions, I
- strongly recommend EDWIN by Kim Kokkonen. With it, you can view this text
- and the code at the same time. It's free and available at fine BBS's
- everywhere.
-
- One thing I do need to warn you about right away is that for some of the
- routines, you will need to have Turbo Pascal with BCD (for use of the FORM
- command). If someone doesn't have BCD and they find a good substitute for
- the FORM command, please let me know.
-
- Credit needs to go to Brian Foley for his FastWrite routines. They were
- what I butchered to make QWrite. For those routines, Brian gives some
- credit to Marshall Brain, Kim Kokkonen and Bela Lubkin. Brian also looked
- over this program and made many speed-up suggestions.
-
- Credit also needs to go to Bela Lubkin. He is the author of the
- MoveToScreen and MoveFromScreen procedures.
-
- It's been brought to my attention that people with different displays are
- getting different results. First of all let me say that this program will
- operate at it's peak on an AT&T 6300 (what I have). It can work on mono,
- if you have the desire and don't know how to alter it, ask. I've been
- told that the quality on the IBM CGA is much poorer than that of the AT&T
- or Compaq, and sometimes even illegible. The best solution is to get a
- better card or monitor. The next best solution is to modify the color
- defaults (see "Colors" below).
-
-
- update 1.01
-
- I included a .COM file for those that would like to see immediate
- results of their download also for those that haven't solved the "FORM"
- problem yet.
-
- I also made the QWrite a little more streamlined and fixed a cosmetic
- bug in PopNote.
-
-
- code cleaning
-
- I just received the Turbo Power Utilities and ran PSA on this. It found
- a few unused variables and procedures. So, the program will run exactly
- the same, only take up less space in both source and code.
-
-
- update 1.02
-
- Shortened and sped up some procedures and functions in KBMISC, namely
- those relating to windows and text boxes.
-
- Removed a bug from ReadString (it was allowing a bogus Cpos).
-
- Removed a bug from ReadDate (on leap year checking, had to change an "="
- to "<>").
-
- Moved KBVARS.PAS, KBMISC.PAS and KBINIT.PAS all into one include file
- KBMISC.PAS.
-
-
-
- What little documentation there is.
-
- Here is a list of how all of the parameters of ReadString are supposed to
- react.
-
- Option: Passing a 'W' will write the string as it appears and return
- without stopping for any keyboard input. Passing an 'R' will write out
- what is currently in Z under the form of MASK and then place the cursor
- on CPOS and wait for key entry.
-
- AutoClear: If CPOS=1 and nothing has been changed since entering the
- field, upon typing an acceptable key, the field will be cleared and the
- character will be placed in pos 1.
-
- InsertStatusLine: Whether or not the Insert/Overwrite status will be
- displayed at the top of the screen.
-
- SetCposTo1OnEntry: will do just that if TRUE.
-
- Floater: If TRUE, a floater will appear just after the last character
- of the string. I used it for debugging purposes, and after a while, I
- decided that I liked it.
-
- DeadColorsOnExit: some other routines use this routine. So they want
- to enter live and leave live. (see "Colors" below)
-
- HelpLine: This will set which helpline will be displayed at the bottom
- of the screen. (see "Help Lines" below)
-
- HelpNum: This number will be passed to procedure SetHelp, where a
- global variable will then be assigned to it. Should you ever press F1,
- the appropriate help routine (not provided) will be executed from
- procedure GetHelp.
-
- X,Y: Where the first character of the field will be placed.
-
- ScanExitSet: This set will contain all of the acceptable exit scan
- codes, such as the Enter Key or maybe an up arrow key. See the table
- in KBVARS.PAS. (see "Key conversion" below)
-
- Scan: On exit, this variable will contain the scan code which forced
- the exit. This number wil be one of the numbers found in ScanExitSet.
-
- AsciiExitSet,Ascii: Works the same way as ScanExitSet and Scan, except
- for printable characters.
-
- Cpos: On entry, the cursor will be set to the given values position of
- the editable mask. If you pass a 5, the cursor will be initially
- placed at the fifth editable character. On exit, Cpos will return the
- last position of the cursor.
-
- Z: The string that you want to have edited. It will be written out as
- the default at entry and the edited version will be given on exit.
-
- Mask: Perhaps the most powerful part of this whole shebang. You may
- define what characters mean what for the mask, using the SetMask
- procedure. There is a function called StMask which will return a
- Standard mask where the first character is any printable character
- except lower case and the rest of the mask includes lower case. This
- will work provided that the masks that it uses are not different from
- what they're set at in the procedure Initialize. Anyway, an example of
- a mask would be '(&&&)&&&-&&&& ext:####' the only editable characters
- here are the '&' and the '#'. Thus the longest string possible is 14
- characters long. As initially set up, the '&' allows numbers only and
- the '#' allows standard printable characters. When the field is
- active, the editable charcters will have the color of LFCC and the
- others will have NFCC.
-
-
- Here is a list of parameters to the other six read procedures which may
- not be too obvious.
-
- ReadChar-MaskSet: A set of characters which are allowable to be
- passed into Z.
-
- ReadReal-Cpos: With an Integeral Field Length of 6 and a mantissa
- length of 3, the cursor position numbers would look like this:
- 567,891.234. So when Cpos is one, the cursor will be placed in the
- right most position of the integral portion.
-
- ReadDate-OtherMode: If OtherMode is 1 then when entering a date you
- may press, say, 'W' and viola! 'Wednesday' appears. To get back to
- numeric dates, simply press any number. 'TFN' is short for "`till
- further notice".
-
- ReadTime-MilitaryTime: Keying is still the same, but the appearance
- will be different between whether this is true or false.
-
- ReadTime-Ommisions: Sometimes, you need to read just hours and
- minutes or just minutes and seconds.
-
-
-
- Here is a list of what the procedures and functions in KBMISC.PAS are
- supposed to do.
-
- GotoXYA: Same as GotoXY, except that it has no regard to windows (the
- "A" is for Absolute).
-
- WhereXA/WhereYA: Same as WhereX/WhereY, except that is has no regard
- for windows.
-
- QWriteA: Will place the string ST on the screen starting at the
- position X,Y without regard to windows. If X is 0 then X will be set
- to the current X. Same for Y. The string will be painted with the
- color ATT (see "Colors" below) except when 0. When ATT is 0, the
- screen attributes will not be altered. The cursor code can be in the
- range of 0 to 3 which will have the following effects on exit: 0)put
- the cursor back where you found it; 1)put the cursor on the first
- character of the string; 2)put the cursor on the character after the
- last character of the string. This routine works much faster than the
- built in Write and Writeln commands.
-
- QWrite: Same as above, except this one minds windows.
-
- QWriteAttA: Same as QWrite, except ST is replaced by LEN. This will
- not write any characters on the screen, only modify the attributes.
-
- QWriteAtt: Same as above, except this one minds windows.
-
- MoveFromScreen/MoveToScreen: Works the same as the move command. The
- only difference is that the move command causes "snow" while these
- don't.
-
- BitCheck: Will return true if BITNUM of ANYBYTE is set to 1.
-
- ByteVal: Will return the byte value of the given string.
-
- Cursor: Cursor(on) will turn the cursor on. Cursor(off) will turn
- the cursor off. (It just doesn't get any easier)
-
- Spaces: Will return a string of X spaces.
-
- StringOf: Will return a string of CHARS with a length of HOWMANY.
-
- StMask: The standard mask for ReadString. If you leave '}' and '#'
- set to what I origionally set them to, when the user types in the
- string, the first char will be forced to upper case. X denotes how
- long you want the field to be.
-
- LeftText: This procedure serves two purposes. One is that if the
- string is longer than FIELDSIZE, it will be truncated to that length.
- The other is if it's shorter than FIELDSIZE, the difference will be
- filled with spaces.
-
- RSpaceWhack: Don't laugh. This will whack all trailing spaces from a
- string.
-
- LSpaceWhack: Whacks leading spaces.
-
- SpaceWhack: Whack leading and trailing spaces.
-
- SetHelp: Puts help line number HLINE at the bottom of the screen and
- sets the global variable CurrentHelpStatus equal to HNUM. When F1 is
- pressed while waiting for key entry, the procedure which corresponds
- to CurrentHelpStatus will be executed.
-
- SetWindow: This will do the same thing as Turbo's Window command,
- except that it will record the coordinates for the purpose of
- overlaying windows. **MUST** be followed by a RecallWindow;
-
- RecallWindow: Tosses out the current window and pops in the previous
- window. Does not work with LayWindow.
-
- TextBox: Draws a box on the screen with the upper left corner at X,Y.
- LINES is how many lines the box will be made of (0,1,2). ABSORFLOAT
- can be an 'A' or an 'F'. 'F' will pay attention to windows, 'A' won't.
-
- WTextBox: Same as TextBox, except for: 1) the X,Y will have no
- regard to the current window; 2) A window (cleared) will be declared
- within the box; 3) **MUST** be followed by RecallWindow.
-
- LayWindow: Same as WTextBox except: 1) what is currenty on the
- screen will be recorded to be replaced later by PeelWindow. 2)
- **MUST** be followed by PeelWindow.
-
- PeelWindow: Peels off the current window. Works only in conjuction
- with LayWindow.
-
- GetKey: Central entry. Clock is updated here, help is called from
- here, the scan and ascii codes are translated from here, etc. (see
- "Key conversion" below). If InsertStausLine is True then "Insert" or
- "Overwrite" will be diplayed at the top of the screen.
-
- MaskIndex: Converts the current charcter of the ReadString Mask into
- a number in the range of 0 to 20 to access that mask set. Passing
- anything but the defined charcters results in a 0.
-
- SetMask: M is the mask that you want to assign to TOKEN. Any
- characters in M will be assigned to TOKEN except for periods. A
- single period is interpreted here as "through". So 'A.Z' is the
- equivalent to 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'. 'A.CX.Z' is the same as
- saying 'ABCXYZ'. To get a period into the set, either include a set
- around the period, such as '-./' (the ascii values of '-','.','/' are
- 45,46,47 respectively) or enter two periods in a row. '0.9..' will
- allow any number or a period.
-
- ReadKey: Filters the keys pressed. Will only return if an acceptable
- key is pressed. If you don't want MASKTOKEN to play a part in the
- selection process, pass it a #0.
-
- PopNote: Puts a window on the screen as near to the cursor as
- possible with the words "Note!:" and "Press:" provided. Fill the
- global array PopUpArray with what you wnat to say and the descriptions
- of the keys to be pressed. Put the keys into PopUpKey starting with
- the second key. The first key is always the Escape key. NLINES is
- how many "Note!" lines there are, and NKEYS is how many different
- responses are allowed. The users choice will be passed back in KEY.
-
- DaypartToClock: Converts Dayparts (17,280 five second dayparts make
- up one day) to hours minutes and seconds.
-
- ClockToDaypart: Reverse of above.
-
- RawTime: Returns the current system time in clock format.
-
- TimeString: Converts CLOCK to a string. If MILITARYTIME is true then
- the hours will be shown as 0 through 23 and there will be no meridiem
- indication. If MILITARYTIME is false, then the hours will be 1
- through 12 with a meridiem attached. The meridiem will show 'M' when
- exactly midnight and 'N' when exactly noon.
-
- GregToJul: Converts Gregorian dates (day, month, year) to Julian
- dates (1 to 365/366 days and the year). All of the calendar
- procedures and functions will work properly with leap years between
- the years 1901 and 2099 (That's more than DOS can cope with anyway).
-
- JulToGreg: Reverse of above.
-
- RawDate: Returns the system date in Gregorian format.
-
- Calendar: Converts GREG to a string in one of six formats. STYLE may
- be 'A'lpha-numeric (January 1, 1987), 'N'umeric (1-01-1987) or
- 'E'uropean (1 January, 1987). Size may be 'S'hort (Jan 1, 87) or 'L'ong.
-
- ScreenClock: Will display the system time and date on the screen.
-
- HelpNeeded: Where all of the help routines will be called from.
-
-
-
-
- Colors
-
- In the global variables there are three varibles that effect color. I
- have them set for mono screens using a color card. They are LFCC,
- DFCC and NFCC. The CC stands for composite color, as they carry both
- the text and background for the screen attribute. LF is Live Field, DF
- is Dead Field and NF is neutral field. When a field is not active, it
- uses DFCC a dimmer color. When it is active, it uses LFCC for those
- characters that can be altered and NFCC for those that are part of the
- uneditable mask. LFCC is as bright as I can make it and NFCC is
- slightly dimmer.
-
-
- Help Lines
-
- The file HELP.SCR contains the helplines that appear at the bottom of
- the screen. They're loaded into memory at runtime within the
- Initialize procedure and moved onto the screen with the calling of each
- Read procedure via the SetHelp procedure. The way to look at or change
- these is with a screen editor. I understand that there are some PD
- screen editors out, but I don't know how good they are.
-
-
- Key conversion
-
- All of the keys will return one of the following:
-
- a) a value in scan and a #0 in ascii.
- b) a 0 in scan and a value in ascii.
-
- for more info on what values may do what, see the table in KBVARS.PAS.
- This program uses those extended values found in SuperKey. For those
- that don't know what this means: When some keys are pressed when
- SuperKey is not resident, nothing is returned to work with. Hence you
- have a handicapped keyboard. Another thing that my program does that
- is a little different, is that it distinguishes between key
- combinations that are normally though to be the same thing. For
- example: The Backspace is normally considered to be the same as a
- control-Backspace. In ReadString, a Backspace will delete the
- character to the left, while a control-Backspace will delete all of the
- characters to the left.
-
-
-
-
-
-
- This source is hereby licensed for private, non-commercial use. It may
- be freely copied and distributed, but no consideration may be requested
- other than customary handling/transferring fees charged by recognized
- user's groups or bulletin boards. This source may not be acquired at the
- same time as any other product which is obtained by consideration (i.e.
- package deals).
-
- No warranties of any kind are provided. By using this software, the user
- assumes all risk.
-