home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / GET10.ZIP / GET.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1988-11-09  |  20.5 KB  |  811 lines

  1. {$B-,D-,F-,I-,L+,N-,R-,S-,T-,V+} {TP4 directives}
  2. {
  3.   This set of data entry routines provides dynamic validation capabilities.
  4.   Note that dynamic validation of numbers is not attempted unless the range
  5.   indicated for checking includes the number 0; these numbers are validated
  6.   after they have been entered.
  7.  
  8.   Paul O'Nolan, CIS 72007,242 November 1988
  9.  
  10. }
  11. Unit get;
  12.  
  13. Interface
  14.  
  15. Uses Crt, Qwik, Dos, GetFns, Getvars;
  16.  
  17. { Note Crt is only used for: sound, nosound, delay }
  18.  
  19.  
  20. function EditingField: boolean;
  21. function brighten (instr: string): string;
  22.  
  23. procedure altwrite
  24.  
  25.    (row,col,                   {coordinates}
  26.     attr1,attr2: byte;         {attributes}
  27.     sentinel:    char;         {sentinel character}
  28.     altstr:      screen_text); {message}
  29.  
  30. procedure bell; {may or may not be sounded, depending on SoundOn}
  31. procedure beep; {user cannot disable}
  32. procedure info (infomsg: screen_text);
  33. procedure info2 (infomsg: screen_text);
  34. procedure error (errormsg: screen_text);
  35. procedure error2 (errormsg: screen_text);
  36. procedure clearerror;
  37. procedure clearerror2;
  38. procedure getboolean
  39.  
  40.    (char_prompt:   screen_text;
  41.     atr,atc,                 {co-ordinates}
  42.     cursor_attr,
  43.     pattr,dattr:   byte;     {attributes}
  44. var response:      boolean);
  45.  
  46. procedure getbool
  47.  
  48.    (char_prompt:   screen_text;
  49.     atr,atc:       byte;     {co-ordinates}
  50. var response:      boolean);
  51.  
  52. procedure getchar
  53.  
  54.    (char_prompt:   screen_text;
  55.     atr,atc,                 {co-ordinates}
  56.     cursor_attr,
  57.     pattr,chattr:  byte;     {attributes}
  58. var response:      char;
  59.     valid_keys:    ok_keys;
  60.     nullok:        boolean;
  61.     default_ch:    char);    {default response}
  62.  
  63. procedure getresponse
  64.  
  65.    (char_prompt: screen_text;
  66.     valid_keys:  ok_keys;
  67.     atr,atc:     byte;    {screen co-ords}
  68.     makesure:    boolean; {confirm with Y/N?}
  69. var response:    char;
  70.     default_ch:  char);   {default response}
  71.  
  72. procedure getdigit
  73.  
  74.    (atr,atc:  byte;
  75.     nattr:    integer);
  76.  
  77. procedure getnumber
  78.  
  79.    (num_prompt:   screen_text;
  80.     atr,atc:      byte;        {screen co-ords}
  81.     low,high:     longint;     {not checked if equal}
  82.     pattr,nattr:  byte;        {attributes}
  83. var number:       longint;
  84.     maxvalue:     longint;     {implied type}
  85.     default:      numstring);
  86.  
  87. procedure getreal
  88.  
  89.    (num_prompt:       screen_text;
  90.     atr,atc:          byte;        {screen co-ords}
  91.     low,high:         real;        {not checked if equal}
  92.     decimal_places:   integer;     {or UserFormat number if negative}
  93.     pattr,nattr:      byte;        {attributes}
  94. var number:           real;
  95.     default:          numstring);
  96.  
  97.  
  98. procedure getlongint
  99.  
  100.    (num_prompt:       screen_text;
  101.     atr,atc:          byte;       {screen co-ords}
  102.     low,high:         integer;
  103.     pattr,nattr:      byte;
  104. var number:           longint;
  105.     default:          numstring);
  106.  
  107. procedure getinteger
  108.  
  109.    (num_prompt:       screen_text;
  110.     atr,atc:          byte;       {screen co-ords}
  111.     low,high:         integer;
  112.     pattr,nattr:      byte;
  113. var number:           integer;
  114.     default:          numstring);
  115.  
  116. procedure getshortint
  117.  
  118.    (num_prompt:       screen_text;
  119.     atr,atc:          byte;       {screen co-ords}
  120.     low,high:         integer;
  121.     pattr,nattr:      byte;
  122. var number:           shortint;
  123.     default:          numstring);
  124.  
  125. procedure getword
  126.  
  127.    (num_prompt:       screen_text;
  128.     atr,atc:          byte;        {screen co-ords}
  129.     low,high:         integer;
  130.     pattr,nattr:      byte;
  131. var number:           word;
  132.     default:          numstring);
  133.  
  134. procedure getbyte
  135.  
  136.    (num_prompt:       screen_text;
  137.     atr,atc:          byte;        {screen co-ords}
  138.     low,high:         integer;
  139.     pattr,nattr:      byte;
  140. var number:           byte;
  141.     default:          numstring);
  142.  
  143. procedure getstring
  144.  
  145.    (str_prompt:       string;
  146.     pattr,                      {prompt attribute}
  147.     atr,atc,                    {row,col}
  148.     attr,cursor_attr: byte;     {string & cursor attributes}
  149. var instr:            string;   {string to edit}
  150.     picture:          string;   {input picture/mask}
  151.     maxstrlen:        plusbyte; {maximum length of string}
  152.     status:           byte);
  153.  
  154. procedure getstr                {getstring with default attributes}
  155.  
  156.    (str_prompt:       string;
  157.     atr,atc:          byte;     {row,col}
  158. var instr:            string;   {string to edit}
  159.     picture:          string;   {input picture/mask}
  160.     maxstrlen:        plusbyte; {maximum length of string, 1..255}
  161.     status:           byte);
  162.  
  163. procedure getdatestring
  164.  
  165.    (date_prompt:      screen_text;
  166.     pattr:            byte;        {prompt attribute}
  167.     atr,atc,                       {screen co-ords}
  168.     dattr,                         {attribute}
  169.     cursor_attr,                   {cursor attribute}
  170.     separator_attr:   byte;        {date subfield separator attribute}
  171. var datestr:          string;
  172.     status:           byte);
  173.  
  174. procedure getdatestr
  175.  
  176.    (date_prompt:      screen_text;
  177.     atr,atc:          byte;        {screen co-ords}
  178. var datestr:          string;
  179.     status:           byte);
  180.  
  181. procedure gettimestring
  182.  
  183.    (time_prompt:      screen_text;
  184.     pattr,                         {prompt attribute}
  185.     atr,atc,                       {screen co-ords}
  186.     tattr,                         {time attribute}
  187.     cursor_attr,                   {date and cursor attributes}
  188.     separator_attr:   byte;        {time subfield separator attribute}
  189. var timestr:          string;
  190.     status:           byte);       {bit 2: use system time (hh:mm) as default}
  191.  
  192. procedure gettimestr
  193.  
  194.    (time_prompt:      screen_text;
  195.     atr,atc:          byte;        {screen co-ords}
  196. var timestr:          string;
  197.     status:           byte);       {bit 2: use system time (hh:mm) as default}
  198.  
  199.  
  200. Implementation
  201.  
  202. function EditingField: boolean;
  203. begin
  204.   EditingField := not PaintingFields;
  205. end;
  206.  
  207.  
  208. function brighten (instr: string): string;
  209. {
  210.   Attaches DefaultAltSwitch before and after a string. Used to trigger
  211.   hightlighting in messages, e.g. error(text + brighten(text) + text);
  212. }
  213. begin
  214.   if length(instr) < 254 then
  215.     instr := DefaultAltSwitch + instr + DefaultAltSwitch;
  216.   brighten := instr;
  217. end;
  218.  
  219.  
  220. procedure altwrite
  221.  
  222.    (row,col,                   {coordinates}
  223.     attr1,attr2: byte;         {attributes}
  224.     sentinel:    char;         {sentinel character}
  225.     altstr:      screen_text); {message}
  226.  
  227. {
  228.   Displays text in two attributes alternated by means of a switch passed as a
  229.   parameter and embedded within text. Then pads rest of the line with spaces
  230.   using the attribute in effect at the end of the string. Typical altstr:
  231.  
  232.   Delete ^ALL^ files? ^Y^/^N^?
  233. }
  234. var I,J,attr:   byte;
  235. begin
  236.   if length(altstr) > 0 then
  237.     begin
  238.       attr := attr1; J := 0;
  239.       for I := 1 to length(altstr) do
  240.         if altstr[I] = sentinel then
  241.           if attr = attr2 then
  242.             attr := attr1
  243.           else attr := attr2
  244.         else
  245.           begin
  246.             Qwrite(row,col + J,attr,altstr[I]); inc(J);
  247.           end;
  248. {
  249.   Now fill to end of screen line with spaces using attr
  250. }
  251.       Qfill(row,col + J,1,CRTcols - pred(col) - J,attr,' ');
  252.     end;
  253. end;
  254.  
  255.  
  256. procedure bell; {may or may not be sounded, depending on SoundOn}
  257. begin
  258.   if SoundOn then
  259.     begin
  260.       sound(belltone);
  261.       delay(75);
  262.       nosound;
  263.     end;
  264. end;
  265.  
  266.  
  267. procedure beep; {user cannot disable}
  268. begin
  269.   sound(belltone);
  270.   delay(75);
  271.   nosound;
  272. end;
  273.  
  274.  
  275. procedure info (infomsg: screen_text);
  276. begin
  277.   altwrite(pred(CRTrows),1,AttrNM,AttrBO,DefaultAltSwitch,infomsg);
  278. end;
  279.  
  280.  
  281. procedure info2 (infomsg: screen_text);
  282. begin
  283.   altwrite(CRTrows,1,AttrNM,AttrBO,DefaultAltSwitch,infomsg);
  284. end;
  285.  
  286.  
  287. procedure error (errormsg: screen_text);
  288. {
  289.   No message is output unless the error line is clear. This prevents
  290.   output of multiple error messages. Error line must be cleared with
  291.   Clearerror.
  292. }
  293. begin
  294.  if ErrorLineClear then
  295.    begin
  296.      info(errormsg);
  297.      beep;
  298.      ErrorLineClear := false;
  299.    end;
  300. end;
  301.  
  302.  
  303. procedure error2 (errormsg: screen_text);
  304. {
  305.   No output unless error2 line is clear
  306. }
  307. begin
  308.   if Error2LineClear then
  309.     begin
  310.       info2(errormsg);
  311.       beep;
  312.       Error2LineClear := false;
  313.     end;
  314. end;
  315.  
  316.  
  317. procedure clearerror;
  318. begin
  319.   qfill(pred(CRTrows),1,1,CRTcols,AttrNM,' ');
  320.   ErrorLineClear := true;
  321. end;
  322.  
  323. procedure clearerror2;
  324. begin
  325.   qfill(CRTrows,1,1,CRTcols,AttrNM,' ');
  326.   Error2LineClear := true;
  327. end;
  328.  
  329.  
  330. procedure display_prompt
  331.  
  332.    (char_prompt:   screen_text;
  333.     atr:           byte;
  334. var atc:           byte;     {co-ordinates}
  335.     pattr,                   {attribute}
  336.     field_size:    byte);
  337.  
  338. {
  339.   This procedure displays a prompt for a field of a given size, performing
  340.   any necessary adjustments to the positioning and size of the prompt to
  341.   make it fit on the screen. The prompt is not redisplayed when input is
  342.   sought for a field unless RedisplayPrompts is true.
  343. }
  344.  
  345. begin
  346.   if length(char_prompt) > CRTcols - field_size then {truncate prompt}
  347.     char_prompt := copy(char_prompt,1,CRTcols - field_size);
  348. {
  349.   prompt + field will now fit on a line, move backwards until a home is found
  350. }
  351.   while
  352.     (length(char_prompt) + field_size > CRTcols - pred(atc)) and (atc > 1)
  353.   do
  354.     dec(atc);
  355. {
  356.   Output prompt string at atr,atc.
  357. }
  358.  
  359.   if PaintingFields or RedisplayPrompts then
  360.     Qwrite(atr,atc,pattr,char_prompt);
  361.   atc := atc + length(char_prompt);
  362. end;
  363.  
  364.  
  365. procedure getchar
  366.  
  367.    (char_prompt:   screen_text;
  368.     atr,atc,                 {co-ordinates}
  369.     cursor_attr,
  370.     pattr,chattr:  byte;     {attributes}
  371. var response:      char;
  372.     valid_keys:    ok_keys;
  373.     nullok:        boolean;
  374.     default_ch:    char);    {default response}
  375.  
  376. const
  377.  
  378.     field_size:    byte = 1; {used for readability and consistency}
  379.  
  380. var CheckSet:             CharacterSetType;
  381.     old_response:         char;
  382.     BooleanInputExpected,
  383.     finished:             boolean;
  384.     TypeExpectedWord:     string;
  385.  
  386. procedure show_character;
  387. var fattr: byte; {field attribute}
  388. begin
  389.   if EditingField and not finished then
  390.     if FieldCursor <> 0 then
  391.        fattr := FieldCursor
  392.     else fattr := cursor_attr
  393.   else fattr := chattr;
  394.  
  395.   if BooleanInputExpected then {translate response}
  396.     begin
  397.       if pos(response,TrueChars + BooleanTrueChar) > 0 then
  398.         response := BooleanTrueChar
  399.       else response := BooleanFalseChar;
  400.     end;
  401.  
  402.   Qwrite(atr,atc,fattr,response);
  403. end;
  404.  
  405. procedure validate_response;
  406. begin
  407.   if response in valid_keys then
  408.     finished := true
  409.   else
  410.     begin
  411.       if TypeExpectedWord <> '' then
  412.         error2(TypeExpectedWord + InputWord + RequiredWord);
  413.  
  414.       if error2lineclear then
  415.         bell; {some other character set}
  416.     end;
  417. end;
  418.  
  419. begin
  420.   escaped := false;
  421.   finished := false;
  422.   old_response := response;
  423.   TypeExpectedWord := '';
  424.  
  425.   display_prompt(char_prompt,atr,atc,pattr,field_size);
  426.  
  427. {
  428.   Determine if input type expected is one of the predefined types.
  429. }
  430.  
  431.   for CheckSet := Alphabetic to TrueOrFalse do
  432.     with CharacterSet[CheckSet] do
  433.       if valid_keys = CharSet then
  434.         TypeExpectedWord := CharacterSetName; {set up for error message}
  435.  
  436.   BooleanInputExpected := valid_keys = CharacterSet[TrueOrFalse].CharSet;
  437.  
  438.   SetCursor(CursorOn or CursorUnderline);
  439.   gotorc(atr,atc); {position cursor for input}
  440.  
  441.   if EditingField then
  442.   repeat
  443.  
  444.     show_character;
  445.     command := extendkey;
  446.     action := get_edit(command);
  447.     response := chr(asciicode);
  448.     clearerror2;
  449.  
  450.     case action of
  451.  
  452.       help,
  453.       abort:           begin
  454.                          response := old_response;
  455.                          finished := true;
  456.                        end;
  457.  
  458.       tabover,
  459.       tabback,
  460.       upchar,
  461.       downchar,
  462.       leftchar,
  463.       rightchar,
  464.       pageup,
  465.       pagedown,
  466.       scrollup,
  467.       scrolldown,
  468.       goto_top,
  469.       goto_bottom,
  470.       exit_screen,
  471.       quit:            begin
  472.                          response := old_response;
  473.                          validate_response; {sets finished true if ok}
  474.                        end;
  475.  
  476.       enter_default,
  477.       carriage_return: if default_ch in valid_keys then
  478.                          response := default_ch
  479.                        else if nullok and (chr(0) in valid_keys) then
  480.                               response := chr(0)
  481.                             else validate_response; {^J,^M?}
  482.  
  483.       escapefrom:     begin
  484.                          response := old_response;
  485.                          escaped := true;
  486.                        end;
  487.     else
  488.       validate_response;
  489.     end; {case}
  490.  
  491.   until (response in valid_keys) or escaped or finished;
  492.  
  493.   finished := true;
  494.   show_character;
  495.   clearerror2;
  496.   SetCursor(CursorOff);
  497. end;
  498.  
  499.  
  500. procedure getresponse
  501.  
  502.    (char_prompt: screen_text;
  503.     valid_keys:  ok_keys;
  504.     atr,atc:     byte;    {screen co-ords}
  505.     makesure:    boolean; {confirm with Y/N?}
  506. var response:    char;
  507.     default_ch:  char);   {default response}
  508.  
  509. {
  510.   This procedure returns a single character in the variable 'response'.
  511.   If the value of response is y or Y and 'makesure' is true then the
  512.   response to 'Sure Y/N' is elicited via a recursive call. This is handy
  513.   for getting answers to questions such as 'Delete all files.' Confirmation
  514.   of responses other than y/Y is not possible with this procedure.
  515.  
  516.   Input is solicited immediately after the prompt, so the prompt should end
  517.   with a space to separate the two fields.
  518.  
  519.   No recourse to help or function keys is allowed. The user is expected
  520.   to enter a character from a selection displayed, end of story.
  521.  
  522.   The prompt string is displayed with the procedure AltWrite and so may
  523.   contain DefaultAltSwitch to trigger highlighting. Note that the
  524.   attributes for this string are the defaults for AttrNM and AttrBO.
  525.  
  526.   It is assumed that the prompt output will normally be at the start of a 
  527.   line. 
  528. }
  529.  
  530. var CheckSet:         CharacterSetType;
  531.     output_char,
  532.     old_response:     char;
  533.     TypeExpectedWord: string;
  534.     action:           edit;
  535.     prompt_length:    byte;
  536.  
  537. begin
  538.   escaped := false;
  539.   old_response := response;
  540.   TypeExpectedWord := '';
  541.  
  542.   prompt_length := length_without_tears(char_prompt,DefaultAltSwitch);
  543.  
  544.   if prompt_length >= CRTcols then
  545.     begin
  546.       prompt_length := pred(CRTcols);
  547.       char_prompt[0] := chr(prompt_length);
  548.     end;
  549.  
  550.   if prompt_length > 0 then
  551.     begin
  552.       if atc + prompt_length >= CRTcols then
  553.         atc := 1;
  554.       altwrite(atr,atc,AttrNM,AttrBO,DefaultAltSwitch,char_prompt);
  555.       atc := atc + prompt_length;
  556.     end;
  557.  
  558. {
  559.   Determine if input type expected is one of the predefined types.
  560. }
  561.  
  562.   for CheckSet := Alphabetic to TrueOrFalse do
  563.     with CharacterSet[CheckSet] do
  564.       if valid_keys = CharSet then
  565.         TypeExpectedWord := CharacterSetName; {set up for error message}
  566.  
  567.   SetCursor(CursorOn or CursorUnderline);
  568.   gotorc(atr,atc);
  569.   response := default_ch;
  570.  
  571.   repeat
  572.     if not (response in valid_keys) then
  573.       output_char := default_ch {was ' '}
  574.     else output_char := response;
  575.     Qwrite(atr,atc,AttrBO,output_char); {highlight/blank input}
  576.  
  577.     command := extendkey;
  578.     action := get_edit(command);
  579.     response := chr(asciicode);
  580.     clearerror2;
  581.  
  582.     case action of
  583.       carriage_return: if default_ch in valid_keys then
  584.                          response := default_ch;
  585.       escapefrom: begin
  586.                     response := old_response;
  587.                     escaped := true;
  588.                   end;
  589.        else
  590.          if not (response in valid_keys) then
  591.            begin
  592.              error2(TypeExpectedWord + InputWord + RequiredWord);
  593.  
  594.              if error2lineclear then
  595.                bell; {some other character set}
  596.            end;
  597.  
  598.     end; {case}
  599.  
  600.     if response in valid_keys then
  601.       begin
  602.         Qwrite(atr,atc,AttrBO,response); {echo it}
  603.  
  604.         if (upcase(response) = YesLetter) and makesure then
  605.           getresponse(SureYN,CharacterSet[YesAndNo].CharSet,
  606.                       atr,atc + 2,false,response,' ');
  607.       end;
  608.  
  609.   until (response in valid_keys) or escaped;
  610.  
  611.   clearerror2;
  612.   SetCursor(CursorOff);
  613. end;
  614.  
  615.  
  616. procedure getboolean
  617.  
  618.    (char_prompt:   screen_text;
  619.     atr,atc,                 {co-ordinates}
  620.     cursor_attr,
  621.     pattr,dattr:   byte;     {prompt and data attributes}
  622. var response:      boolean);
  623.  
  624. var
  625.     response_ch,
  626.     default_ch:    char;
  627. {
  628.   Cannot be a default value for response, as it must be true or false (i.e.
  629.   no 'blank' state).
  630. }
  631. begin
  632.   response_ch := chr(ord(response) + $30); {convert to '0'/'1'}
  633.  
  634.   getchar(char_prompt,atr,atc,cursor_attr,pattr,dattr,response_ch,
  635.           CharacterSet[TrueOrFalse].CharSet,false,response_ch);
  636.  
  637.   if not escaped then
  638.     response := pos(response_ch,Truechars + BooleanTrueChar) > 0;
  639. end;
  640.  
  641.  
  642. procedure getbool
  643.  
  644.    (char_prompt:   screen_text;
  645.     atr,atc:       byte;     {co-ordinates}
  646. var response:      boolean);
  647.  
  648. begin
  649.   getboolean(char_prompt,atr,atc,Default_cursor_attr,
  650.              Default_pattr,Default_dattr,response);
  651. end;
  652.  
  653.  
  654. procedure getdigit
  655.  
  656.    (atr,atc:  byte;
  657.     nattr:    integer);
  658.  
  659. {
  660.   Get any of the following characters: ^H,^I,^J,^M,^[,^Y,^U,'-','+','.', ","
  661.   Echo using nattr attribute if nattr > 0.
  662.  
  663.   This procedure is used in procedures getnumber and getreal.
  664. }
  665. var
  666.     figure, result: integer;
  667.     action: edit;
  668. begin
  669.   repeat
  670.     gotorc(atr,atc);
  671.     command := extendkey;
  672.  
  673.     if scancode = 0 then {not an extended key}
  674.  
  675.       begin
  676.         if not (chr(asciicode) in [^H,^I,^J,^M,^[,^Y,^U,'-','+','.',',']) then
  677.           begin
  678.             val(chr(asciicode),figure,result);
  679.             if not (result = 0) then
  680.               error2(Press_a_numeric_key)
  681.             else if nattr > 0 then
  682.               Qwrite(atr,atc,nattr,chr(asciicode));
  683.           end
  684.         else result := 0;
  685.       end;
  686.  
  687.   until (result = 0) or (scancode <> 0);
  688. end;
  689.  
  690.  
  691.  
  692. {$I getnum.pas}
  693. {$I getreal.pas}
  694.  
  695.  
  696. procedure getlongint
  697.  
  698.    (num_prompt:       screen_text;
  699.     atr,atc:          byte;        {screen co-ords}
  700.     low,high:         integer;
  701.     pattr,nattr:      byte;
  702. var number:           longint;
  703.     default:          numstring);
  704.  
  705. begin
  706.   getnumber(num_prompt,atr,atc,low,high,pattr,nattr,number,maxlongint,default);
  707. end;
  708.  
  709.  
  710. procedure getinteger
  711.  
  712.    (num_prompt:       screen_text;
  713.     atr,atc:          byte;        {screen co-ords}
  714.     low,high:         integer;
  715.     pattr,nattr:      byte;
  716. var number:           integer;
  717.     default:          numstring);
  718.  
  719. var longI:            longint;
  720.  
  721. begin
  722.   longI := number;
  723.   getnumber(num_prompt,atr,atc,low,high,pattr,nattr,longI,maxint,default);
  724.   number := longI;
  725. end;
  726.  
  727.  
  728. procedure getshortint
  729.  
  730.    (num_prompt:       screen_text;
  731.     atr,atc:          byte;        {screen co-ords}
  732.     low,high:         integer;
  733.     pattr,nattr:      byte;
  734. var number:           shortint;
  735.     default:          numstring);
  736.  
  737. var shortI:           longint;
  738.  
  739. begin
  740.   shortI := number;
  741.   getnumber(num_prompt,atr,atc,low,high,pattr,nattr,shortI,maxshortint,default);
  742.   number := shortI;
  743. end;
  744.  
  745.  
  746. procedure getword
  747.  
  748.    (num_prompt:       screen_text;
  749.     atr,atc:          byte;        {screen co-ords}
  750.     low,high:         integer;
  751.     pattr,nattr:      byte;
  752. var number:           word;
  753.     default:          numstring);
  754.  
  755. var wordI:           longint;
  756.  
  757. begin
  758.   wordI := number;
  759.   getnumber(num_prompt,atr,atc,low,high,pattr,nattr,wordI,maxword,default);
  760.   number := wordI;
  761. end;
  762.  
  763.  
  764. procedure getbyte
  765.  
  766.    (num_prompt:       screen_text;
  767.     atr,atc:          byte;        {screen co-ords}
  768.     low,high:         integer;
  769.     pattr,nattr:      byte;
  770. var number:           byte;
  771.     default:          numstring);
  772.  
  773. var byteI:           longint;
  774.  
  775. begin
  776.   byteI := number;
  777.   getnumber(num_prompt,atr,atc,low,high,pattr,nattr,byteI,maxbyte,default);
  778.   number := byteI;
  779. end;
  780.  
  781.  
  782. {$I getstr.pas}
  783. {$I getdate.pas}
  784. {$I gettime.pas}
  785.  
  786. { check for 80 col screen mode if not set then force it }
  787.  
  788. begin
  789.   LastVideoMode := QVideoMode;
  790.   VideoModeNow  := QVideoMode;
  791.  
  792.   case VideoModeNow of
  793.     BW40: VideoModeNow := BW80;
  794.     CO40: VideoModeNow := CO80;
  795.   end;
  796.  
  797.   if VideoModeNow <> QVideoMode then
  798.     begin
  799.       TextMode (VideoModeNow + hi(LastMode));
  800.       Qinit;
  801.     end;
  802.  
  803.   if QVideoMode = Mono then
  804.     begin
  805.       RedAttr             := 120;
  806.       PicCursor           := 7;
  807.       FieldCursor         := 9;
  808.       Default_cursor_attr := 112;
  809.     end;
  810. end. {end of unit}
  811.