home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1995 November
/
PCWK1195.iso
/
inne
/
podstawy
/
dos
/
4dos
/
4uzytki
/
4dman10b.exe
/
MAN.BTM
next >
Wrap
Text File
|
1992-10-20
|
5KB
|
156 lines
@echo off^goto man_start
:man_help
REM MAN 1.0ß by Jouni Vääriskoski (vaarisko@tnclus.tele.nokia.fi)
text
MAN -- Searches for user manual related to the given command. Version 1.0ß.
Usage: MAN <command>
( MAN /a <command> <document_file> - to add a record to MAN.DB )
<command> may be on of the following (checked in this order):
* An executable extension - MAN shows manual for the related command.
* A 4dos alias - MAN displays the alias definition, and,
if the first command in alias is *<command>, OR the alias doesn't include
carets and doesn't start with "if" or "for", asks for permission to
call itself with the first alias command as parameter.
* An internal 4dos cmd - MAN calls 4dos help.
* An external command - MAN searches for the following files:
- Files named <prg_name>.<txt|doc|man|hlp> in program file's directory.
- File MAN.DB, and if found, line starting with "<prg_name> ",
continued by the full name of the related document file.
Using wildcards (other than leading '*') in <command>, forces MAN
to search for external files only. The path of the first matching
filename is used, and all matching files in that directory are processed.
Note: In most cases, "MAN list.com" leads to an internal 4dos command
"list", since it is the way used by 4DOS when parsing command lines.
endtext
return
:man_start
if %# eq 0 .or. "%1" == "/?" (gosub man_help^quit)
if "%debug" eq "%0" echo on
if "%1" eq "/a" goto add_record
setlocal
set pa=%@upper[%@path[%1]]
set targ=%@upper[%@name[%1]]
set ex=%@upper[%@ext[%1]]
echo.
if "%ex" == "" goto noext
if %ex == COM .or. %ex == EXE .or. %ex == BTM .or. %ex == BAT goto catext
set ey=.%ex
iff "%[%ey]" ne "" then
echo Executable extension = %@upper[%[%ey]]
iff "%@path[%[%ey]]" == "" then
REM Call myself, no return:
%0 %@name[%[%ey]].%@ext[%[%ey]]
endiff
iff not exist %[%ey] then
echo Extension program not found
endiff
else
echo Executable extension .%ex definition not found
endiff
quit
:catext
set targ=%[targ].%[ex]
:noext
iff isalias %[pa]%[targ] then
REM Add quotes in case of compaund characters:
set alcmd=%@word[0,%@alias[%[pa]%[targ]]]
set alcaret=%@index["%@alias[%[pa]%[targ]]",%@char[94]]
set alstrct=%@index[.iff.if.for,.%[alcmd]]
echo 4dos Alias:
alias %[pa]%[targ]
iff "%[alcmd]" eq "*%targ" .or. %[alcaret] eq -1 .and. %[alstrct] eq -1 then
inkey /k"yn[Enter][Esc]" Continue with "%@upper[%0] %[alcmd]" (Y/n) ? %%a
if "%a" eq "y" .or. "%@ascii[%a]" eq "64" %0 %[alcmd]
rem elseiff %[alcaret] eq -1 .and. %[alstrct] eq -1 then
rem inkey /k"yn[Enter][Esc]" Continue with "%@upper[%0] %[alcmd]" (Y/n) ? %%a
rem if "%a" eq "y" .or. "%@ascii[%a]" eq "64" %0 %[alcmd]
endiff
quit
endiff
REM Note: Remove leading "*", if found ("isinternal *dir" returns false!).
iff %@substr[%targ,0,1] eq * then
set targ=%@substr[%targ,1]
endiff
set targ=%pa%%targ%
REM Note: Above the path, if given, must be included, othervise command
REM like "MAN c:\util\list.com" would go into the next iff, because
REM "isinternal LIST.COM" returns TRUE! (Bug in 4dos?)
REM Check if an internal 4DOS Command:
iff isinternal %targ then
echo Internal 4dos command - calling 4DOS HELP...
*help %targ
REM Plain "HELP" not used here - it may not refer to 4dos help.exe.
quit
endiff
REM Try to find the file(s) on PATH:
set targ=%@search[%targ]
iff "%targ" ne "" then
for %targ in (%targ) do gosub find_doc
else
echo Unknown command - check spelling.
endiff
quit
:find_doc
echos %@upper[%targ]
set desc=%@descript[%targ%]
REM Show description, if found:
iff "%desc" ne "" then^echo : %desc^else^echo.^endiff
REM Find files with the same NAME and extension used for document files:
for %dex in (.DOC .MAN .TXT .HLP) do (
set doc=%@search[%@path[%targ]%@name[%targ]%dex]
iff "%doc" ne "" then
list %doc
set %targ=OK
endiff
)
iff "%[%targ]" ne "OK" .AND. "%@search[man.db]" ne "" then
for %ln in (@%@search[man.db]) do (
iff "%@name[%targ]" eq "%@word[0,%ln]" then
set doc=%@search[%@word[1,%ln]]
iff "%doc" ne "" then
list %doc
set %targ=OK
else
beep^echo %@upper[%0]: Error in MAN.DB on line "%ln" - doc file not found.
endiff
endiff
)
endiff
if "%[%targ]" ne "OK" echo Related documentation not found. Try executing with /? switch.
unset /q %targ
echo.
return
:Add_Record
REM Adds a line to MAN.DB.
if "%3" eq "" (echo %@upper[%0]: Missing parameters.^quit 2)
setlocal
set Targ=%@search[%2]
if "%[Targ]" eq "" (echo %@upper[%0]: Program file "%2" missing - not recorded.^quit 2)
set Targ=%@search[%@path[%[Targ]]%@name[%3].%@ext[%3]]
if "%[Targ]" eq "" set Targ=%@search[%3]
if "%[Targ]" eq "" (echo %@upper[%0]: Document file "%3" missing - not recorded.^quit 2)
set Targ=%@path[%0]%0.db
iff not exist %[Targ] then
inkey /k"ny" %[Targ] doesn't exist - create it (Y/n) ? %%k
if "%[k]" eq "n" (echo Cancelled.^quit)
endiff
echo %2 %3 >> %[Targ]