home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / READSTR.ZIP / README.KB < prev   
Encoding:
Text File  |  1986-08-27  |  16.4 KB  |  383 lines

  1. ReadStuff   version 1.0    released 8-11-86
  2.             update  1.01            8-13-86
  3.             some documentation      8-15-86
  4.             code cleaning           8-19-86
  5.             update  1.02            8-27-86
  6.  
  7. Copyright 1986 by Gary Wheaton.
  8.  
  9. This is a group of procedures and fuctions whose final purpose is to have
  10. formated keyboard entry.
  11.  
  12. The main reason that I'm making this available is that I would like to
  13. make it better.  If you go through the code and find something that you
  14. can make faster, smaller or more powerful, please send this info to me
  15. via CompuServe EasyPlex [73547,2322] or mail to:
  16.  
  17.             Gary Wheaton
  18.             P.O. Box 68271
  19.             Portland, OR
  20.                 97268-0271
  21.  
  22. Contributions can be sent to the above address.
  23.  
  24. For reading this, editing the code and any other editing functions, I
  25. strongly recommend EDWIN by Kim Kokkonen.  With it, you can view this text
  26. and the code at the same time.  It's free and available at fine BBS's
  27. everywhere.
  28.  
  29. One thing I do need to warn you about right away is that for some of the
  30. routines, you will need to have Turbo Pascal with BCD (for use of the FORM
  31. command).  If someone doesn't have BCD and they find a good substitute for
  32. the FORM command, please let me know.
  33.  
  34. Credit needs to go to Brian Foley for his FastWrite routines.  They were
  35. what I butchered to make QWrite.  For those routines, Brian gives some
  36. credit to Marshall Brain, Kim Kokkonen and Bela Lubkin.  Brian also looked
  37. over this program and made many speed-up suggestions.
  38.  
  39. Credit also needs to go to Bela Lubkin.  He is the author of the
  40. MoveToScreen and MoveFromScreen procedures.
  41.  
  42. It's been brought to my attention that people with different displays are
  43. getting different results.  First of all let me say that this program will
  44. operate at it's peak on an AT&T 6300 (what I have).  It can work on mono,
  45. if you have the desire and don't know how to alter it, ask.  I've been
  46. told that the quality on the IBM CGA is much poorer than that of the AT&T
  47. or Compaq, and sometimes even illegible.  The best solution is to get a
  48. better card or monitor.  The next best solution is to modify the color
  49. defaults (see "Colors" below).
  50.  
  51.  
  52. update 1.01
  53.  
  54.   I included a .COM file for those that would like to see immediate
  55.   results of their download also for those that haven't solved the "FORM"
  56.   problem yet.
  57.  
  58.   I also made the QWrite a little more streamlined and fixed a cosmetic
  59.   bug in PopNote.
  60.  
  61.  
  62. code cleaning
  63.  
  64.   I just received the Turbo Power Utilities and ran PSA on this.  It found
  65.   a few unused variables and procedures.  So, the program will run exactly
  66.   the same, only take up less space in both source and code.
  67.  
  68.  
  69. update 1.02
  70.  
  71.   Shortened and sped up some procedures and functions in KBMISC, namely
  72.   those relating to windows and text boxes.
  73.  
  74.   Removed a bug from ReadString (it was allowing a bogus Cpos).
  75.  
  76.   Removed a bug from ReadDate (on leap year checking, had to change an "="
  77.   to "<>").
  78.  
  79.   Moved KBVARS.PAS, KBMISC.PAS and KBINIT.PAS all into one include file
  80.   KBMISC.PAS.
  81.  
  82.  
  83.  
  84. What little documentation there is.
  85.  
  86.   Here is a list of how all of the parameters of ReadString are supposed to
  87.   react.
  88.  
  89.     Option:  Passing a 'W' will write the string as it appears and return
  90.     without stopping for any keyboard input.  Passing an 'R' will write out
  91.     what is currently in Z under the form of MASK and then place the cursor
  92.     on CPOS and wait for key entry.
  93.  
  94.     AutoClear:  If CPOS=1 and nothing has been changed since entering the
  95.     field, upon typing an acceptable key, the field will be cleared and the
  96.     character will be placed in pos 1.
  97.  
  98.     InsertStatusLine: Whether or not the Insert/Overwrite status will be
  99.     displayed at the top of the screen.
  100.  
  101.     SetCposTo1OnEntry: will do just that if TRUE.
  102.  
  103.     Floater:  If TRUE, a floater will appear just after the last character
  104.     of the string.  I used it for debugging purposes, and after a while, I
  105.     decided that I liked it.
  106.  
  107.     DeadColorsOnExit:  some other routines use this routine.  So they want
  108.     to enter live and leave live. (see "Colors" below)
  109.  
  110.     HelpLine:  This will set which helpline will be displayed at the bottom
  111.     of the screen.  (see "Help Lines" below)
  112.  
  113.     HelpNum:  This number will be passed to procedure SetHelp, where a
  114.     global variable will then be assigned to it.  Should you ever press F1,
  115.     the appropriate help routine (not provided) will be executed from
  116.     procedure GetHelp.
  117.  
  118.     X,Y:  Where the first character of the field will be placed.
  119.  
  120.     ScanExitSet:  This set will contain all of the acceptable exit scan
  121.     codes, such as the Enter Key or maybe an up arrow key.  See the table
  122.     in KBVARS.PAS.  (see "Key conversion" below)
  123.  
  124.     Scan:  On exit, this variable will contain the scan code which forced
  125.     the exit.  This number wil be one of the numbers found in ScanExitSet.
  126.  
  127.     AsciiExitSet,Ascii:  Works the same way as ScanExitSet and Scan, except
  128.     for printable characters.
  129.  
  130.     Cpos:  On entry, the cursor will be set to the given values position of
  131.     the editable mask.  If you pass a 5, the cursor will be initially
  132.     placed at the fifth editable character.  On exit, Cpos will return the
  133.     last position of the cursor.
  134.  
  135.     Z:  The string that you want to have edited.  It will be written out as
  136.     the default at entry and the edited version will be given on exit.
  137.  
  138.     Mask:  Perhaps the most powerful part of this whole shebang.  You may
  139.     define what characters mean what for the mask, using the SetMask
  140.     procedure.  There is a function called StMask which will return a
  141.     Standard mask where the first character is any printable character
  142.     except lower case and the rest of the mask includes lower case.  This
  143.     will work provided that the masks that it uses are not different from
  144.     what they're set at in the procedure Initialize.  Anyway, an example of
  145.     a mask would be  '(&&&)&&&-&&&& ext:####'  the only editable characters
  146.     here are the '&' and the '#'.  Thus the longest string possible is 14
  147.     characters long.  As initially set up, the '&' allows numbers only and
  148.     the '#' allows standard printable characters.  When the field is
  149.     active, the editable charcters will have the color of LFCC and the
  150.     others will have NFCC.
  151.  
  152.  
  153.   Here is a list of parameters to the other six read procedures which may
  154.   not be too obvious.
  155.  
  156.     ReadChar-MaskSet:  A set of characters which are allowable to be
  157.     passed into Z.
  158.  
  159.     ReadReal-Cpos:  With an Integeral Field Length of 6 and a mantissa
  160.     length of 3, the cursor position numbers would look like this:
  161.     567,891.234.  So when Cpos is one, the cursor will be placed in the
  162.     right most position of the integral portion.
  163.  
  164.     ReadDate-OtherMode:  If OtherMode is 1 then when entering a date you
  165.     may press, say, 'W' and viola!  'Wednesday' appears.  To get back to
  166.     numeric dates, simply press any number.  'TFN' is short for "`till
  167.     further notice".
  168.  
  169.     ReadTime-MilitaryTime:  Keying is still the same, but the appearance
  170.     will be different between whether this is true or false.
  171.  
  172.     ReadTime-Ommisions:  Sometimes, you need to read just hours and
  173.     minutes or just minutes and seconds.
  174.  
  175.  
  176.  
  177.   Here is a list of what the procedures and functions in KBMISC.PAS are
  178.   supposed to do.
  179.  
  180.     GotoXYA:  Same as GotoXY, except that it has no regard to windows (the
  181.     "A" is for Absolute).
  182.  
  183.     WhereXA/WhereYA:  Same as WhereX/WhereY, except that is has no regard
  184.     for windows.
  185.  
  186.     QWriteA:  Will place the string ST on the screen starting at the
  187.     position X,Y without regard to windows.  If X is 0 then X will be set
  188.     to the current X.  Same for Y.  The string will be painted with the
  189.     color ATT (see "Colors" below) except when 0.  When ATT is 0, the
  190.     screen attributes will not be altered.  The cursor code can be in the
  191.     range of 0 to 3 which will have the following effects on exit: 0)put
  192.     the cursor back where you found it;  1)put the cursor on the first
  193.     character of the string;  2)put the cursor on the character after the
  194.     last character of the string.  This routine works much faster than the
  195.     built in Write and Writeln commands.
  196.  
  197.     QWrite:  Same as above, except this one minds windows.
  198.  
  199.     QWriteAttA:  Same as QWrite, except ST is replaced by LEN.  This will
  200.     not write any characters on the screen, only modify the attributes.
  201.  
  202.     QWriteAtt:  Same as above, except this one minds windows.
  203.  
  204.     MoveFromScreen/MoveToScreen:  Works the same as the move command.  The
  205.     only difference is that the move command causes "snow" while these
  206.     don't.
  207.  
  208.     BitCheck:  Will return true if BITNUM of ANYBYTE is set to 1.
  209.  
  210.     ByteVal:  Will return the byte value of the given string.
  211.  
  212.     Cursor:  Cursor(on) will turn the cursor on.  Cursor(off) will turn
  213.     the cursor off.  (It just doesn't get any easier)
  214.  
  215.     Spaces:  Will return a string of X spaces.
  216.  
  217.     StringOf:  Will return a string of CHARS with a length of HOWMANY.
  218.  
  219.     StMask:  The standard mask for ReadString.  If you leave '}' and '#'
  220.     set to what I origionally set them to, when the user types in the
  221.     string, the first char will be forced to upper case.  X denotes how
  222.     long you want the field to be.
  223.  
  224.     LeftText:  This procedure serves two purposes.  One is that if the
  225.     string is longer than FIELDSIZE, it will be truncated to that length.
  226.     The other is if it's shorter than FIELDSIZE, the difference will be
  227.     filled with spaces.
  228.  
  229.     RSpaceWhack:  Don't laugh.  This will whack all trailing spaces from a
  230.     string.
  231.  
  232.     LSpaceWhack:  Whacks leading spaces.
  233.  
  234.     SpaceWhack:  Whack leading and trailing spaces.
  235.  
  236.     SetHelp:  Puts help line number HLINE at the bottom of the screen and
  237.     sets the global variable CurrentHelpStatus equal to HNUM.  When F1 is
  238.     pressed while waiting for key entry, the procedure which corresponds
  239.     to CurrentHelpStatus will be executed.
  240.  
  241.     SetWindow:  This will do the same thing as Turbo's Window command,
  242.     except that it will record the coordinates for the purpose of
  243.     overlaying windows.  **MUST** be followed by a RecallWindow;
  244.  
  245.     RecallWindow:  Tosses out the current window and pops in the previous
  246.     window.  Does not work with LayWindow.
  247.  
  248.     TextBox:  Draws a box on the screen with the upper left corner at X,Y.
  249.     LINES is how many lines the box will be made of (0,1,2).  ABSORFLOAT
  250.     can be an 'A' or an 'F'.  'F' will pay attention to windows, 'A' won't.
  251.  
  252.     WTextBox:  Same as TextBox, except for:  1) the X,Y will have no
  253.     regard to the current window;  2) A window (cleared) will be declared
  254.     within the box;  3) **MUST** be followed by RecallWindow.
  255.  
  256.     LayWindow:  Same as WTextBox except:  1) what is currenty on the
  257.     screen will be recorded to be replaced later by PeelWindow.  2)
  258.     **MUST** be followed by PeelWindow.
  259.  
  260.     PeelWindow:  Peels off the current window.  Works only in conjuction
  261.     with LayWindow.
  262.  
  263.     GetKey:  Central entry.  Clock is updated here, help is called from
  264.     here, the scan and ascii codes are translated from here, etc. (see
  265.     "Key conversion" below).  If InsertStausLine is True then "Insert" or
  266.     "Overwrite" will be diplayed at the top of the screen.
  267.  
  268.     MaskIndex:  Converts the current charcter of the ReadString Mask into
  269.     a number in the range of 0 to 20 to access that mask set.  Passing
  270.     anything but the defined charcters results in a 0.
  271.  
  272.     SetMask:  M is the mask that you want to assign to TOKEN.  Any
  273.     characters in M will be assigned to TOKEN except for periods.  A
  274.     single period is interpreted here as "through".  So 'A.Z' is the
  275.     equivalent to 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.  'A.CX.Z' is the same as
  276.     saying 'ABCXYZ'.  To get a period into the set, either include a set
  277.     around the period, such as '-./' (the ascii values of '-','.','/' are
  278.     45,46,47 respectively) or enter two periods in a row.  '0.9..' will
  279.     allow any number or a period.
  280.  
  281.     ReadKey:  Filters the keys pressed.  Will only return if an acceptable
  282.     key is pressed.  If you don't want MASKTOKEN to play a part in the
  283.     selection process, pass it a #0.
  284.  
  285.     PopNote:  Puts a window on the screen as near to the cursor as
  286.     possible with the words "Note!:" and "Press:" provided.  Fill the
  287.     global array PopUpArray with what you wnat to say and the descriptions
  288.     of the keys to be pressed.  Put the keys into PopUpKey starting with
  289.     the second key.  The first key is always the Escape key.  NLINES is
  290.     how many "Note!" lines there are, and NKEYS is how many different
  291.     responses are allowed.  The users choice will be passed back in KEY.
  292.  
  293.     DaypartToClock:  Converts Dayparts (17,280 five second dayparts make
  294.     up one day) to hours minutes and seconds.
  295.  
  296.     ClockToDaypart:  Reverse of above.
  297.  
  298.     RawTime:  Returns the current system time in clock format.
  299.  
  300.     TimeString:  Converts CLOCK to a string.  If MILITARYTIME is true then
  301.     the hours will be shown as 0 through 23 and there will be no meridiem
  302.     indication.  If MILITARYTIME is false, then the hours will be 1
  303.     through 12 with a meridiem attached.  The meridiem will show 'M' when
  304.     exactly midnight and 'N' when exactly noon.
  305.  
  306.     GregToJul:  Converts Gregorian dates (day, month, year) to Julian
  307.     dates (1 to 365/366 days and the year).  All of the calendar
  308.     procedures and functions will work properly with leap years between
  309.     the years 1901 and 2099 (That's more than DOS can cope with anyway).
  310.  
  311.     JulToGreg:  Reverse of above.
  312.  
  313.     RawDate:  Returns the system date in Gregorian format.
  314.  
  315.     Calendar:  Converts GREG to a string in one of six formats.  STYLE may
  316.     be 'A'lpha-numeric (January 1, 1987), 'N'umeric (1-01-1987) or
  317.     'E'uropean (1 January, 1987).  Size may be 'S'hort (Jan 1, 87) or 'L'ong.
  318.  
  319.     ScreenClock:  Will display the system time and date on the screen.
  320.  
  321.     HelpNeeded:  Where all of the help routines will be called from.
  322.  
  323.  
  324.  
  325.  
  326.   Colors
  327.  
  328.     In the global variables there are three varibles that effect color.  I
  329.     have them set for mono screens using a color card.  They are LFCC,
  330.     DFCC and NFCC.  The CC stands for composite color, as they carry both
  331.     the text and background for the screen attribute.  LF is Live Field, DF
  332.     is Dead Field and NF is neutral field.  When a field is not active, it
  333.     uses DFCC a dimmer color.  When it is active, it uses LFCC for those
  334.     characters that can be altered and NFCC for those that are part of the
  335.     uneditable mask.  LFCC is as bright as I can make it and NFCC is
  336.     slightly dimmer.
  337.  
  338.  
  339.   Help Lines
  340.  
  341.     The file HELP.SCR contains the helplines that appear at the bottom of
  342.     the screen.  They're loaded into memory at runtime within the
  343.     Initialize procedure and moved onto the screen with the calling of each
  344.     Read procedure via the SetHelp procedure.  The way to look at or change
  345.     these is with a screen editor.  I understand that there are some PD
  346.     screen editors out, but I don't know how good they are.
  347.  
  348.  
  349.   Key conversion
  350.  
  351.     All of the keys will return one of the following:
  352.  
  353.       a) a value in scan and a #0 in ascii.
  354.       b) a 0 in scan and a value in ascii.
  355.  
  356.     for more info on what values may do what, see the table in KBVARS.PAS.
  357.     This program uses those extended values found in SuperKey.  For those
  358.     that don't know what this means:  When some keys are pressed when
  359.     SuperKey is not resident, nothing is returned to work with.  Hence you
  360.     have a handicapped keyboard.  Another thing that my program does that
  361.     is a little different, is that it distinguishes between key
  362.     combinations that are normally though to be the same thing.  For
  363.     example:  The Backspace is normally considered to be the same as a
  364.     control-Backspace.  In ReadString, a Backspace will delete the
  365.     character to the left, while a control-Backspace will delete all of the
  366.     characters to the left.
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373. This source is hereby licensed for private, non-commercial use.  It may
  374. be freely copied and distributed, but no consideration may be requested
  375. other than customary handling/transferring fees charged by recognized
  376. user's groups or bulletin boards.  This source may not be acquired at the
  377. same time as any other product which is obtained by consideration (i.e.
  378. package deals).
  379.  
  380. No warranties of any kind are provided.  By using this software, the user
  381. assumes all risk.
  382.  
  383.