home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1998 April A
/
Pcwk4a98.iso
/
Wtestowe
/
OnNet16
/
LIBGET.SCR
< prev
next >
Wrap
Text File
|
1997-01-08
|
5KB
|
147 lines
*---------------------------------------------------------------------*
* "LIBGET.BAT" : Relay/PC Gold Library Extraction *
*---------------------------------------------------------------------*
*
* (c) Copyright 1983,1993 RELAY Technology Inc.
*
* This program extracts members from a Library file previously
* built for use with Relay/PC Gold. The user is prompted for the
* library fileid and the output member file (which includes the
* drive, path, name, extension).
*
* Supplied arguments (optional) are:
* &1 = Library fileid
* &2 = Member fileid
*---------------------------------------------------------------------*
* Module History *
*---------------------------------------------------------------------*
* *
* Latest Revision - *
* *
* $Revision: 1.8 $ *
* *
* Modification Log - *
* *
* M0001V70 Put Relay Source Files under PVCS Control *
* by JMM on 12/18/95 *
* *
*---------------------------------------------------------------------*
*
* Initialize variables
*
&INPFILE = &1 ;* Library fileid (input file)
&OUTFILE = &2 ;* Member fileid (output file)
&MFILE="" ;* Member fileid
&MNAME="" ;* Current Member name
&DIRCNT=0 ;* Count of directory entries
&DIRNUM=0 ;* Current directory entry number
&DIRMN0="" ;* Array is list of member names
&DIRNO0=0 ;* Array is member offset in file
&DIRLN0=0 ;* Array is length of member
*
* Introduction & prompts
*
clear
if (&INPFILE<>"") goto -CHECK1
-ASK1
&FILESPEC = "Library Files/*.LIB/All Files/*.*/"
&INPFILE = &rdrive
display dialogbox CLEAR
display dialogbox FILEOPEN "Specify fileid for the Library" &FILESPEC &INPFILE
if (&rc = 2) quiet stop
if (&INPFILE="") stop 99 "INo library specified!"
-CHECK1 &INPFILE=&upper(&trim(&INPFILE))
if not valid &INPFILE goto -ASK1
if exists &INPFILE then goto CONT1
display dialogbox OK "Library Extract Utility" "File &INPFILE does not exist."
&INPFILE = ""
goto ASK1
-CONT1
if (&OUTFILE<>"") goto -CHECK2
-ASK2 display dialogbox INPUT "Library Extract Utility" "Specify the fileid for the output members: " &OUTFILE
if (&OUTFILE="") stop 99 "INo member specified!"
-CHECK2 &OUTFILE=&upper(&trim(&OUTFILE))
if not valid &OUTFILE goto -ASK2
*
* Check for single or complete extraction
*
&MNAME = &fname(&OUTFILE)
if (&MNAME="????????") goto -READALL
gosub -EXTRACT
display dialogbox OK "Library Extract Utility" "Extract completed."
stop
*---------------------------------------------------------------------*
* Extract all members from the library *
*---------------------------------------------------------------------*
*
* First, read the library directory.
*
-READALL open &INPFILE as #1 length 16 binary
field #1 1 8 &DIRMN&DIRNUM char
field #1 * 2 &DIRNO&DIRNUM dec
field #1 * 2 &DIRLN&DIRNUM dec
field #1 * 4 &NULL
&DIRNUM = 0
read record #1
if (&DIRMN0<>"PDSDIR ") then display dialogbox OK "Library Extract Utility" "File &INPFILE is not a library!"
then stop 98
&DIRCNT = &DIRLN0
&DIRNUM = 1
loop *+2 &DIRCNT
read record #1
&DIRNUM = &DIRNUM+1
close #1
*
* Loop to extract all members
*
&DIRNUM = 1
loop *+3 &DIRCNT
&MNAME = &trim(&DIRMN&DIRNUM)
gosub -EXTRACT
&DIRNUM = &DIRNUM+1
display dialogbox OK "Library Extract Utility" "Extract completed."
stop
*---------------------------------------------------------------------*
* Extract a member from the library *
*---------------------------------------------------------------------*
-EXTRACT &MFILE=&FDIR(&OUTFILE)&MNAME..&FEXT(&OUTFILE)
display dialogbox INFO "Library Extract Utility" "Writing &MFILE"
on error
open &INPFILE as #1 for input stream binary buffersize 4096 member &MNAME
&HRC = &rc
if (&HRC=2) then display dialogbox OK "Library Extract Utility" "Member &MNAME not found in file &INPFILE.."
then quiet stop
if (&HRC<>0) then display dialogbox OK "Library Extract Utility" "Member &MNAME could not be extracted. Problems opening file &INPFILE.."
on error stop error
open &MFILE as #2 for output stream binary buffersize 4096
read file #1 &RECORD
loop *+2 while found
write file #2 &RECORD
read file #1 &RECORD
close #1
close #2
return