home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / pcmag / vol9n21.zip / DGDEC.PAS < prev    next >
Pascal/Delphi Source File  |  1990-09-25  |  11KB  |  401 lines

  1. {
  2.  ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  3.  █                                                                         █
  4.  █        TITLE :      DGDEC.TPU                                           █
  5.  █      PURPOSE :      Common declarations.                                █
  6.  █       AUTHOR :      David Gerrold, CompuServe ID:  70307,544            █
  7.  █  _____________________________________________________________________  █
  8.  █                                                                         █
  9.  █   Written in Turbo Pascal, Version 5.5,                                 █
  10.  █   with routines from TurboPower, Object Professional.                   █
  11.  █                                                                         █
  12.  █   Turbo Pascal is a product of Borland International.                   █
  13.  █   Object Professional is a product of TurboPower Software.              █
  14.  █  _____________________________________________________________________  █
  15.  █                                                                         █
  16.  █   This is not public domain software.                                   █
  17.  █   This software is copyright 1990, by David Gerrold.                    █
  18.  █   Permission is hereby granted for personal use.                        █
  19.  █                                                                         █
  20.  █        The Brass Cannon Corporation                                     █
  21.  █        9420 Reseda Blvd., #804                                          █
  22.  █        Northridge, CA  91324-2932.                                      █
  23.  █                                                                         █
  24.  ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  25.                                                                             }
  26. { Compiler Directives ===================================================== }
  27.  
  28. {$A-}    {Switch word alignment off, necessary for cloning}
  29. {$R-}    {Range checking off}
  30. {$B-}    {Boolean complete evaluation off}
  31. {$S-}    {Stack checking off}
  32. {$I-}    {I/O checking off}
  33. {$N+,E+} {Simulate numeric coprocessor}
  34. {$M 16384,0,327680} {stack and heap}
  35. {$V-}    {Variable range checking off}
  36.  
  37. { Name ==================================================================== }
  38.  
  39. UNIT DgDec;
  40. {
  41.   The purpose of this code is to provide a template for beginning a new
  42.   unit.  Replace these lines with a general description of the unit's
  43.   abilities.
  44. }
  45.  
  46. { ========================================================================= }
  47. { Interface =============================================================== }
  48.  
  49. INTERFACE
  50.  
  51. { ========================================================================= }
  52. { Type declarations ======================================================= }
  53.  
  54. TYPE
  55.   Proc = Procedure;
  56.  
  57. TYPE
  58.   CapsFlagType =
  59.     (NoCaps,
  60.      MixedCaps,
  61.      SentenceCaps,
  62.      NameCaps,
  63.      AllCaps);
  64.  
  65. { Shift key declarations -------------------------------------------------- }
  66.  
  67. VAR
  68.   KeyStateByte : byte absolute $40:$17;          { shift key status }
  69.  
  70. CONST
  71. { Bit values of KeyStateByte at $40:$17 }
  72.   RightShiftKey =   1;
  73.   LeftShiftKey  =   2;
  74.   ShiftKey      =   3;
  75.   ControlKey    =   4;
  76.   AltKey        =   8;
  77.   ScrlLock      =  16;
  78.   NumLock       =  32;
  79.   CapsLock      =  64;
  80.   InsLock       = 128;
  81.  
  82. { Boolean declarations ---------------------------------------------------- }
  83.  
  84. CONST
  85.   Flag         : boolean = false;                { trash variable }
  86.   FlagArray    : array [false..true] of string [3] = ('Off', ' On');
  87.  
  88. { Key declarations -------------------------------------------------------- }
  89.  
  90. CONST
  91.   SpaceChar       : char = #32;
  92.  
  93. CONST
  94.   Null            = #0;
  95.   BackSpace       = #8;
  96.   Tab             = #9;
  97.   Enter           = #13;
  98.   Esc             = #27;
  99.   CtrlBackSpace   = #127;
  100.   ShiftTab        = #143;
  101.  
  102.   ShiftDownArrow  = #50;                         { '2' }
  103.   ShiftLeftArrow  = #52;                         { '4' }
  104.   ShiftRightArrow = #54;                         { '6' }
  105.   ShiftUpArrow    = #56;                         { '8' }
  106.  
  107. { Alt-characters 144-178. }
  108.   AltA = #158;
  109.   AltB = #176;
  110.   AltC = #174;
  111.   AltD = #160;
  112.   AltE = #146;
  113.   AltF = #161;
  114.   AltG = #162;
  115.   AltH = #163;
  116.   AltI = #151;
  117.   AltJ = #164;
  118.   AltK = #165;
  119.   AltL = #166;
  120.   AltM = #178;
  121.   AltN = #177;
  122.   AltO = #152;
  123.   AltP = #153;
  124.   AltQ = #144;
  125.   AltR = #147;
  126.   AltS = #159;
  127.   AltT = #148;
  128.   AltU = #150;
  129.   AltV = #175;
  130.   AltW = #145;
  131.   AltX = #173;
  132.   AltY = #149;
  133.   AltZ = #172;
  134. {
  135.   Here are the same declarations in numerical order.
  136.   Notice that you get the ordering of keys as they
  137.   appear on the keyboard.  This is because the function
  138.   is generating the values by adding 128 to the scancode
  139.   of the character.
  140.  
  141.   AltQ = #144;
  142.   AltW = #145;
  143.   AltE = #146;
  144.   AltR = #147;
  145.   AltT = #148;
  146.   AltY = #149;
  147.   AltU = #150;
  148.   AltI = #151;
  149.   AltO = #152;
  150.   AltP = #153;
  151.   AltA = #158;
  152.   AltS = #159;
  153.   AltD = #160;
  154.   AltF = #161;
  155.   AltG = #162;
  156.   AltH = #163;
  157.   AltJ = #164;
  158.   AltK = #165;
  159.   AltL = #166;
  160.   AltZ = #172;
  161.   AltX = #173;
  162.   AltC = #174;
  163.   AltV = #175;
  164.   AltB = #176;
  165.   AltN = #177;
  166.   AltM = #178;
  167. }
  168.  
  169. { Normal function keys }
  170.   F1         = #187;
  171.   F2         = #188;
  172.   F3         = #189;
  173.   F4         = #190;
  174.   F5         = #191;
  175.   F6         = #192;
  176.   F7         = #193;
  177.   F8         = #194;
  178.   F9         = #195;
  179.   F10        = #196;
  180.  
  181.   HomeKey    = #199;
  182.   UpArrow    = #200;
  183.   PgUp       = #201;
  184.   LeftArrow  = #203;
  185.   RightArrow = #205;
  186.   EndKey     = #207;
  187.   DownArrow  = #208;
  188.   PgDn       = #209;
  189.   InsertKey  = #210;
  190.   DeleteKey  = #211;
  191.  
  192. { Shifted function keys }
  193.   ShiftF1    = #212;
  194.   ShiftF2    = #213;
  195.   ShiftF3    = #214;
  196.   ShiftF4    = #215;
  197.   ShiftF5    = #216;
  198.   ShiftF6    = #217;
  199.   ShiftF7    = #218;
  200.   ShiftF8    = #219;
  201.   ShiftF9    = #220;
  202.   ShiftF10   = #221;
  203.  
  204. { Control function keys }
  205.   CtrlF1     = #222;
  206.   CtrlF2     = #223;
  207.   CtrlF3     = #224;
  208.   CtrlF4     = #225;
  209.   CtrlF5     = #226;
  210.   CtrlF6     = #227;
  211.   CtrlF7     = #228;
  212.   CtrlF8     = #229;
  213.   CtrlF9     = #230;
  214.   CtrlF10    = #231;
  215.  
  216. { Alt function keys }
  217.   AltF1      = #232;
  218.   AltF2      = #233;
  219.   AltF3      = #234;
  220.   AltF4      = #235;
  221.   AltF5      = #236;
  222.   AltF6      = #237;
  223.   AltF7      = #238;
  224.   AltF8      = #239;
  225.   AltF9      = #240;
  226.   AltF10     = #241;
  227.  
  228. { Control keypad keys }
  229.   CtrlLeftArrow   = #243;
  230.   CtrlRightArrow  = #244;
  231.   CtrlEndKey      = #245;
  232.   CtrlPageDown    = #246;
  233.   CtrlHomeKey     = #247;
  234.   CtrlPageUp      = #248;        { Scancode-shift sees CtrlPageUp as ^D }
  235.                                  { ReadChar translates it to #248 }
  236.  
  237. { Control shift keypad keys }
  238.   CtrlShiftLeftArrow   = #249;
  239.   CtrlShiftRightArrow  = #250;
  240.   CtrlShiftEndKey      = #251;
  241.   CtrlShiftPageDown    = #252;
  242.   CtrlShiftHomeKey     = #253;
  243.   CtrlShiftPageUp      = #254;
  244.  
  245. { KeyCode declarations ---------------------------------------------------- }
  246.  
  247. CONST
  248.   KcEnter   = $1C0D;
  249.   KcEsc     = $011B;
  250.  
  251. { KeyCode values of alphabet keys }
  252. { add as needed }
  253.   KcUpD     = $2044;
  254.   KcUpN     = $314E;
  255.   KcUpR     = $1352;
  256.   KcUpS     = $1F53;
  257.   KcUpU     = $1655;
  258.  
  259.   KcLoD     = $2064;
  260.   KcLoN     = $316E;
  261.   KcLoR     = $1372;
  262.   KcLoS     = $1F73;
  263.   KcLoU     = $1675;
  264.  
  265.   KcCtrlD   = $2004;
  266.   KcCtrlN   = $310E;
  267.   KcCtrlR   = $1312;
  268.   KcCtrlS   = $1F13;
  269.   KcCtrlU   = $1615;
  270.  
  271. { KeyCode values of Number pad }
  272.   KcNumPadDot = $532E;
  273.   KcNumPad0 = $5230;
  274.   KcNumPad1 = $4F31;
  275.   KcNumPad2 = $5032;
  276.   KcNumPad3 = $5133;
  277.   KcNumPad4 = $4B34;
  278.   KcNumPad5 = $4C35;
  279.   KcNumPad6 = $4D36;
  280.   KcNumPad7 = $4737;
  281.   KcNumPad8 = $4838;
  282.   KcNumPad9 = $4939;
  283.  
  284.   KcNumPadMinus = $4A2D;
  285.   KcNumPadPlus  = $4E2B;
  286.  
  287. { KeyCode values of function keys }
  288.   KcF1         = $3B00;
  289.   KcF2         = $3C00;
  290.   KcF3         = $3D00;
  291.   KcF4         = $3E00;
  292.   KcF5         = $3F00;
  293.   KcF6         = $4000;
  294.   KcF7         = $4100;
  295.   KcF8         = $4200;
  296.   KcF9         = $4300;
  297.   KcF10        = $4400;
  298.  
  299. { KeyCode values of cursor keys }
  300.   KcHomeKey    = $4700;
  301.   KcUpArrow    = $4800;
  302.   KcPgUp       = $4900;
  303.   KcLeftArrow  = $4B00;
  304.   KcRightArrow = $4D00;
  305.   KcEndKey     = $4F00;
  306.   KcDownArrow  = $5000;
  307.   KcPgDn       = $5100;
  308.   KcInsertKey  = $5200;
  309.   KcDeleteKey  = $5300;
  310.  
  311.   KcCtrlHomeKey    = $7700;
  312.   KcCtrlPgUp       = $8400;
  313.   KcCtrlLeftArrow  = $7300;
  314.   KcCtrlRightArrow = $7400;
  315.   KcCtrlEndKey     = $7500;
  316.   KcCtrlPgDn       = $7600;
  317.  
  318. { KeyCode values of Alt chars }
  319.   KcAltA = $1E00;
  320.   KcAltB = $3000;
  321.   KcAltC = $2E00;
  322.   KcAltD = $2000;
  323.   KcAltE = $1200;
  324.   KcAltF = $2100;
  325.   KcAltG = $2200;
  326.   KcAltH = $2300;
  327.   KcAltI = $1700;
  328.   KcAltJ = $2400;
  329.   KcAltK = $2500;
  330.   KcAltL = $2600;
  331.   KcAltM = $3200;
  332.   KcAltN = $3100;
  333.   KcAltO = $1800;
  334.   KcAltP = $1900;
  335.   KcAltQ = $1000;
  336.   KcAltR = $1300;
  337.   KcAltS = $1F00;
  338.   KcAltT = $1400;
  339.   KcAltU = $1600;
  340.   KcAltV = $2F00;
  341.   KcAltW = $1100;
  342.   KcAltX = $2D00;
  343.   KcAltY = $1500;
  344.   KcAltZ = $2C00;
  345.  
  346. { Procedure declarations -------------------------------------------------- }
  347.  
  348. PROCEDURE Zen;
  349. { Empty procedure to pass to procedure variables. }
  350.  
  351. FUNCTION ShiftKeyOn : boolean;
  352. { returns true if either shift key is pressed }
  353.  
  354. FUNCTION AltKeyReleased : boolean;
  355. { returns true if alt-key is not pressed }
  356.  
  357. { ========================================================================= }
  358. { Implementation ========================================================== }
  359.  
  360. IMPLEMENTATION
  361.  
  362. { ========================================================================= }
  363. { Zen ===================================================================== }
  364.  
  365. {$F+} PROCEDURE Zen; {$F-}
  366. { Empty procedure to pass to procedure variables. }
  367. BEGIN
  368. { ... do nothing ... }
  369. END;
  370.  
  371. { ShiftKeyOn ============================================================== }
  372.  
  373. FUNCTION ShiftKeyOn : boolean;
  374. { returns true if either shift key is pressed }
  375. BEGIN
  376.   ShiftKeyOn := KeyStateByte and ShiftKey > 0;
  377. END;
  378.  
  379. { AltKeyReleased ========================================================== }
  380.  
  381. FUNCTION AltKeyReleased : boolean;
  382. { returns true if alt-key is not pressed }
  383. BEGIN
  384.   AltKeyReleased := KeyStateByte and AltKey <> AltKey;
  385. END;
  386.  
  387. { ========================================================================= }
  388. { Initialization ========================================================== }
  389.  
  390. { No initialization needed. }
  391. END.
  392.  
  393. { ========================================================================= }
  394. { ========================================================================= }
  395.  
  396. NOTES:
  397.  
  398.  
  399. { ========================================================================= }
  400. { ========================================================================= }
  401.