Escolar Documentos
Profissional Documentos
Cultura Documentos
=====================
2. The GREP Utility
=====================
GREP is a powerful search utility that can look for text in
several files at once.
The command-line syntax for GREP follows:
GREP [options] searchstring [filespec ... ]
where options consists of one or more single characters preceded
by a hyphen, searchstring defines the pattern to search for, and
filespec is the file specification. filespec tells GREP which
files (or groups of files) to search; it can be an explicit file
name or a generic file name incorporating the DOS wildcards (?
and *). You can also enter a path as part of filespec; if you use
filespec without a path, GREP only searches the current
directory. If you don't specify filespec, input to GREP must be
specified by redirecting stdin or piping.
=======================
3. The BINOBJ Utility
=======================
A utility program called BINOBJ.EXE has been added to convert any
file to an .OBJ file so it can be linked into a pascal program as
a "procedure." This is useful if you have a binary data file that
must reside in the code segment or is too large to make into a
typed constant array. For example, you can use BINOBJ with the
Graph unit to link the graphics driver or font files directly
into your .EXE file. Then, to use your graph program, you need
only have the .EXE file (see the example BGILINK.PAS).
BINOBJ takes three parameters:
BINOBJ <source[.BIN]> <destination[.OBJ]> <public name>
where source is the binary file to convert, destination is the
name of the .OBJ to be produced, and public name is the name of
the procedure as it will be declared in your pascal program.
The following example, the procedure ShowScreen, takes a pointer
as a parameter and moves 4000 bytes of data to screen memory. The
file called MENU.DTA contains the image of the main menu screen
(80 * 25 * 2 = 4000 bytes).
Here's a simple (no error-checking) version of MYPROG.PAS:
program MyProg;
uses Crt;
procedure ShowScreen(ScreenData : Pointer);
{ Display a screenful of data--no error-checking! }
var
ScreenSegment: Word;
begin
if (Lo(LastMode) = 7) then { Mono? }
ScreenSegment := $B000
else
ScreenSegment := $B800;
Move(ScreenData^, { From pointer }
Ptr(ScreenSegment, 0)^, { To video memory }
4000); { 80 * 25 * 2 }
end;
var
MenuP : Pointer;
MenuF : file;
begin
Assign(MenuF, 'MENU.DTA'); { Open screen data file }
Reset(MenuF, 1);
GetMem(MenuP, 4000); { Allocate buffer on heap }
BlockRead(MenuF, MenuP^, 4000); { Read screen data }
Close(MenuF);
ShowScreen(MenuP); { Display screen }
end.
The screen data file (MENU.DTA) is opened and then read into a
buffer on the heap. Both MYPROG.EXE and MENU.DTA must be present
at run-time for this program to work. You can use BINOBJ to
convert MENU.DTA to an .OBJ file (MENUDTA.OBJ) and tell it to
associate the data with a procedure called MenuData. Then you can
declare the fake external procedure MenuData, which actually
contains the screen data. Once you link in the .OBJ file with the
$L compiler directive, MenuData will be 4000 bytes long and
contain your screen data. First, run BINOBJ on MENU.DTA:
binobj MENU.DTA MENUDTA MenuData
The first parameter, MENU.DTA, shows a familiar file of screen
data; the second, MENUDTA, is the name of the .OBJ file to be
created (since you didn't specify an extension, .OBJ will be
added). The last parameter, MenuData, is the name of the external
procedure as it will be declared in your program. Now that you've
converted MENU.DTA to an .OBJ file, here's what the new
MYPROG.PAS looks like:
program MyProg;
uses Crt;
procedure ShowScreen(ScreenData : Pointer);
{ Display a screenful of data--no error checking! }
var
ScreenSegment: Word;
begin
if (Lo(LastMode) = 7) then { Mono? }
ScreenSegment := $B000
else
ScreenSegment := $B800;
Move(ScreenData^, { From pointer }
Ptr(ScreenSegment, 0)^, { To video memory }
4000); { 80 * 25 * 2 }
end;
procedure MenuData; external;
{$L MENUDTA.OBJ }
begin
ShowScreen(@MenuData); { Display screen }
end.
Notice that ShowScreen didn't change at all, and that the ADDRESS
of your procedure is passed using the @ operator.
================================
4. The Stand-Alone MAKE Utility
================================
For information on the MAKE utility, please refer to the Tools
and Utilities Guide.
* * * * *