home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / GET10.ZIP / GET.DOC next >
Encoding:
Text File  |  1988-11-09  |  73.1 KB  |  1,780 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.                                 THE GET UTILITIES
  13.  
  14.  
  15.                                    Version 1.0
  16.                                 9th Novemer, 1988
  17.  
  18.                          Copyright (c) 1988 Paul O'Nolan
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.             ┌──────────────────────────────────────────────────────┐
  28.             │ All you can take with you is what you've given away. │
  29.             └──────────────────────────────────────────────────────┘
  30.                                  Old Arab saying
  31.  
  32.  
  33.  
  34.  
  35.                                 Table of Contents
  36.  
  37.         Preface ....................................................... 2
  38.  
  39.         Distribution of this package .................................. 4
  40.  
  41.         Acknowledgements .............................................. 4
  42.  
  43.         Introduction .................................................. 5
  44.  
  45.         Units used by GET ............................................. 8
  46.  
  47.         The GET unit procedures ....................................... 9
  48.  
  49.         GETCHAR ....................................................... 9
  50.  
  51.         GETRESPONSE ................................................... 9
  52.  
  53.         GETBOOLEAN ................................................... 10
  54.  
  55.         GETDIGIT ..................................................... 10
  56.  
  57.         GETSTRING .................................................... 11
  58.  
  59.         GETNUM ....................................................... 19
  60.  
  61.         GETREAL ...................................................... 20
  62.  
  63.         GETDATESTRING ................................................ 23
  64.  
  65.         GETTIMESTRING ................................................ 25
  66.  
  67.         GETATTR ...................................................... 25
  68.  
  69.         DATES IN GENERAL ............................................. 26
  70.  
  71.         ADDENDUM ..................................................... 28
  72.  
  73.         RELEASE NOTES ................................................ 28
  74.  
  75.  
  76.                                  IMPORTANT NOTE
  77.  
  78.         This software uses the copyrighted QWIK routines from Eagle
  79.         Performance Software which have been included, in the form of a
  80.         TPU file, by permission. Those who want to use this product must
  81.         be registered for QWIK.  Registration can be obtained from:
  82.  
  83.            Eagle Performance Software
  84.            TP products
  85.            Attn: James H. Le May
  86.            P.O. Box 122237
  87.            Ft. Worth, TX  76121
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.                                                     GET utilities  Page 1
  95.  
  96.  
  97.         Preface
  98.  
  99.         To European readers
  100.  
  101.         Ever been tempted to pay for some American shareware with a
  102.         cheque dated in mm/dd/yy format -- knowing that it would bounce
  103.         as result? I hope not, but I wouldn't be surprised. It would be a
  104.         mean way of making a point even if it needs making badly. Our
  105.         support is expected without much effort to earn it.
  106.  
  107.         Have you decided against supporting certain programs that are
  108.         shareware in the US and sold as cut down commercial rip offs in
  109.         Europe? I hope so.
  110.  
  111.         American shareware authors are aggrieved at our lack of support.
  112.         In general, they are unaware of the reasons for this. Write to
  113.         them.
  114.  
  115.         You may register as a user of this package by sending me the
  116.         equivalent of US $1.
  117.  
  118.  
  119.         To American readers:
  120.  
  121.         I have an admission to make. Although I use many US originated
  122.         shareware programs, I have registered as a user of only a few --
  123.         and all when I lived in the US recently (as a graduate student)
  124.         and had a $ check book. With your help I'd like to remedy this.
  125.  
  126.  
  127.         Excuses, Excuses
  128.  
  129.         I have excuses for not registering ALL the US shareware I use.
  130.         It's overpriced, it's a hassle logistically, I hardly ever use
  131.         some programs etc. You know the score. If we (this means you too)
  132.         paid the asking price for all of what we use we'd be much poorer,
  133.         though not as impoverished as we'd be if shareware disappeared.
  134.         There's no denying that Vern Buerg -- whose LIST program I have
  135.         not registered -- ought to be a millionaire from the popularity
  136.         of LIST. I don't know anyone who doesn't use it and I don't know
  137.         anyone who's paid for it. There's something wrong here! Have YOU
  138.         paid for it? Are you using it? Right now?!
  139.  
  140.         I'd like to see software authors do well out of programs as
  141.         popular as LIST. Most of us would. I'd have given Dando Shaft a
  142.         $1 but I'd have baulked at $25. With so many aspiring
  143.         millionaires attaching importunate messages to their programs
  144.         it's all too easy to ignore the requests for support from those
  145.         that deserve it. This is not to deny anyone's right to ask for
  146.         what they want or our debt to the software authors whose work we
  147.         use. I think part of the problem is that we are spoiled for
  148.         choice and don't always agree that a program is worth what the
  149.         author asks for it.
  150.  
  151.         I'd be a lot happier and I think a lot of shareware authors would
  152.         be richer if they asked for no more than they would get from the
  153.         royalty on a book. I'd cheerfully register as a user of any
  154.         number of programs costing as much as, say, a magazine. Agreed?
  155.  
  156.  
  157.         GET utilities  Page 2
  158.  
  159.  
  160.         And More Excuses
  161.  
  162.         Now for my logistic excuses. It's not EASY for a European user to
  163.         become a registered user of an American shareware program. Why?
  164.         How'd you like to send me a check for £5? You don't have a
  165.         sterling bank account?! Sorry, I can't do it by credit card.
  166.  
  167.         Let's suppose I couldn't sleep at night until I'd sent you $15. I
  168.         have a choice. I can take time off work, visit a bank to organise
  169.         a foreign currency draft (would you do this?). Alternatively, I
  170.         can just send you a check. Your bank would send it for collection
  171.         and keep most of the money. Knowing this I might decide it was a
  172.         waste of time. I might not even bother to write and say "nice
  173.         program" (and "pity about your banking system").
  174.  
  175.  
  176.         Here's the beef
  177.  
  178.         What do I suggest? If you like this package and use it I ask you
  179.         to send me a dollar bill. I will use it to register American
  180.         shareware I use.
  181.  
  182.         If you have any other ideas on how Europeans can better support
  183.         American shareware drop me a line.
  184.  
  185.  
  186.         To American Shareware Authors
  187.  
  188.         Don't treat your international users with the same apparent
  189.         contempt as some of the "big names" in the software business.
  190.         Europe could account for much of your business if you play it
  191.         right. It's a bigger market than the US and growing faster.
  192.  
  193.         There's an argument, an excuse for bad service or no service,
  194.         that European users are hard to support. Oh sure there's a time
  195.         difference, ok. In fact, European software users are not SO much
  196.         more difficult to support than users in, say, Alaska. Most speak
  197.         English. Federal Express, Purolator, DHL etc. (all but UPS)
  198.         deliver here. Then there's the mail. We also have telephones,
  199.         packet switching systems and many of us use services like
  200.         CompuServe. If you can't support your European users directly (by
  201.         mail even) consider charging them less.
  202.  
  203.         Try to make your software language independent so that the user
  204.         interface can be adapted without too much hassle and do support
  205.         international date formats and alternative currency symbols.
  206.  
  207.         First you must make people WANT to pay for your software.
  208.  
  209.         Next you could try to make it easier for them to pay you. THIS is
  210.         the biggest hassle and the insular American banking system
  211.         doesn't help. Until this problem disappears, as it will, you'll
  212.         have to be creative. I hope to send CASH very soon!
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.                                                     GET utilities  Page 3
  220.  
  221.  
  222.         Distribution of this package
  223.  
  224.         This package may not be sold under any circumstances. It may not
  225.         be distributed by PC-Sig or any organisation that operates in a
  226.         substantially similar manner, including the Turbo User Group of
  227.         Poulsbo, Washington. User groups who publish annual accounts and
  228.         have elected officers may distribute this software for a nominal
  229.         charge to cover the costs of such distribution. This package must
  230.         be distributed without changes to the software or accompanying
  231.         documentation.
  232.  
  233.  
  234.         Acknowledgements
  235.  
  236.         This modest contribution to the "many hands make light work"
  237.         school of programming would not have been possible without the
  238.         work of others. Much as I have yet to learn (I'm working on it),
  239.         I have gleaned a lot from reading source code unselfishly made
  240.         available for public scrutiny by all of the following
  241.  
  242.  
  243.         David Bennett
  244.         Scott Bussinger
  245.         David Dubois
  246.         Ted Lassagne
  247.         Jim Le May
  248.         Carley Phillips
  249.         Richard Sadowsky
  250.         Juan Vegerra
  251.  
  252.  
  253.         I thank them all, Jim LeMay and Richard Sadowsky in particular.
  254.  
  255.         If you do any serious Turbo Pascal programming should obtain and
  256.         register a copy of Jim Le May's QWIK screen utilities. You cannot
  257.         buy a better package. I couldn't imagine working without it and I
  258.         think it's important that people like Jim are sufficiently
  259.         rewarded for their work to go on making it so readily available.
  260.  
  261.  
  262.         Paul O'Nolan
  263.         Newstead,
  264.         Forbes Place,
  265.         Hatton of Fintray,
  266.         Aberdeen AB2 0YB
  267.         Scotland, UK
  268.  
  269.         CompuServe 72007,242
  270.         c/o EDAS BBS (Aberdeen) 0224-624264
  271.  
  272.  
  273.  
  274.  
  275.         The GET utilities are copyright by Paul O'Nolan 1988.
  276.  
  277.  
  278.  
  279.  
  280.  
  281.         GET utilities  Page 4
  282.  
  283.  
  284.                          GET UTILITIES v1.0 October 1988
  285.  
  286.         Introduction
  287.  
  288.         The GET utilities consist of a number of Turbo Pascal procedures
  289.         for getting input from the screen, with dynamic validation where
  290.         possible. The procedures are written to make screen painting and
  291.         editing straightforward, as well as enabling the provision of
  292.         field dependent prompts and context sensitive help.
  293.  
  294.         As my use of borrowed code illustrates I hate reinventing wheels.
  295.         Nevertheless, I knew I was going to have to write this set of
  296.         procedures when I purchased a copy of the otherwise excellent
  297.         Turbo Professional package from Turbo Power Software and sat down
  298.         to look at it's data entry routines. The idea that one could
  299.         enter "abc" in a numeric field and not know about it until one
  300.         pressed <return> was not acceptable to me. I wanted keystroke by
  301.         keystroke validation where possible, just for starters.
  302.  
  303.         After a couple of evening's work I came up with
  304.  
  305.  
  306.         GETBOOLEAN    Get a boolean value
  307.         GETCHAR        Get a character
  308.         GETDIGIT    Get a numeric digit
  309.         GETSTR(ING)    Get a string
  310.         GETBYTE        Get an integer, type byte
  311.         GETSHORTINT    Get an integer, type shortint
  312.         GETINTEGER    Get an integer
  313.         GETWORD        Get an integer, type word
  314.         GETLONGINT    Get an integer, type longint
  315.         GETREAL        Get a real number
  316.         GETDATESTR(ING)    Get a date string (variable format)
  317.         GETTIMESTR(ING)    Get a time string
  318.         GETATTR        Get a color attribute
  319.  
  320.  
  321.         ... a list of procedures I thought I should, and did, write.
  322.         Writing them took a little longer.
  323.  
  324.         Next I spent several weekends adding or fixing "one more thing"
  325.         so I could call them "finished." Then, to my delight, Borland
  326.         announced Turbo Pascal v5.0 and I thought I really ought to get
  327.         this out the door before they actually delivered. In the UK this
  328.         meant several months grace because Borland, like Microsoft,
  329.         treats the European customer as a second class customer (pourquoi
  330.         Philippe?) -- something Compaq and IBM make a point of not doing.
  331.         Back to my story...
  332.  
  333.         All except GETATTR are part of the GET unit. In addition to the
  334.         above, GETRESPONSE, which is similar to GETCHAR but which is not
  335.         intended for data entry, is included. Procedures ending in (ING)
  336.         have two versions, with the shorter procedure name corresponding
  337.         to a version having an abbreviated parameter list, with default
  338.         values used for the omitted parameters.
  339.  
  340.         Some supporting software is used and recommended:
  341.  
  342.         A unit of functions GETFNS used by the GET procedures is required
  343.  
  344.                                                     GET utilities  Page 5
  345.  
  346.  
  347.         and included. Jim LeMay's QWIK screen procedures (shareware,
  348.         v4.2) and Richard Sadowsky's TOOLS4 procedures (public domain,
  349.         v1.0) are used extensively in this package. These are essential
  350.         if you wish to make changes to this package, but are not
  351.         otherwise required. Mark Van Kekerix's QHELP program is useful
  352.         but not essential. The GETATTR procedure requires Jim LeMay's
  353.         WNDW package. If subsequent versions of this package do not make
  354.         additional use of WNDW I may alter GETATTR to work without it.
  355.  
  356.  
  357.         The files in this package are:
  358.  
  359.  
  360.         GETTHIS.DOC     A READ.ME file by another name
  361.         GETDEMO.PAS     Demonstration program for this package
  362.         GETDEMO.DOC     Notes on GETDEMO
  363.         GET.DOC         This file
  364.         GETFNS.PAS      A unit of functions used by GET unit
  365.         GETFNS.TPU      Compiled GETFNS unit
  366.         GETOBJ.ARC      Archive of OBJ files used by GETFNS unit
  367.         GETVARS.PAS     Global variable unit used by GET unit
  368.         GET.PAS         Compile this file to produce GET.TPU
  369.         GETSTR.PAS      Source
  370.         GETNUM.PAS        code
  371.         GETREAL.PAS         for
  372.         GETDATE.PAS           GET
  373.         GETTIME.PAS             procedures {included by GET.PAS}
  374.         GETCOLOR.EXE    Program demonstrating GETATTR procedure
  375.         GETCOLOR.PAS    Source code for above
  376.         GETHELP         Help file for this package for use with QHELP
  377.         QWIK.TPU        Jim LeMay's QWIK screen unit, used by GET
  378.  
  379.  
  380.         Suggestions, enhancements and problem reports are all welcome.
  381.  
  382.         Few things are more exasperating for a BBS user than seeing a new
  383.         version of a package, with bug fixes, within days of downloading
  384.         an earlier version. There will not be another version of GET for
  385.         a while. I wrote it in order to write some other programs, which
  386.         I'm now going to write! GET will be updated in a few months, when
  387.         I catch up with Turbo Pascal v5.0 etc.
  388.  
  389.         If anyone cares for the job, there's an obvious application
  390.         waiting to be written using GET: a screen design program that
  391.         generates source code for screen based data entry. There are a
  392.         number of commercial programs that generate Turbo Pascal code
  393.         from screen designs but none, to my knowledge, that are shareware
  394.         or public domain. Drop me a line before undertaking this, I'll
  395.         advise you if anyone else has volunteered/started. Of course, the
  396.         GET procedures themselves could be used to help with the job.
  397.  
  398.         Since the preceding paragraph was written a package called OASIS
  399.         has been uploaded to CompuServe which fits the bill marginally
  400.         better than a mirage. Source code is not available.
  401.  
  402.  
  403.  
  404.  
  405.  
  406.         GET utilities  Page 6
  407.  
  408.  
  409.         Why QuickHelp?
  410.  
  411.         Mark Van Kekerix's QHELP program (in IBMSW on CompuServe) is a
  412.         useful tool for use when programming calls to GET procedures.
  413.         Even though I wrote GET I can't remember all the parameters for
  414.         all the procedures or the order of them. However, with QHELP all
  415.         I need to do is enter the name of the procedure, hit the hot key,
  416.         and read. It's even better than the built in help for Turbo
  417.         Pascal. QuickHelp is an excellent program and well worth having.
  418.  
  419.  
  420.                                 UNITS USED BY GET
  421.  
  422.         GETFNS
  423.  
  424.         This unit contains a number of functions used in GET and some
  425.         others that I use frequently, often in conjunction with GET. It's
  426.         a convenient repository for functions that are used in "higher
  427.         level" units. The functions here are all straightforward and
  428.         should be adequately documented in the code. This unit makes
  429.         extensive use of assembly language procedures written by Jim
  430.         Le May and Richard Sadowsky. Several of their routines replaced
  431.         code of mine and sometimes of others. I try to be an honest
  432.         magpie and have acknowledged my sources where possible.
  433.  
  434.  
  435.         GETVARS.PAS
  436.  
  437.         This unit contains the type definitions, typed constants (incl.
  438.         error messages), global variable declarations and code for the
  439.         smaller procedures and functions used in the GET package.
  440.  
  441.  
  442.         Global variables
  443.  
  444.         Numerous global variables are defined and initialised in GETVARS.
  445.         The meaning and use of most will be apparent from their names.
  446.         E.g:
  447.  
  448.         PasswordChar is set to a space, meaning that spaces are output
  449.         for each character entered using the get string routine when
  450.         PasswordField is true. An alternative value might be an asterisk.
  451.  
  452.         If AutoTab is true then fields are completed automatically on
  453.         entering the last possible character, otherwise the user must
  454.         enter a carriage return to complete the field.
  455.  
  456.         etc.
  457.  
  458.         A quick look at the code should suffice for any variables not
  459.         described in this document.
  460.  
  461.  
  462.         Error messages
  463.  
  464.         The text of all error messages is stored in the GETVARS unit. If
  465.         you wish to change a message you need only alter it in
  466.         GETVARS.PAS. Messages are stored as variables not constants to
  467.         minimise the impact on the stack of passing them to procedures
  468.  
  469.                                                     GET utilities  Page 7
  470.  
  471.  
  472.         (only the address of a variable is passed) and reduce code size
  473.         (constants are embedded in the code at each occurrence).
  474.  
  475.         All error messages are output on either of the two lines at the
  476.         bottom of the screen. Ordinarily the last line is used. The
  477.         penultimate and last lines are written to using the procedures
  478.         error and error2 respectively. To prevent the issuance of
  479.         multiple error messages, error messages are suppressed if the
  480.         appropriate error line is not blank (monitored using boolean
  481.         variables: ErrorLineClear and Error2LineClear). A consequence is
  482.         that the appropriate procedure, clearerror or clearerror2, should
  483.         be executed to clear any outstanding error messages and reset the
  484.         corresponding boolean variable prior to accepting keyboard input.
  485.  
  486.  
  487.         Other messages
  488.  
  489.         Informational messages (status information, acknowledgements,
  490.         warnings etc.) are also rendered on the bottom two lines of the
  491.         screen, using the procedures info and info2. These procedures do
  492.         not ring any bells, they are otherwise identical to error and
  493.         error2.
  494.  
  495.         The bell procedure may be used to give discretionary beeps to
  496.         wake the user up. Sound is made only if SoundOn is true, this is
  497.         a variable over which the user should have control. The beep
  498.         procedure sounds a bell regardless of the status of SoundOn.
  499.  
  500.         The AltWrite procedure displays text in one or two attributes
  501.         alternated by means of a switch passed as a parameter and
  502.         embedded within text. The procedure then pads the rest of the
  503.         line with spaces using the attribute in effect at the end of the
  504.         string (so that "reverse video" messages don't end abruptly half
  505.         way across the screen). A typical string to be displayed with
  506.         this procedure might be:
  507.  
  508.           Delete ^ALL^ files? ^Y^/^N^?
  509.  
  510.         It is not necessary to hard code the switch character into the
  511.         message. The brighten procedure can be used to embed text in a
  512.         pair of switches:
  513.  
  514.             error(text + brighten(text) + text);
  515.  
  516.         This procedure uses the value of DefaultAltSwitch for the switch
  517.         character.
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.         GET utilities  Page 8
  532.  
  533.  
  534.                                   THE GET UNIT
  535.  
  536.         GET procedures
  537.  
  538.         It is expected that GET procedures will ordinarily be called
  539.         twice to gather information from fields. On the first occasion,
  540.         with the global variable PaintingFields set to true, each GET
  541.         procedure will simply display the field contents and exit. This
  542.         makes screen painting fairly easy. EditingField is another
  543.         boolean variable -- the logical negative of PaintingFields -- it
  544.         was created for readability. If EditingField is true then the
  545.         active GET procedure will seek input. By default, a field prompt
  546.         is not redisplayed on the second call to the relevant get
  547.         procedure. This may be changed by changing the value of the
  548.         boolean global variable RediplayPrompts to true.
  549.  
  550.         All GET procedures get input into a nominated variable at
  551.         specified screen co-ordinates following a prompt string or
  552.         fieldname. The prompt string may be blank; if it is too long to
  553.         allow the field to fit on the screen it will be left-shifted
  554.         automatically until the field can fit on the screen. If it is
  555.         still too big it will be truncated as required.
  556.  
  557.         Notes
  558.  
  559.         Always ensure that you initialise all variables passed to get
  560.         procedures. If you use get procedures independently, i.e. outside
  561.         the context of a form make sure that you set PaintingFields to
  562.         false and RedisplayPrompts to true.
  563.  
  564.  
  565.         GETCHAR
  566.  
  567.         This procedure gets a single character in the variable
  568.         'response'.The character entered is validated against a set of
  569.         characters passed as a parameter (valid_keys). If possible, an
  570.         appropriate error message is issued when an invalid key is
  571.         pressed: "Numeric input expected" e.g. The input type expected is
  572.         deduced if the set of valid characters corresponds to one of the
  573.         predefined sets. No such message can be issued if some other set
  574.         of characters is passed as the set of valid characters (the bell
  575.         procedure is executed however). In such cases you should
  576.         highlight the valid options in the prompt or display them
  577.         elsewhere on the screen.
  578.  
  579.         Note: the field will not be highlighted during data entry using
  580.         the parameter cursor_attr unless FieldCursor is 0 (i.e. the
  581.         global variable FieldCursor has precedence over the parameter).
  582.  
  583.  
  584.         GETRESPONSE
  585.  
  586.         Like GETCHAR, this procedure gets a single character in the
  587.         variable 'response'.
  588.  
  589.         The prompt string is displayed using the AltWrite procedure
  590.         described above, so DefaultAltSwitch characters may be embedded
  591.         in it to emphasise particular words if necessary. The default
  592.         normal and bold video attributes, attrNM and attrBO, are passed
  593.  
  594.                                                     GET utilities  Page 9
  595.  
  596.  
  597.         to AltWrite. Validation is accomplished as per GETCHAR.
  598.  
  599.         If the value entered for 'response' is y or Y and 'makesure' is
  600.         true then the response to 'Sure Y/N' is elicited via a recursive
  601.         call. This is handy for getting answers to questions such as
  602.         'Delete all files.' Confirmation of responses other than y/Y is
  603.         not possible with this procedure.
  604.  
  605.         Whereas GETCHAR is intended for entry of data, this procedure is
  606.         intended for getting answers to questions, typically outside the
  607.         data area and using default values for display attributes. Fewer
  608.         parameters are needed as result.
  609.  
  610.  
  611.         GETBOOLEAN
  612.  
  613.         This is essentially a call to GETCHAR with the redundant
  614.         parameters taken out and the result translated to the appropriate
  615.         type. There can be no default value parameter for this procedure,
  616.         i.e. one entered in the event of the field being left "blank",
  617.         since a boolean value must be true or false.
  618.  
  619.         The grey plus and minus keys on the numeric keypad are probably
  620.         the most convenient keys to set the value of a boolean variable
  621.         to true or false. The following keys may be used:
  622.  
  623.         True:  T, t, +, Y, y, 1
  624.         False: F, f, -, N, n, 0, <space>
  625.  
  626.  
  627.         GETDIGIT
  628.  
  629.         This procedure is used to get a numeric character, decimal point,
  630.         plus or minus sign and certain editing characters at a designated
  631.         screen position. GETDIGIT is not intended to be called by the
  632.         user but by other GET procedures.
  633.  
  634.         This procedure has a feature it shouldn't have: hard coded
  635.         bindings between certain ASCII characters and commands (e.g. ^J
  636.         is tested for instead of the enter_default command). This is
  637.         inconsistent with the way the rest of the code is intended to
  638.         work and this discrepancy should be / will be fixed. I'm pointing
  639.         it out just to indicate that I know about it. It needn't affect
  640.         you unless you wish to alter the commands used to accomplish
  641.         certain things, in which case you'll need to edit this procedure
  642.         as well as the get_edit procedure (in GETFNS.PAS).
  643.  
  644.         This procedure should be implemented by a call to GETCHAR!
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.         GET utilities  Page 10
  657.  
  658.  
  659.         GETSTR
  660.  
  661.         This procedure is used to get a string fom the screen. It is,
  662.         effectively, a line editor and may be used to edit a series of
  663.         lines in a window. It may also be used for routine data entry
  664.         purposes, collecting and validating information from string
  665.         fields.
  666.  
  667.         Why bother with a line editor? Surely a full screen editor, such
  668.         as the binary editor provided with the Turbo Editor Toolbox,
  669.         would be more useful? If you wish to edit some text in a window
  670.         on its own, i.e., without reference to the contents of other
  671.         windows, this may well be the case. If, however, you have a need
  672.         for an application in which data in separate windows are linked,
  673.         then adapting a line editor to do the job is often a lot simpler
  674.         than reprogramming a text editor. A very trivial example in this
  675.         package is the GETTIME procedure, where the separate windows
  676.         amount to no more than two subfields.
  677.  
  678.         How it works
  679.  
  680.         Attributes:
  681.  
  682.         The string is displayed at the co-ordinates passed using the
  683.         attribute parameter attr. The value of attr is considered the
  684.         native attribute for the field, however this may be overridden by
  685.         the global variable FieldCursor (if FieldCursor is not zero and
  686.         the field is being edited rather than just displayed).
  687.  
  688.         FieldCursor is used to highlight the field the cursor is on and,
  689.         as you would expect, it moves around from field to field with the
  690.         ordinary cursor. The ordinary blinking underline cursor is a
  691.         fairly miserable specimen. I prefer a non-blinking block cursor
  692.         myself, so I've given GETSTR the ability to use one -- "faked"
  693.         using a video cursor.
  694.  
  695.         To make a video cursor the blinking underline is switched off and
  696.         a block cursor is simulated using the attribute byte of the
  697.         appropriate screen location. This byte is set to the value of the
  698.         parameter cursor_attr. This value should be different from attr
  699.         if you wish to use this kind of cursor -- you don't have to of
  700.         course. Arguably, cursor_attr should be a global variable, like
  701.         FieldCursor, since it's not very likely that you'd change it
  702.         between calls to GETSTR. In overwrite mode the cursor will change
  703.         to include a blinking underline.
  704.  
  705.         If you elect not to use a non-blinking block cursor, in the
  706.         colour of your choice, a blinking block cursor will be used
  707.         instead, and overwrite mode will be indicated by a blinking
  708.         underline cursor. If you find this blinking discourse hard to
  709.         follow the following table summarizes everything.
  710.  
  711.                              Insert                 Overwrite
  712.  
  713.         cursor_attr =  attr  blinking block*        blinking underline
  714.         cursor_attr <> attr  non-blinking block** + blinking underline
  715.  
  716.          * black
  717.         ** any colour
  718.  
  719.                                                    GET utilities  Page 11
  720.  
  721.  
  722.  
  723.         The extent of the field is indicated, even if it is blank, if the
  724.         attribute used to display it differs in background colour from
  725.         the rest of the screen -- spaces are output to clear to the end
  726.         of the field when the string is displayed.
  727.  
  728.  
  729.         The PICTURE
  730.  
  731.         The picture parameter controls how the string is to be disposed
  732.         on the screen and controls how individual characters are to be
  733.         validated. In other words, it provides for a degree of formatted
  734.         input. Suppose, for the sake of illustration, that you wished to
  735.         get a 6 character date from the screen. The following picture
  736.         would help:
  737.  
  738.                                  '99/99/99'
  739.  
  740.         The 9's indicate that only numeric input will be accepted in the
  741.         corresponding positions. The slashes are field markers and will
  742.         not be part of the string returned by GETSTR.
  743.  
  744.         Characters in specific positions may be constrained to belong to
  745.         particular character sets: numeric, alphabetic, alphanumeric and
  746.         printable are provided by default (you can add sets of your own).
  747.         The picture descriptors for these sets are as follows:
  748.  
  749.  
  750.         picture character          character set
  751.  
  752.                 A                  alphabetic
  753.                 C                  alphanumeric
  754.                 P                  printable
  755.                 9                  numeric
  756.                 X                  any character
  757.                 any other          any character
  758.  
  759.  
  760.         These picture characters may be entered in the picture string in
  761.         upper or lower case. Upper case picture characters will cause
  762.         characters entered at the corresponding screen position to be
  763.         converted to upper case. Thus a picture beginning 'Aa' could be
  764.         convenient for entering names, with the initial character
  765.         automatically converted on entry to upper case.
  766.  
  767.         If more than one character set is employed in validating a
  768.         string, the string is edited in overwrite mode and the Ins key
  769.         has no effect. The last mode (overwrite or insert) will be
  770.         resumed at the next field if appropriate. When character
  771.         validation is position dependent it makes no sense to allow
  772.         characters to be displaced by the insertion or deletion of other
  773.         characters, this is why insert mode is temporarily disabled.
  774.  
  775.         If you wish to edit a field 5 characters long, without any
  776.         constraints on what characters are entered, you do not need to
  777.         pass GETSTR a picture of 'xxxxx'. A picture of just 'x' will do.
  778.         In mapping the correspondences between the picture and data
  779.         strings GETSTR will apply the last picture character repeatedly
  780.         all the way to the end of the data string. If you wish to get 3
  781.  
  782.         GET utilities  Page 12
  783.  
  784.  
  785.         digits followed by 20 alphabetic characters a picture of '999a'
  786.         will suffice. The number of a's to the end of the string will be
  787.         controlled by the value passed for maxstrlen. However, if you
  788.         wish to get 79 alphanumeric characters followed by a digit you
  789.         would need to pass a string of 79 a's and a 9 (if you were
  790.         determined to do it like that). There is a shortcut however, see
  791.         RepeatCharacter below.
  792.  
  793.         The parameters instr and picture are both of type string, meaning
  794.         that they cannot exceed 256 characters in length. This should not
  795.         cause you any difficulty. I just wish to point out here that, as
  796.         you have already seen, their lengths need not correspond. The
  797.         picture string can actually be longer than the data string, since
  798.         it can contain embedded field markers.
  799.  
  800.  
  801.         Field Markers
  802.  
  803.         Field markers are characters which are output at designated
  804.         positions on the screen within the string field but which are not
  805.         actually returned as part of the string. GETSTR uses a predefined
  806.         set of field markers which you can change if you wish to (see
  807.         GETVARS). The default set includes most punctuation characters
  808.         and special symbols. You are in no way debarred from entering
  809.         these in the string by virtue of their being employed as field
  810.         markers. Field markers can be strung together in succession as
  811.         well as being entered individually. One special field marker
  812.         deserves mention.
  813.  
  814.         The letter 'B' used in the picture is used to denote a blank
  815.         character in the input field over which the cursor will skip.
  816.         Thus, a picture of
  817.  
  818.                               '(999)B999-9999'
  819.  
  820.         would leave a blank on the screen between the area code and the
  821.         rest of the telephone number. The value of maxstrlen (following
  822.         picture string in the parameter list) should, of course, be 10.
  823.         There are 10 digits in the string. You could render the picture
  824.         as '(999)B999-9' if you wanted to, and let GETSTR fill in the
  825.         last few characters automatically, however your code would not be
  826.         quite as readable. Note, B is used instead of a space to make
  827.         counting field markers easier.
  828.  
  829.  
  830.         Switches
  831.  
  832.         Special characters or switches may be embedded in the picture
  833.         string to control how it is interpreted by GETSTR. Naturally,
  834.         aone of these should appear in the predefined set of field
  835.         markers, or they will be ignored in any picture string. You may
  836.         change the switch characters if you wish.
  837.  
  838.  
  839.         DefaultAltSwitch
  840.  
  841.         First is the constant DefaultAltSwitch (type char). It's default
  842.         value is a tilde. It's name derives from the fact that this
  843.         character is the default switch for the AltWrite procedure which
  844.  
  845.                                                    GET utilities  Page 13
  846.  
  847.  
  848.         is used to display text using either of two video attributes,
  849.         with this character toggling between them. It is used to trigger
  850.         the copying of text from the picture to the screen as if the
  851.         characters following the switch were field markers. Thus, if an
  852.         asterisk was the switch character, the following picture would
  853.         allow you to get a date with '19' displayed on the screen for the
  854.         first two digits of the year
  855.  
  856.  
  857.                                 '99-99-*19*99'
  858.  
  859.         Note that GETSTR will not return the '19' as part of the string
  860.         (unless you modify the code!).
  861.  
  862.  
  863.         ShiftCharacter
  864.  
  865.         The second switch is the constant ShiftCharacter, with a default
  866.         value of "\". This character is used to force GETSTR to treat the
  867.         string parameter (instr) as one or more string segments which,
  868.         although they belong together, are not displayed contiguously.
  869.         This switch can be used to get GETSTR to break a 240 character
  870.         comment string into three 80 character lines, e.g. Alternatively,
  871.         it could be used to facilitate collection of input from a few, or
  872.         even a few dozen, apparently separate text fields into one string
  873.         (edits could be accepted or aborted collectively). Of course
  874.         there would still be only one field prompt provided by GETSTR.
  875.  
  876.         The character following the ShiftCharacter controls how GETSTR
  877.         breaks the string; the shift character itself is merely a flag
  878.         indicating that the string is to be broken. If the next picture
  879.         character is an "N" then the string is wrapped so that the next
  880.         data string character is located beneath the first character in
  881.         that string. Thus, using the default value of ShiftCharacter, the
  882.         sequence "\N" embedded in the picture string connotes a new line.
  883.         A picture of
  884.  
  885.                                  'xxx\Nxxx\Nxxx'
  886.  
  887.         will correspond to 3 x 3 block of characters on the screen.
  888.  
  889.         If the character following the ShiftCharacter is anything other
  890.         than an "N" then GETSTR displaces the next data string character
  891.         by the ordinal value of that character. Thus, a picture of
  892.  
  893.                             'xxx\' + chr(10) + 'xxx'
  894.  
  895.         could be used for two three character fields separated by 10
  896.         screen positions. Note that this picture is not equivalent to
  897.  
  898.                                'xxxBBBBBBBBBBxxx'
  899.  
  900.         The B in the picture will cause the corresponding screen location
  901.         to be blanked and displayed using an attribute controlled by
  902.         GETSTR. This will not happen using the first picture above.
  903.  
  904.         If you wish to effect a displacement of ord('N') or one in excess
  905.         of 255 locations simply use two or more successive displacements.
  906.         Note: All displacements must be positive.
  907.  
  908.         GET utilities  Page 14
  909.  
  910.  
  911.  
  912.  
  913.         RepeatCharacter
  914.  
  915.         The third switch is the RepeatCharacter (default value: "@").
  916.         This is used in a similar manner to the ShiftCharacter, except
  917.         that the character following the RepeatCharacter represents a
  918.         repeat value rather than a displacement. The picture character
  919.         repeated is the last one used. The RepeatCharacter allows long
  920.         picture strings to be specified conveniently (no miscounting and
  921.         a reduced impact on code size and stack space). Thus, returning
  922.         to the previous example, a picture of
  923.  
  924.         'x@' + chr(79) + '\N' + 'x@' + chr(79) + '\N' + 'x@' + chr(79)
  925.  
  926.         or
  927.  
  928.         'x@' + #79 + '\N' + 'x@' + #79 + '\N' + 'x@' + #79
  929.  
  930.         corresponds to a 240 character string broken into three lines of
  931.         80 characters each. This could be rendered more economically as
  932.         'x@O\Nx@O\Nx@O' or even 'x@O\N@P\N@P'. Note that #n may be used
  933.         instead of chr(n).
  934.  
  935.         As an aside, # is a hash character, or if you want to be exactly
  936.         correct, an octothorpe. It is not, repeat not, a pound character.
  937.  
  938.         Note: the display_prompt procedure takes account of the fact that
  939.         the string may be broken. It would not necessarily be appropriate
  940.         to left shift the prompt and a long string field if the string
  941.         was split into, say, two segments and enough room was allowed for
  942.         these. However, it is assumed that string segments following the
  943.         first will be on succeeding lines and no check is made to ensure
  944.         that there is enough room for these.
  945.  
  946.         If you are silly and ask GETSTR to get data from a field whose
  947.         picture string doesn't provide for anything other than embedded
  948.         (marker) text and field markers you, and the field, will be
  949.         ignored. GETSTR will display what it can and exit.
  950.  
  951.         Naturally, GETSTR allows you to display embedded text and field
  952.         markers in strings using a different attribute from the rest of
  953.         the string. If the field is being edited these characters will be
  954.         displayed using the value of the constant PicCursor. If PicCursor
  955.         has a value greater than 0 it will be used instead of the
  956.         prevailing attribute.
  957.  
  958.  
  959.         Other parameters
  960.  
  961.         The status parameter is used to pass a single byte bit map which
  962.         controls the variables 'mandatory' and 'fixed_length' (bits 1 and
  963.         2 respectively). These control whether or not a blank field is an
  964.         acceptable input and whether that input must, if not zero
  965.         characters long, be a fixed number of characters (value of
  966.         maxstrlen) in length.
  967.  
  968.  
  969.  
  970.                                                    GET utilities  Page 15
  971.  
  972.  
  973.         WordStar editing
  974.  
  975.         The GETSTR editor understands the following commands:
  976.  
  977.  
  978.         Home          beginning of string        ^QS
  979.         End           end of string              ^QD
  980.         Ins           toggle insert/overwrite    ^V
  981.                       left word                  ^A
  982.         right arrow   right 1 character          ^D
  983.         left arrow    left 1 character           ^S
  984.         up arrow      up 1 character             ^E
  985.         down arrow    down 1 character           ^X
  986.         <tab>         insert tab (if allowed)    ^I
  987.         <ret>         enter the string           <ret> / ^M
  988.                       insert literal             ^P followed by any char
  989.                       oops (undo)                ^QL / ^U
  990.                       delete string              ^Y
  991.                       delete to start of string  ^Q<del> / ^QH
  992.                       delete to end of string    ^QY
  993.                       delete next word           ^T
  994.         <esc>         abandon changes to field
  995.         <del>         delete character           ^G
  996.  
  997.  
  998.         Many other commands are passed through to the calling program.
  999.  
  1000.         <Tab> will either enter a "<tab>" or, if the global variable
  1001.         tabsize is set to 0, move to the next field. If tabsize is not 0
  1002.         (default is 8) then the appropriate number of spaces is entered.
  1003.  
  1004.         The up arrow and down arrow commands are acted upon by GETSTR
  1005.         only if appropriate, i.e., if the string is broken into two or
  1006.         more segments -- these would normally be displayed on separate
  1007.         lines.
  1008.  
  1009.         The following are worthy of note
  1010.  
  1011.         ALT-R  Reset -- disable validation (temporarily only)
  1012.         ALT-Y  Delete a block (all subfields with a string)
  1013.         ALT-U  Restore (undo) a block -- e.g subfields in dates and times
  1014.         ALT-X  Exit: abort changes to current field and finish data entry
  1015.         ^J     Enter default -- described below
  1016.  
  1017.  
  1018.         Enter Default
  1019.  
  1020.         The GETSTR procedure does not enter a default value in response
  1021.         to the enter default command, instead it returns to the calling
  1022.         procedure which may then take the appropriate action. This is
  1023.         done for two reasons: 1. to avoid passing an additional parameter
  1024.         (whether string, address or pointer) and 2. because it would not
  1025.         help in situations where strings were linked to make up a larger
  1026.         field -- how does one enter a default date, say 10 characters in
  1027.         a 2 character day field?
  1028.  
  1029.  
  1030.  
  1031.  
  1032.         GET utilities  Page 16
  1033.  
  1034.  
  1035.         Disabling Validation
  1036.  
  1037.         Validation may be disabled, on a field by field basis only,
  1038.         provided the user has the appropriate privilege. The privilege is
  1039.         controlled by the boolean variable ValidationOverride. In the
  1040.         case of the GETSTR procedure, bad data will not be displayed
  1041.         using asterisks (as is done to indicate overflow, e.g., in the
  1042.         procedure GETNUM). However, attempts to move the cursor to
  1043.         another field will be trapped, on the offending character, until
  1044.         validation is turned off, <escape> or ALT-X is pressed, or the
  1045.         data is corrected.
  1046.  
  1047.  
  1048.         Global variables affecting string editing
  1049.  
  1050.         PaintingFields (boolean) controls whether, having displayed the
  1051.         string 'instr', GETSTR should allow the user to edit this string
  1052.         or exit. At the moment this variable is global to all fields,
  1053.         however it could easily be set for particular fields using a bit
  1054.         map -- enabling write protected (display only) fields to be used.
  1055.  
  1056.         Top_n_tail (boolean) controls whether or not strings returned by
  1057.         GETSTR have leading and trailing blanks removed.
  1058.  
  1059.         ForceUppercase (boolean) controls whether all text is to be set
  1060.         to upper case regardless of the value of picture characters.
  1061.  
  1062.         PasswordField (boolean) controls how characters entered are
  1063.         echoed. If true then the character PasswordChar (default value is
  1064.         a space) is output in place of all characters entered and all
  1065.         validation is suspended -- no point in issuing messages like
  1066.         "numeric character expected"!
  1067.  
  1068.  
  1069.         Variables affecting cursor movement
  1070.  
  1071.         Fieldwrap (boolean) controls whether the cursor moves from the
  1072.         last field to the first on field completion/next field command or
  1073.         or vice versa when directed to the previous field. If Fieldwrap
  1074.         is false it is expected that the value of the variable 'field'
  1075.         will, in your program, eventually exceed the number of fields on
  1076.         the screen and that data entry can be terminated without
  1077.         requiring the user to enter an exit command.
  1078.  
  1079.         Cursor movement between fields effected using the horizontal
  1080.         arrow keys may be controlled directly by a lookup table in your
  1081.         application.
  1082.  
  1083.         StringFieldWrap (boolean) controls whether the cursor will
  1084.         respond to the left and right arrow keys when positioned in the
  1085.         first or last character positions in a string. If StringFieldWrap
  1086.         is set, GETSTR will attempt to move the cursor to the next or
  1087.         previous field if asked to do so, moving to the start or end of a
  1088.         string if appropriate -- i.e., from the end of one string to the
  1089.         start of the next and v.v.
  1090.  
  1091.         This variable can be set to enable the use of linked subfields
  1092.         within what appears to be a string but is in reality a series of
  1093.         strings. E.g.
  1094.  
  1095.                                                    GET utilities  Page 17
  1096.  
  1097.  
  1098.  
  1099.         Getting a date using an apparent PIC '99/99/99'
  1100.  
  1101.         oldStringFieldWrap := StringFieldWrap;
  1102.         StringFieldWrap := true;
  1103.  
  1104.         now get 3 date subfields
  1105.  
  1106.         StringFieldWrap := oldStringFieldWrap;
  1107.  
  1108.  
  1109.         Other notes
  1110.  
  1111.         It is possible to include a field prompt in the picture string if
  1112.         you wish to do so. Simply embed it using DefaultAltSwitch as
  1113.         previously described; it may be displayed using the same
  1114.         attribute as the input field however. Alternatively, the
  1115.         following would work:
  1116.  
  1117.         promptstr := 'fieldname: ';
  1118.         picture := brighten(promptstr) + 'x';
  1119.  
  1120.         Getstr(....,picture,...);
  1121.  
  1122.         The brighten procedure adds the switches for you, so you don't
  1123.         need to hard code them into the code.
  1124.  
  1125.         You may care to consider using RedAttr to display characters not
  1126.         matching the picture specified for them* (at the moment there is
  1127.         nothing to draw attention to 'abc' displayed in a field with a
  1128.         picture of '999' until the user attempts to leave the field).
  1129.         Alternatively, one could use a reserved graphics character for
  1130.         each bad character, perhaps with the reset validation command
  1131.         (currently Alt-R) enabling a display of the offending characters.
  1132.  
  1133.         * Some commented out code can be taken as a starting point.
  1134.  
  1135.         The GETFNS unit incorporates routines which could be used to add
  1136.         search or search and replace functions to GETSTR. Other routines
  1137.         could easily be added: change the case of the current character
  1138.         etc.
  1139.  
  1140.  
  1141.  
  1142.  
  1143.  
  1144.  
  1145.  
  1146.  
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.         GET utilities  Page 18
  1158.  
  1159.  
  1160.         GETNUM
  1161.  
  1162.         This procedure should never be called directly. It is intended to
  1163.         be called by one of the following procedures:
  1164.  
  1165.                   GETBYTE
  1166.                   GETSHORTINT
  1167.                   GETWORD
  1168.                   GETINTEGER
  1169.                   GETLONGINT
  1170.  
  1171.         Each of these procedures indicates to GETNUMBER what the maximum
  1172.         value of a returnable number should be. This is accomplished
  1173.         using a longint parameter (maxvalue) having one of a restricted
  1174.         set of values, each of which is used to imply the required type
  1175.         of the returnable number. When you use one of the above
  1176.         procedures the appropriate value of maxvalue is set
  1177.         automatically.
  1178.  
  1179.         The parameter list includes the variables 'low' and 'high' which
  1180.         may be used for controlling range checking. Range checking is
  1181.         dynamic -- i.e., mistakes are caught immediately -- if the range
  1182.         does not exclude the number 0. If dynamic validation is not
  1183.         possible then numbers are validated after the user has finished
  1184.         entering them.
  1185.  
  1186.         If low and high are equal then range checking is turned off. If
  1187.         the value of either low or high is not appropriate for the
  1188.         implied type (e.g., a range of 0 to 999 with a maxvalue of 255)
  1189.         then the range is adjusted to the maximum permissible if the type
  1190.         is correct (in this case the range would become 0 to 255);
  1191.  
  1192.         Field size is determined in the first instance by the required
  1193.         number of digits for the implied type (3 for a byte, 5 for a word
  1194.         etc.). Validation criteria may constrain this further (a byte in
  1195.         range 0..99 will require a field size of only 2 digits), unless
  1196.         the user has ValidationOverride privilege in which case the
  1197.         nominal (full) field size is used. ValidationOverride is a
  1198.         boolean variable used to control whether or not a user may
  1199.         disable validation. Note that it may be turned on or off between
  1200.         fields. Naturally, if the user has this privilege for a field,
  1201.         the field needs to be the maximum size allowable for the type of
  1202.         data expected (3 digits for a byte etc.) regardless of what
  1203.         validation criteria are in effect.
  1204.  
  1205.         If the number passed is too big to be displayed in the field
  1206.         allowed then the field is asterisk filled. The delete_line
  1207.         command (default: ^Y) blanks the field for fresh input. Pressing
  1208.         <ret> sets a blank field to a default value if one has been
  1209.         specified. <esc> and ALT-X exit the field leaving it unchanged,
  1210.         as does moving to another field before terminating entry or
  1211.         editing of the field's contents. The enter_default command
  1212.         (default: ^J) forces entry of the default value. A default value
  1213.         may lie outside the validation range if the user has
  1214.         ValidationOverride privilege.
  1215.  
  1216.  
  1217.  
  1218.  
  1219.                                                    GET utilities  Page 19
  1220.  
  1221.  
  1222.         Global variables
  1223.  
  1224.         RightJustifyNumbers (boolean) controls whether numbers are
  1225.         displayed right justified after entry.
  1226.  
  1227.         RightJustifyNumberEntry (boolean) controls whether numbers are
  1228.         right justified in the input field during data entry. If true
  1229.         they are, otherwise they are entered left justified. Note that
  1230.         RIghtJustifyNumbers controls how numbers are displayed AFTER they
  1231.         have been edited.
  1232.  
  1233.         If ZeroAsBlank is true then fields having a value of zero are
  1234.         displayed as blank.
  1235.  
  1236.         If ZeroFillNumbers is true then fields are displayed so that each
  1237.         field is filled with a right justified number preceded by zeros.
  1238.  
  1239.  
  1240.         Other notes
  1241.  
  1242.         Editing of a number always takes place at the end of the field.
  1243.         Because the cursor is not constrained to remain within the field,
  1244.         even when editing the last character in a full field (as it is in
  1245.         GETSTR), a real cursor is always used rather than a simulated
  1246.         one. If this were not done it would be necessary to save and
  1247.         restore the video attribute byte immediately following each
  1248.         field. Because a real cursor is used then, SetCursor(CursorOn) is
  1249.         executed at the start of the routine and SetCUrsor(CursorOff) at
  1250.         the end of it.
  1251.  
  1252.  
  1253.         GETREAL
  1254.  
  1255.         This procedure is broadly similar to GETNUM, having the same
  1256.         general parameters, but the parameter decimal_places is used
  1257.         instead of maxvalue to determine the maximum range of possible
  1258.         input.
  1259.  
  1260.         The larger field size required for low or high controls how big
  1261.         the field for the entry of 'number' is, unless low = high then
  1262.         the nominal field size of 13 digits is used (11 significant
  1263.         digits, plus sign and decimal point). The value of decimal_places
  1264.         constrains the maximum range of the input as follows:
  1265.  
  1266.  
  1267.           implied_lowest  implied_highest  decimal_places
  1268.  
  1269.           -2147483648     217483647               0
  1270.           -2147483648.0   217483647.0             1
  1271.           -999999999.99   99999999.99             2
  1272.           -99999999.999   9999999.999             3
  1273.  
  1274.           -9.9999999999   9.999999999            10
  1275.  
  1276.  
  1277.         The ranges indicated above will be used for the corresponding
  1278.         number of decimal places if user specified range checking is not
  1279.         in effect (i.e., if low = high) or if the range specified is not
  1280.         appropriate for the number of decimal places specified.
  1281.  
  1282.         GET utilities  Page 20
  1283.  
  1284.  
  1285.  
  1286.         The range may be constrained further by the parameters low and
  1287.         high and the field size will be affected accordingly -- provided
  1288.         ValidationOverride is not true. Field size may be further
  1289.         affected if any user defined formats are used. As many additional
  1290.         characters as are required to cater for the maximum number of
  1291.         commas, e.g., in a number may be added to the field size.
  1292.  
  1293.         As with GETNUM, dynamic validation is not attempted unless the
  1294.         validation range includes the number 0.
  1295.  
  1296.         A decimal point is added automatically during data entry when the
  1297.         maximum number of digits for the integer part of a number has
  1298.         been entered.
  1299.  
  1300.  
  1301.         User Defined Formats
  1302.  
  1303.         It would be possible to add several parameters to the GETREAL
  1304.         procedure to control how real numbers were to be displayed after
  1305.         they had been entered. I thought it would be a better idea to
  1306.         collapse a number of parameters into one: the parameter
  1307.         decimal_places can have a negative value. Ordinarily, this would
  1308.         be nonsensical. However, this provides a means for passing
  1309.         additional information to the GETREAL procedure without expanding
  1310.         the parameter list.
  1311.  
  1312.         If the value of decimal_places is negative GETREAL uses its
  1313.         absolute value to index into an array of user specified display
  1314.         formats (in GETVARS.PAS). GETREAL uses the information obtained
  1315.         from this array to set the values of the several variables
  1316.         controlling number display. The first entry in this array looks
  1317.         like this:
  1318.  
  1319.  
  1320.         (UnitSymbol: '$'; places: 2; UnitFormat: SymbolFirst_Commas)
  1321.  
  1322.  
  1323.         If the value of decimal_places is -1 then 'number' is displayed
  1324.         to two places of decimals with a dollar in front of a comma
  1325.         punctuated amount. No problem? However, remembering to use -1 for
  1326.         one format and minus something else for another would be a little
  1327.         tedious, so I've set up some constants to make it simple; you
  1328.         should modify the list of these and the corresponding formats to
  1329.         suit your own purposes.
  1330.  
  1331.         The predefined values are as follows:
  1332.  
  1333.           Dollars      = -1;
  1334.           Pounds       = -2;
  1335.           FrenchFrancs = -3;
  1336.           SwissFrancs  = -4;
  1337.           Kmpersec     = -5;
  1338.           MHz          = -6;
  1339.  
  1340.  
  1341.         All you have to do is write "Dollars", "SwissFrancs", "Pounds"
  1342.         etc. instead of a number of decimal places in the parameter list
  1343.         for GETREAL.
  1344.  
  1345.                                                    GET utilities  Page 21
  1346.  
  1347.  
  1348.  
  1349.         The variable UnitFormat in the array of format descriptors is
  1350.         itself a composite variable. It is a byte whose bits are set or
  1351.         reset to indicate how the number should be displayed. Some
  1352.         constants are defined to make manipulating these bits easier:
  1353.  
  1354.  
  1355.           Unformatted = $00;
  1356.           SymbolFirst = $01;
  1357.           Commas      = $02;
  1358.           Parentheses = $04; {display negative numbers in parentheses}
  1359.           Financial   = $06; {shorthand for commas + parentheses}
  1360.           SIdisplay   = $08; {Système International format}
  1361.  
  1362.           SymbolFirst_Commas      = $03;
  1363.           SymbolFirst_Parentheses = $05;
  1364.           SymbolFirst_Financial   = $07;
  1365.  
  1366.  
  1367.         To add your own format all you need do is:
  1368.  
  1369.         1. Decide how you wish the number to be displayed
  1370.         2. Increment the constant TotalUserFormats (also in GETVARS.PAS)
  1371.         3. Add a record to the array of formats (UserFormatArray)
  1372.  
  1373.  
  1374.         You may add a constant to the list shown above (after MHz) so
  1375.         that you don't need to remember where in the table the
  1376.         appropriate format is defined. A further advantage of doing this
  1377.         lies in the fact that the table may be reordered without the need
  1378.         to make changes to every invocation of the procedure; the values
  1379.         of the appropriate constants (dollars, pounds etc.) may be
  1380.         changed instead.
  1381.  
  1382.         Find the appropriate value of UnitFormat by inspection of the
  1383.         table above.
  1384.  
  1385.  
  1386.         Système International
  1387.  
  1388.         Real numbers displayed in compliance with the conventions of the
  1389.         SI standard are shown with a comma delimiting the mantissa and
  1390.         the characteristic part of the number, with thousands delimited
  1391.         by either a space or a period. GETREAL supports the SI standard
  1392.         by means of its facilities for handling user-defined formats.
  1393.  
  1394.         If SIdisplay in the appropriate UnitFormat record is true then
  1395.         the real is displayed according to the conventions of the SI
  1396.         standard. A global character variable, SIThousandsDelimiter, with
  1397.         a default value of a period, is used to punctuate the integer
  1398.         part of the real. This variable can be set to a space if desired.
  1399.  
  1400.         Numbers entered with SIdisplay set true or false in their
  1401.         UnitFormat records will be displayed with a "decimal comma" or
  1402.         decimal point respectively during data entry, although either
  1403.         character may be entered as the decimal delimiter. Range values
  1404.         will be correspondingly affected in the text of any error
  1405.         messages issued during data entry (decimal comma if SIdisplay).
  1406.  
  1407.  
  1408.         GET utilities  Page 22
  1409.  
  1410.  
  1411.         GETDATESTRING
  1412.  
  1413.         This routine gets a date string from the screen using successive
  1414.         calls to the GETSTR procedure to accumulate an aggregate string.
  1415.         The description of that procedure's operation applies to the each
  1416.         of the day, month and year subfields comprising a date.
  1417.  
  1418.         The primary purpose of this procedure is to provide flexible date
  1419.         format control and to provide validated dates in a string format.
  1420.         The user may then convert dates using a preferred Julian
  1421.         conversion routine if desired. I believe that quite a few people
  1422.         will be happy to store dates as ASCII strings, particularly in
  1423.         cases where all other data are being stored as ASCII. In such
  1424.         cases the dates need only be temporarily converted to Julian
  1425.         format for arithmetic purposes.
  1426.  
  1427.         Date format control is accomplished by means of simple global
  1428.         variable assignments such as:
  1429.  
  1430.  
  1431.         DateFormat := European;
  1432.         YearFormat := YY;
  1433.  
  1434.  
  1435.         GETDATESTRING returns an 8 or a 10 character string with 2
  1436.         subfield separators. The global variables DateFormat and
  1437.         YearFormat control the interpretation of the subfields in any
  1438.         string passed to this procedure (i.e., their order and implied
  1439.         nature -- month, day or year) and the number of characters in a
  1440.         year field. Thus, for a DateFormat of American, dates are
  1441.         expected in mm/dd/[yy]yy order.
  1442.  
  1443.         The date field separators, i.e. the characters between month, day
  1444.         and year subfields, are either those in the appropriate positions
  1445.         in the string being edited or the globally specified default (for
  1446.         blank dates).
  1447.  
  1448.         Unlike the field markers which appear in picture strings, date
  1449.         subfield separator are part of the string -- although they are
  1450.         skipped over during data entry or editing. In practice the
  1451.         content of these bytes is irrelevant, their position is more
  1452.         significant. Any separator character may be used, each will be
  1453.         displayed during date entry using the separator_attr attribute
  1454.         passed to the procedure.
  1455.  
  1456.         Valid date formats are:
  1457.  
  1458.  
  1459.         DateFormat  date string format
  1460.  
  1461.         American    mm/dd/[yy]yy
  1462.         European    dd/mm/[yy]yy
  1463.         Japanese    [yy]yy/mm/dd
  1464.  
  1465.  
  1466.  
  1467.  
  1468.  
  1469.  
  1470.                                                    GET utilities  Page 23
  1471.  
  1472.  
  1473.         Valid year formats are:
  1474.  
  1475.  
  1476.         YearFormat   year string subfield                overall length
  1477.  
  1478.         YYYY         4 digits: 0000-9999 to be returned         10
  1479.         YY           2 digits: 00-99                             8
  1480.         NY           as above                                    8
  1481.  
  1482.  
  1483.         The difference between NY and YY is that dates with a YearFormat
  1484.         of NY are displayed with a "19" prefacing a two character year
  1485.         subfield. This "19" is NOT returned as part of the date string.
  1486.         In determining what years are leap years ALL dates with effective
  1487.         field sizes of two characters for data entry are assumed to be
  1488.         20th century dates, and 1900 is added to each.
  1489.  
  1490.         Dates entered are validated to ensure that the number of days in
  1491.         the month and number of months in the year are legal values.
  1492.         Because GETDATESTRING allows dates to be entered in a variable
  1493.         manner it also validates dates in the subfield order in which
  1494.         they are displayed.
  1495.  
  1496.         No validation is performed on the year subfield of any date other
  1497.         than to ensure that it is filled with numeric characters, though
  1498.         of course whether or not the year is a leap year will affect the
  1499.         validation of the day subfield.
  1500.  
  1501.         The following definition of a leap year is used: any year
  1502.         divisible by four except centuries divisible by four hundred and
  1503.         millennia by four thousand are leap years.
  1504.  
  1505.         Because the date string used by this procedure needs to be
  1506.         capable of being either 8 or 10 characters long the appropriate
  1507.         var parameter is a string (0 to 255 characters long). This means
  1508.         that any old rubbish can be passed to it without difficulty, it
  1509.         is your responsibility to see that this doesn't happen.
  1510.         GETDATESTRING doesn't do much to recover the situation if the
  1511.         string passed is simply not a date in the format expected.
  1512.  
  1513.         To blank a date field enter the del_block command (default Alt-Y)
  1514.         and to restore a date field enter the restore_block command
  1515.         (default Alt-U).
  1516.  
  1517.         The enter_default command (^J) enters the current system date.
  1518.         This command may be entered on the first subfield of a blank date
  1519.         field or on any completed date subfield. Pressing <return> on a
  1520.         blank date field will enter the system time if SystemDefault is
  1521.         set true (2nd bit in 'status' parameter). Blank dates will be
  1522.         displayed as blanks or zeros if the global boolean
  1523.         DateZeroAsBlank is true or false respectively.
  1524.  
  1525.         Short version: GETDATESTR
  1526.  
  1527.  
  1528.  
  1529.  
  1530.  
  1531.  
  1532.         GET utilities  Page 24
  1533.  
  1534.  
  1535.         GETTIMESTRING
  1536.  
  1537.         This routine gets a string time from the screen using successive
  1538.         calls to the GETSTR procedure. It is similar to but considerably
  1539.         simpler than GETDATESTRING because all times are returned in a
  1540.         fixed 24 hour format with, invariably, a colon between the hour
  1541.         and minute subfields.
  1542.  
  1543.         The enter_default command (^J) enters the current system time.
  1544.         Pressing <return> on a blank time field will enter the system
  1545.         time if SystemDefault is set true (2nd bit in 'status'
  1546.         parameter). Blank times will be displayed as blanks or zeros if
  1547.         the global boolean TimeZeroAsBlank is true or false respectively.
  1548.  
  1549.         Short version: GETTIMESTR
  1550.  
  1551.         Possible changes:
  1552.  
  1553.         Add minimum and maximum parameters (like GETNUM), ALT-R to
  1554.         disable this validation.
  1555.  
  1556.         Allow use of 12 hour times with A.M. / P.M. indicator (like DOS).
  1557.  
  1558.         If minimum and maximum time parameters are added and a given call
  1559.         to this procedure excluded 00:00 as a valid time, bit 1 of status
  1560.         could be used to control whether entry of a time was mandatory.
  1561.         Alternatively, if an AM/PM indicator were added this could take a
  1562.         null/blank value to indicate that a blank time was not 00:00
  1563.         (midnight) but a blank field.
  1564.  
  1565.  
  1566.         GETATTR
  1567.  
  1568.         This procedure displays a palette of attributes similar to that
  1569.         used by Turbo Pascal's TINST program and allows the user to
  1570.         select one. The boolean parameter display_value controls whether
  1571.         or not the decimal value of the attribute is displayed at the
  1572.         bottom of the window.
  1573.  
  1574.         <Ret> selects foreground & background colours (attribute)
  1575.         <Esc> aborts leaving the attribute variable passed unchanged
  1576.  
  1577.         NOTE:
  1578.  
  1579.         The procedure InitWindow in Jim LeMay's WNDW unit should be run
  1580.         BEFORE this procedure is executed, preferably at the start of the
  1581.         program within which this procedure is used.
  1582.  
  1583.         GETATTR is not part of the GET unit.
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.  
  1592.  
  1593.  
  1594.                                                    GET utilities  Page 25
  1595.  
  1596.  
  1597.         DATES IN GENERAL
  1598.  
  1599.              There's an old joke about the computer industry liking
  1600.              standards so much that it's got hundreds of them. How
  1601.              old? Let's see, which date routine are you using?
  1602.  
  1603.  
  1604.         There are a plethora of "date procedures" available. Scott
  1605.         Bussinger, Ted Lassagne, Carley Phillips, David Dubois and others
  1606.         have contributed useful routines. All of them have their
  1607.         advantages and all suffer from one or more disadvantages.
  1608.  
  1609.         In general, the readily available date routines offer one or more
  1610.         flavours of Julian/Gregorian date conversion.
  1611.  
  1612.  
  1613.         Background
  1614.  
  1615.         Some of the shortcomings of the so-called Julian date routines
  1616.         currently available are discussed below.
  1617.  
  1618.         Most commonly these routines allow a word (2 bytes) for the
  1619.         Julian day number, enough for 64k serial numbered days -- or a
  1620.         range of 179 years (65,535 / 365) . DOS stores dates in this
  1621.         fashion and has such a range, as does Lotus 1-2-3 and many other
  1622.         programs. There are a few problems with this approach.
  1623.  
  1624.         BY DEFINITION a Julian date is a number of days from an agreed
  1625.         base date: 1/1/4713 B.C. This date was fixed by the astronomer
  1626.         Joseph Scaliger, after whose father Julius the Julian date scheme
  1627.         is named, to facilitate conversion between the Gregorian and
  1628.         earlier calendars.
  1629.  
  1630.         Microsoft's DOS dates are numbered from midnight on the last day
  1631.         of 1979. They are not true Julian dates because this additional
  1632.         information is required to decode them properly. Similarly, dates
  1633.         with other bases -- such as Smithsonian dates -- are not true
  1634.         Julian dates. (Smithsonian day 0 was 17 November, 1858. This is
  1635.         the base date used in date calculations on many computers, DEC's
  1636.         VAX machines e.g. The conversion factor, according to Ted
  1637.         Lassagne, is Smithsonian = Julian - 2400001).
  1638.  
  1639.         Note that it is not necessary for the user of date conversion
  1640.         routines to know the base date to use them. David Dubois'
  1641.         FASTDATE routine is based on a day 0 = "a magic number". So far
  1642.         as I can tell, this derives from his birthday. Unfortunately, his
  1643.         assembler code isn't as accurate as one might hope for under the
  1644.         circumstances.
  1645.  
  1646.         However, if one decides to expand the day range to encompass the
  1647.         agreed starting point for true Julian dates one runs into other
  1648.         problems. The generally employed Julian to Gregorian inter-
  1649.         conversion procedures derive from the published work of Tantzen
  1650.         (Algorithm No. 398, Communications of the ACM, August 1963,
  1651.         Vol. 6 No. 8). These calculations are valid for dates between
  1652.  
  1653.                      15 October 1572 and 28 February 4000 AD
  1654.  
  1655.         The former is the date the starting date of the Gregorian system,
  1656.  
  1657.         GET utilities  Page 26
  1658.  
  1659.  
  1660.         established by Papal Bull in March 1572. The Bull suppressed the
  1661.         5th to the 14th of October 1572, inclusive, in order to restore
  1662.         the vernal equinox to March 21st.
  1663.  
  1664.         Tantzen's routines are not valid after the latter date because
  1665.         they do not take into account the fact that years divisible by
  1666.         4,000 are not leap years.
  1667.  
  1668.         The applicability of the calculations to dates prior 15 October,
  1669.         1572 is at least debatable (Pope Gregory was not the first to
  1670.         eliminate days). Mathematically, the procedures are purportedly
  1671.         valid from the 1st of March, year 0. However, there was no year
  1672.         0! The Christian calendar went from 1 BC to 1 AD. It's better not
  1673.         to worry if Jesus Christ was on earth for a week or so BC,
  1674.         because we almost certainly don't know the true date of his
  1675.         birth. If the 1st of March following the birth of Christ is taken
  1676.         to be day number 0 we are not dealing with a Julian date. Some
  1677.         date routines treat the first day as day 1 (W. Madison's e.g.).
  1678.  
  1679.         No problem, we can add a constant number of days to it -- the
  1680.         number of days in January and February of the first year would be
  1681.         one option. To do this we need to know if the year was a leap
  1682.         year. That depends on whether you call it year 0 or year 1.
  1683.         However, we really ought to add the number of days between the
  1684.         1st of January 4713 BC and the 1st of March following Christ's
  1685.         birth. In calculating this total we need to bear in mind that
  1686.         years divisible by 4000 are not leap years and that there was no
  1687.         year zero (Are you with me? Sigh. I don't think I am!).
  1688.  
  1689.         I have yet to see any code which addresses this properly (Carley
  1690.         Phillips' routines are closest). To an extent the issue is
  1691.         academic, though it would be nice to have a(nother) standard for
  1692.         computing purposes. Days were dropped periodically prior to, and
  1693.         upon the introduction of, the Gregorian calendar to bring the
  1694.         calendar into line with the earth's astronomical calendar. Should
  1695.         date conversion routines know about the effects of these changes?
  1696.         I would argue against it, given that the Gregorian calendar was
  1697.         not adopted simultaneously all over the western world and we
  1698.         already have the confusion of different countries adopting it on
  1699.         different dates (Britain in 1752, Russia in 1918 and Turkey as
  1700.         recently as 1928 e.g.).
  1701.  
  1702.         Anyway...
  1703.  
  1704.         The whole business of date arithmetic requires either relatively
  1705.         adjacent dates or an agreed standard means of calculation (the
  1706.         actual base date is not particularly important). In the absence
  1707.         of a universally agreed procedure the GET procedures will have
  1708.         nothing to do with date arithmetic, for now anyway. You may
  1709.         select your own procedures (e.g. Ted Lassagne's EXDATE.PAS). For
  1710.         what it's worth, my preference is for the most recent popular
  1711.         base date (Smithsonian) because using it eliminates most of the
  1712.         problems, however it may not suit everybody.
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.                                                    GET utilities  Page 27
  1720.  
  1721.  
  1722.                                     Addendum
  1723.  
  1724.         It's a small world so please, if you disseminate documents for
  1725.         printing, bear the following recommendations in mind.
  1726.  
  1727.         Use 66 line pages (not 70 line A4, unprintable in N.America).
  1728.         Use formfeeds not linefeeds at the end of a page -- A MUST!
  1729.         Set the right margin so that the total width does not exceed 77
  1730.         characters -- the maximum the HP LaserJet II will print in
  1731.         Courier 10.
  1732.  
  1733.  
  1734.         RELEASE NOTES
  1735.  
  1736.         Since the beta distribution (October 1st) the following changes
  1737.         have been made:
  1738.  
  1739.         1. Minor bug in display of time and date fixed (wrong attribute
  1740.            for separator character).
  1741.         2. GETSTR display speed improved slightly.
  1742.         3. Support for SI format reals added to GETREAL.
  1743.  
  1744.  
  1745.         During the month:
  1746.  
  1747.         UPS began delivering all over the UK; there's a depot in Aberdeen
  1748.         not far from where I live (hey hey!). Borland laid off staff,
  1749.         started looking for dealers to handle technical support, and
  1750.         still didn't deliver Turbo Pascal v5.0 -- now expected in the UK
  1751.         in December (1988). Blaises! What Kahn a poor boy do? Will it be
  1752.         Wirth waiting for? We shall C, perhaps.
  1753.  
  1754.  
  1755.  
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761.  
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781.         GET utilities  Page 28
  1782.