home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / HEXDMP.ZIP / HEXTEST.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1987-12-01  |  4.2 KB  |  146 lines

  1. Program HexTest    { 1987/12/01 };
  2.  
  3. {    A sample program showing some uses of the HexDmp Unit.    }
  4.  
  5. Uses Crt,HexDmp;
  6.  
  7. {    The next five constants are samples of hexadecimal formatting strings
  8.     for use with HexArea and Hexline.
  9.  
  10.     These constants do not exist in the unit itself.  The user of the unit
  11.     must provide any such definitions.    }
  12.  
  13. Const    HexBytes: string[79] =
  14. '%%%%:@@@@  ## ## ## ## ## ## ## ##  ## ## ## ## ## ## ## ##  ~~~~~~~~ ~~~~~~~~';
  15.  
  16.         HexDebug: string[78] =
  17. '%%%%:@@@@  ## ## ## ## ## ## ## ##-## ## ## ## ## ## ## ##   ~~~~~~~~~~~~~~~~';
  18.  
  19. {    Note:    The following three constants would be concatenated
  20.             to create a format string for a Vertical Hex Format.
  21.  
  22.             Notice the use of the HexNL token to generate multiple
  23.             lines of output.    }
  24.  
  25.         HexVline1: string[77] =
  26. '       !!!!!!!!  !!!!!!!!  !!!!!!!!  !!!!!!!!  !!!!!!!!  !!!!!!!!  !!!!!!!!_';
  27.         HexVline2: string[77] =
  28. '%LLL:  ^^^^^^^^  ^^^^^^^^  ^^^^^^^^  ^^^^^^^^  ^^^^^^^^  ^^^^^^^^  ^^^^^^^^_';
  29.         HexVline3: string[77] =
  30. '@LLL   &&&&&&&&  &&&&&&&&  &&&&&&&&  &&&&&&&&  &&&&&&&&  &&&&&&&&  &&&&&&&&_';
  31.  
  32.  
  33. Var    ascOpt,                            { ASCII mask option }
  34.     i : integer;
  35.  
  36.     baseLine: boolean;                { base line 0 flag }
  37.  
  38.     areaPtr: pointer;                { dump area pointer }
  39.  
  40.     dumpBytes,                        { dump area length remaining }
  41.     formatBytes: word;                { dump area length formatted }
  42.  
  43.     dumpArea: array[0..255] of byte;{ sample dump area }
  44.  
  45.     HexVertical: string;            { vertical hex format string }
  46.  
  47. Procedure Pause;
  48.  
  49. {    Write pause message and wait for ENTER key.    }
  50.  
  51. begin
  52.     Write('Press ENTER to continue...');
  53.     Readln;
  54.     Writeln;
  55. end;
  56.  
  57. {    Program mainline.    }
  58.  
  59. begin
  60.     if (ParamCount = 1) and (ParamStr(1) = '?') then
  61.     begin
  62.         Writeln('HEXTEST Version 1.0 Copyright 1987 by Lawrence R. Steeger');
  63.         Writeln;
  64.         Writeln('A sample program illustrating the use of the HexDmp Unit.');
  65.         Writeln;
  66.         Writeln('     Syntax:    HEXTEST    [?]');
  67.         Writeln;
  68.         Writeln('   Operands:    ?    display program syntax');
  69.         Writeln;
  70.         Writeln('ERRORLEVELS:    0    program successful');
  71.         Writeln('        1    syntax displayed');
  72.         Writeln;
  73.         Halt(1);
  74.     end;
  75.  
  76.     {    build sample data area to be dumped    }
  77.  
  78.     for i := 0 to SizeOf(dumpArea) do dumpArea[i] := byte(i);
  79.  
  80.     HexVertical := HexVLine1            { build vertical hex format string }
  81.                  + HexVLine2
  82.                  + HexVLine3;
  83.  
  84.     {    display area ASCII only    }
  85.  
  86.     ascOpt := HexIBMgraph;                { ASCII format is IBM Graphics }
  87.     baseLine := False;                    { base line is not 0 base }
  88.     areaPtr := @dumpArea;                { area to be dumped }
  89.     dumpBytes := SizeOf(dumpArea);        { length of area to be dumped }
  90.  
  91.     ClrScr;
  92.     Writeln('HexBytes Format: HEX with ASCII using IBM Graphics Character Set');
  93.     Writeln;
  94.     while dumpBytes > 0
  95.     do Writeln(HexLine(HexBytes,        { format string }
  96.                        ascOpt,            { ASCII format option }
  97.                        baseLine,        { base line 0 flag }
  98.                        areaPtr,            { area pointer }
  99.                        dumpBytes,        { area byte count }
  100.                        formatBytes)        { area bytes formatted }
  101.               );
  102.     Writeln;
  103.     Pause;
  104.  
  105.     {    display area ASCII and hex    }
  106.  
  107.     ascOpt := HexASCII;                    { ASCII format is ASCII only }
  108.     baseLine := False;                    { base line is not 0 base }
  109.     areaPtr := @dumpArea;                { area to be dumped }
  110.     dumpBytes := SizeOf(dumpArea);        { length of area to be dumped }
  111.  
  112.     ClrScr;
  113.     Writeln('HexDebug Format: HEX and ASCII using ASCII Character Set');
  114.     Writeln;
  115.     while dumpBytes > 0
  116.     do Writeln(HexLine(HexDebug,        { format string }
  117.                        ascOpt,            { ASCII format option }
  118.                        baseLine,        { base line 0 flag }
  119.                        areaPtr,            { area pointer }
  120.                        dumpBytes,        { area byte count }
  121.                        formatBytes)        { area bytes formatted }
  122.               );
  123.     Writeln;
  124.     Pause;
  125.  
  126.     {    display ASCII and hex in vertical format    }
  127.  
  128.     ascOpt := HexHiBit;                    { ASCII format is masked ASCII }
  129.     baseLine := False;                    { base line is not 0 base }
  130.     areaPtr := @dumpArea;                { area to be dumped }
  131.     dumpBytes := SizeOf(dumpArea);        { length of area to be dumped }
  132.  
  133.     ClrScr;
  134.     Writeln('HexVertical Format: HEX and ASCII using Masked ASCII Character Set');
  135.     Writeln;
  136.     HexArea(HexVertical,                { format string }
  137.             ascOpt,                        { ASCII format option }
  138.             baseLine,                    { base line 0 flag }
  139.             areaPtr,                    { area pointer }
  140.             dumpBytes                    { area byte count }
  141.            );
  142.     Pause;
  143.  
  144.     Halt(0);
  145. end.
  146.