home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / INPFLD11.ZIP / FIELDTST.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1987-07-02  |  5.2 KB  |  159 lines

  1. { ==================================================== }
  2. { FieldTest - Test out the InpFld routine. Demonstrate }
  3. {     how it works.                                    }
  4. {                                                      }
  5. { Information about how to use InpFld is provided in   }
  6. { the procedure header for InpFld in the file          }
  7. { INPFLD.INC                                           }
  8. { ==================================================== }
  9. Program FieldTest;
  10.  
  11. {$IINPFLD.INC }
  12.  
  13. Const
  14.    UPPER = 1;
  15.    AUTOEXIT = 5;
  16.    RJUST = 6;
  17.    DISPOLD = 7;
  18.  
  19.    editkeys : array [1..16] of strg80 = (
  20.      '               Field Editing Keys           ',
  21.      '                                            ',
  22.      'Left Arrow  (Ctl-S) - Move left one column  ',
  23.      'Right Arrow (Ctl-D) - Move right one column ',
  24.      'Home        (Ctl-A) - Go to start of field  ',
  25.      'End         (Ctl-F) - go to end of field    ',
  26.      'BackSpace           - Delete char to left   ',
  27.      'Del         (Ctl-G) - Delete current char   ',
  28.      'Ctl-BackSpace       - Delete entire field   ',
  29.      'Ins                 - Toggle insert mode    ',
  30.      'Ctl-End             - Delete to end of field',
  31.      'Ctl-Left Arrow      - Move one word to left ',
  32.      'Ctl-Right Arrow     - Move one word to right',
  33.      '                                            ',
  34.      'To exit the field, use Enter, Tab, BackTab, ',
  35.      'Esc, Up Arrow or Down Arrow.                ');
  36. Var
  37.    keyval : integer;         { Returned value of last keystroke }
  38.    attr   : integer;         { The field attributes             }
  39.    row,col: integer;         { Row/col position of the field    }
  40.    size   : integer;         { Length of the field              }
  41.    legal  : strg255;         { List of legal characters         }
  42.    ibuf   : strg255;         { The actual input string          }
  43.    options: option_type;     { Input options                    }
  44.    s      : strg80;          { a display string for DispLine    }
  45.    i      : integer;
  46.  
  47. Procedure DisplayExitCode;
  48. Var atr : integer;
  49. begin
  50.    s := 'Exit key value: ';
  51.    atr := ((black shl 4) + green);
  52.    DispLine(60,18,atr,s);
  53.    Gotoxy(77,19);
  54.    Write(keyval);
  55. end;
  56.  
  57. begin
  58.    ClrScr;
  59.    s := 'InpFld - Field Input Demonstration';
  60.    attr := ((red shl 4) + yellow);
  61.    DispLine(22,0,attr,s);   { Display a banner }
  62.    attr := ((blue shl 4) + white);
  63.    for i := 1 to 16 do DispLine(35,i+1,attr,editkeys[i]); { show edit info }
  64.  
  65. { No options chosen. No uppercase translation, no auto exit from }
  66. { field, no initial string display. Allow all characters.        }
  67.  
  68.    s := 'No options, all chars legal';
  69.    attr := ((black shl 4) + white);
  70.    DispLine(4,2,attr,s);  { note that displine coordinates are 0-24, 0-79 }
  71.    row := 4;     { InpFld coordinates are 1-25, 1-80 }
  72.    col := 5;
  73.    attr := ((lightgray shl 4) + black);
  74.    size := 27;
  75.    legal := '';
  76.    ibuf := 'This will not be displayed.';
  77.    options := [];
  78.    InpFld(keyval,legal,ibuf,attr,col,row,size,options);
  79.    DisplayExitCode;
  80.  
  81. { Uppercase translation. All characters legal.                   }
  82.  
  83.    s := 'Translate all to uppercase';
  84.    attr := ((black shl 4) + white);
  85.    DispLine(4,5,attr,s);
  86.    row := 7;
  87.    col := 5;
  88.    attr := ((red shl 4) + lightgreen);
  89.    size := 26;
  90.    legal := '';
  91.    ibuf := 'This will not be displayed.';
  92.    options := [UPPER];
  93.    InpFld(keyval,legal,ibuf,attr,col,row,size,options);
  94.    DisplayExitCode;
  95.  
  96. { Display old string. All characters legal.                      }
  97.  
  98.    row := 9;
  99.    col := 5;
  100.    attr := ((green shl 4) + black);
  101.    size := 24;
  102.    legal := '';
  103.    ibuf := 'Display old field.';
  104.    options := [DISPOLD];
  105.    InpFld(keyval,legal,ibuf,attr,col,row,size,options);
  106.    DisplayExitCode;
  107.  
  108. { Autoexit on filled field. numbers only.                        }
  109.  
  110.    s := 'Auto exit when full - numbers';
  111.    attr := ((black shl 4) + white);
  112.    DispLine(0,10,attr,s);
  113.    row := 12;
  114.    col := 1;
  115.    attr := ((blue shl 4) + yellow);
  116.    size := 29;
  117.    legal := '0123456789';
  118.    ibuf := '4321';
  119.    options := [AUTOEXIT,DISPOLD];
  120.    InpFld(keyval,legal,ibuf,attr,col,row,size,options);
  121.    DisplayExitCode;
  122.  
  123. {                                                                }
  124.  
  125.    s := 'Answer yes/no (Y/N):';
  126.    attr := ((magenta shl 4) + black);
  127.    DispLine(2,15,attr,s);
  128.    row := 16;
  129.    col := 24;
  130.    attr := ((lightgray shl 4) + black);
  131.    size := 1;
  132.    legal := 'NY';
  133.    ibuf := 'Y';
  134.    options := [UPPER,DISPOLD];
  135.    InpFld(keyval,legal,ibuf,attr,col,row,size,options);
  136.    DisplayExitCode;
  137.  
  138.  
  139. { Upper case, display old, right justify at end.                 }
  140.  
  141.    s := 'Enter a filename - try illegal characters (right justified on exit)';
  142.    attr := ((black shl 4) + white);
  143.    DispLine(0,19,attr,s);
  144.    row := 21;
  145.    col := 1;
  146.    attr := ((brown shl 4) + white);
  147.    size := 50;
  148.    legal := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:.$&#@!%''`~()-{}_/\';
  149.    ibuf := 'C:\SUBDIR\SUB\FILENAME.EXT';
  150.    options := [UPPER,RJUST,DISPOLD];
  151.    InpFld(keyval,legal,ibuf,attr,col,row,size,options);
  152.    DisplayExitCode;
  153.  
  154.    Gotoxy(1,23);
  155.    Writeln('See INPFLD.INC for more information. InpFld is a ShareWare procedure.');
  156.    Write  ('         Copyright (C) 1987 by Michael Burton Software.');
  157.  
  158. end.
  159.