home *** CD-ROM | disk | FTP | other *** search
- {************************************************************************
- Patches POPHELP.EXE to use a new default database. This is simpler and
- faster than changing and recompiling the source code (when the only change
- is to refer to a different default database).
-
- Usage: PHMOD NewHelpFileName [options]
- /N PgmName Program name [default = POPHELP.EXE]
- /? Display help
-
- Written 5/3/90, Terry Hughes, TurboPower Software
- CompuServe ID [72077,1450]
- ************************************************************************}
-
- {$R-,S-,V-,F+,A-,I-}
-
- program PhMod;
- {-Changes the default database in POPHELP.EXE}
-
- uses
- Dos,
- OpString,
- OpClone;
-
- const
- {Installation area}
- DBName : PathStr = 'OPRO.HLP'; {Default help file to load}
- HeapOverHead : Word = $1300; {Total heap overhead}
- Swap1Name : String[65] = 'POPHELP.SW1'; {Length limited by OPSWAP1}
-
- PgmName : PathStr = 'POPHELP.EXE';
- CopyRightLine = 'PHMOD 1.00 Copyright TurboPower Software 1990.';
-
- var
- C : Cloner;
- DBOfs : LongInt;
- Status : Word;
-
- procedure WriteHelp;
- {-Display help screen and halt}
- begin
- WriteLn('Usage: PHMOD NewHelpFileName [options]'^M);
- WriteLn(' /N PgmName Program name [default = POPHELP.EXE]');
- WriteLn(' /? Display help'^M^J);
- Halt(1);
- end;
-
- procedure Abort(Msg : String);
- begin
- WriteLn(Msg,^M^J);
- Halt(1);
- end;
-
- procedure ParseCommandLine;
- {-Gets command line options and sets various parameters}
- var
- Code : Word;
- Param : String;
- Cnt : Word;
- ComNum : Word;
-
- begin
- {Scan command line}
- if ParamCount = 0 then
- WriteHelp;
-
- Cnt := 1;
- Param := ParamStr(Cnt);
-
- while Cnt <= ParamCount do begin
- case Param[1] of
- '/', '-' :
- if Length(Param) <> 2 then
- Abort('Invalid parameter: '+Param)
- else
- case Upcase(Param[2]) of
- 'N' : begin
- Inc(Cnt);
- PgmName := StUpcase(ParamStr(Cnt));
- end;
- '?' : WriteHelp;
- else
- Abort('Invalid parameter: '+Param);
- end;
- else
- DBName := StUpCase(ParamStr(Cnt));
- end;
- Inc(Cnt);
- Param := ParamStr(Cnt);
- end;
- end;
-
- begin
- {Startup}
- WriteLn(CopyRightLine,^M^J);
- ParseCommandLine;
- {Open the file and find the id string}
- if not C.Init(PgmName, UpdateDate) then
- Abort('Unable to modify '+PgmName);
- if not C.FindDefaultsEnd(Swap1Name, SizeOf(Swap1Name), 0) then
- Abort('Unable to find ID string in '+PgmName);
- WriteLn('Opening '+PgmName+'...');
-
- {Adjust DBOfs to point to DBName}
- DBOfs := C.GetPos - SizeOf(DBName) - 2;
-
- {Store the new database name}
- WriteLn('Storing '+DBName+'...');
- C.StoreDefaults(DBOfs, DBName, SizeOf(DBName));
- Status := C.GetLastError;
- if Status <> 0 then
- Abort('Unable to write modifications to '+PgmName + ' ' + Long2Str(Status));
- WriteLn(PgmName+' successfully updated'^M^J);
- C.Done;
- end.
-