home *** CD-ROM | disk | FTP | other *** search
- Program HexTest { 1987/12/01 };
-
- { A sample program showing some uses of the HexDmp Unit. }
-
- Uses Crt,HexDmp;
-
- { The next five constants are samples of hexadecimal formatting strings
- for use with HexArea and Hexline.
-
- These constants do not exist in the unit itself. The user of the unit
- must provide any such definitions. }
-
- Const HexBytes: string[79] =
- '%%%%:@@@@ ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ~~~~~~~~ ~~~~~~~~';
-
- HexDebug: string[78] =
- '%%%%:@@@@ ## ## ## ## ## ## ## ##-## ## ## ## ## ## ## ## ~~~~~~~~~~~~~~~~';
-
- { Note: The following three constants would be concatenated
- to create a format string for a Vertical Hex Format.
-
- Notice the use of the HexNL token to generate multiple
- lines of output. }
-
- HexVline1: string[77] =
- ' !!!!!!!! !!!!!!!! !!!!!!!! !!!!!!!! !!!!!!!! !!!!!!!! !!!!!!!!_';
- HexVline2: string[77] =
- '%LLL: ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^_';
- HexVline3: string[77] =
- '@LLL &&&&&&&& &&&&&&&& &&&&&&&& &&&&&&&& &&&&&&&& &&&&&&&& &&&&&&&&_';
-
-
- Var ascOpt, { ASCII mask option }
- i : integer;
-
- baseLine: boolean; { base line 0 flag }
-
- areaPtr: pointer; { dump area pointer }
-
- dumpBytes, { dump area length remaining }
- formatBytes: word; { dump area length formatted }
-
- dumpArea: array[0..255] of byte;{ sample dump area }
-
- HexVertical: string; { vertical hex format string }
-
- Procedure Pause;
-
- { Write pause message and wait for ENTER key. }
-
- begin
- Write('Press ENTER to continue...');
- Readln;
- Writeln;
- end;
-
- { Program mainline. }
-
- begin
- if (ParamCount = 1) and (ParamStr(1) = '?') then
- begin
- Writeln('HEXTEST Version 1.0 Copyright 1987 by Lawrence R. Steeger');
- Writeln;
- Writeln('A sample program illustrating the use of the HexDmp Unit.');
- Writeln;
- Writeln(' Syntax: HEXTEST [?]');
- Writeln;
- Writeln(' Operands: ? display program syntax');
- Writeln;
- Writeln('ERRORLEVELS: 0 program successful');
- Writeln(' 1 syntax displayed');
- Writeln;
- Halt(1);
- end;
-
- { build sample data area to be dumped }
-
- for i := 0 to SizeOf(dumpArea) do dumpArea[i] := byte(i);
-
- HexVertical := HexVLine1 { build vertical hex format string }
- + HexVLine2
- + HexVLine3;
-
- { display area ASCII only }
-
- ascOpt := HexIBMgraph; { ASCII format is IBM Graphics }
- baseLine := False; { base line is not 0 base }
- areaPtr := @dumpArea; { area to be dumped }
- dumpBytes := SizeOf(dumpArea); { length of area to be dumped }
-
- ClrScr;
- Writeln('HexBytes Format: HEX with ASCII using IBM Graphics Character Set');
- Writeln;
- while dumpBytes > 0
- do Writeln(HexLine(HexBytes, { format string }
- ascOpt, { ASCII format option }
- baseLine, { base line 0 flag }
- areaPtr, { area pointer }
- dumpBytes, { area byte count }
- formatBytes) { area bytes formatted }
- );
- Writeln;
- Pause;
-
- { display area ASCII and hex }
-
- ascOpt := HexASCII; { ASCII format is ASCII only }
- baseLine := False; { base line is not 0 base }
- areaPtr := @dumpArea; { area to be dumped }
- dumpBytes := SizeOf(dumpArea); { length of area to be dumped }
-
- ClrScr;
- Writeln('HexDebug Format: HEX and ASCII using ASCII Character Set');
- Writeln;
- while dumpBytes > 0
- do Writeln(HexLine(HexDebug, { format string }
- ascOpt, { ASCII format option }
- baseLine, { base line 0 flag }
- areaPtr, { area pointer }
- dumpBytes, { area byte count }
- formatBytes) { area bytes formatted }
- );
- Writeln;
- Pause;
-
- { display ASCII and hex in vertical format }
-
- ascOpt := HexHiBit; { ASCII format is masked ASCII }
- baseLine := False; { base line is not 0 base }
- areaPtr := @dumpArea; { area to be dumped }
- dumpBytes := SizeOf(dumpArea); { length of area to be dumped }
-
- ClrScr;
- Writeln('HexVertical Format: HEX and ASCII using Masked ASCII Character Set');
- Writeln;
- HexArea(HexVertical, { format string }
- ascOpt, { ASCII format option }
- baseLine, { base line 0 flag }
- areaPtr, { area pointer }
- dumpBytes { area byte count }
- );
- Pause;
-
- Halt(0);
- end.