home *** CD-ROM | disk | FTP | other *** search
Wrap
*------------------------------------------------------------------------------* * PROGRAM: STRIPSCR.SCR DATE: 02/03/88 * (c) Copyright 1983,91 Relay Technology Inc. * All rights reserved. * * FUNCTION: Batch program to prompt user for the name of the file that contains * the member names of a list of SCRIPT or BATCH files that we wish to * strip the comments and blank lines out of. * *---------------------------------------------------------------------* * Module History * *---------------------------------------------------------------------* * * * Latest Revision - * * * * $Revision: 1.8 $ * * * * Modification Log - * * * * M0001V70 Put Relay Source Files under PVCS Control * * by JMM on 12/18/95 * * * *---------------------------------------------------------------------* on error -TOP global &FILEIT &MEMBERS &OUTLIB &USERPATH &FILEIT=YES &LIBFLAG="N" &MEMCTR=0; &BEGBYTE=0; &ENDBYTE=0; &TOTBYTE=0 clear * Warn user that files run throughout this procedure will be significantly changed * -ADVISE display dialogbox OKCANCEL "Strip Script Utility" "This procedure performs the following functions:&CR &LF [1] Removes comment lines and blank lines&LF [2] Removes command line comments &LF" if (&rc = 2) quiet stop display dialogbox OKCANCEL "Strip Script Utility" "[3] Removes leading blanks on command lines&LF [4] Evaluates GOTOs, GOSUBs and LOOPS, replacing label names with absolute line&LF number references. " if (&rc = 2) quiet stop display dialogbox OKCANCEL "Strip Script Utility" "The input file (.SCR) will not be modified in&LF any way. The 'stripped' file will instead be &LF saved with a file extension of '.SCX'. " if (&rc = 2) quiet stop * * Get input file name and display file size before STRIPSCR * -PROMPT &FILESPEC = "All Files/*.*/" &MEMBERS = &rdrive display dialogbox CLEAR display dialogbox FILEOPEN "Specify Member-List File" &FILESPEC &MEMBERS if (&rc = 2) quiet stop clear * * Get drive and path info * &USERPATH = &fdirectory(&MEMBERS) open &MEMBERS as #1 for input loop ENDREAD until not found read file #1 &MEMNAME if not found goto -ENDALL if (&substring(&MEMNAME,1,1)="*") then goto ENDREAD argstring &MEMNAME &MEMNAME=&trim(&1) &HNAME=&MEMNAME &MEMNAME = &USERPATH.&MEMNAME &BEGBYTE=&calc(&BEGBYTE+&fsize(&MEMNAME)) &MEMCTR=&MEMCTR+1 display dialogbox clear display dialogbox INFO "Strip Script Utility" "Stripping file &upper(&HNAME) - please stand by..." edit &MEMNAME execute STRIPSCR.EDS nodisplay &ENDBYTE=&calc(&ENDBYTE+&fsize(&USERPATH.&fname(&MEMNAME).SCX)) -ENDREAD * * Calculate the benefit of having run STRIPSCR * -ENDALL CLOSE #1 if (&BEGBYTE<&ENDBYTE) then &TOTBYTE=0 then &FINAL=0 then GOTO -STATS &TOTBYTE=&BEGBYTE-&ENDBYTE &ENDPER=&ENDBYTE*100 &PERCENT=&ENDPER/&BEGBYTE &FINAL=100-&PERCENT * * Display STRIPSCR statistics * -STATS display dialogbox clear display dialogbox OKCANCEL "Strip Script Utility" "Total bytes saved with STRIPSCR: &TOTBYTE&LF Pulverization Factor: &FINAL&LF You may choose to place these files into a library..." if (&rc = 2) quiet stop * Provide opportunity to create or update library * -LIBNAME &XSPEC='Library Files/*.LIB/All Files/*.*/' &XNAME='&USERPATH' display dialogbox CLEAR display dialogbox INPUT "Strip Script Utility" "Specify a Library Name" &OUTLIB if (&rc = 2) quiet stop clear if (&fstate(&OUTLIB)="R/W") or (&fstate(&OUTLIB)="R/O") then GOTO OVERTYP * if not exists LIBRARY.SCR * then goto NOLIB * Create member file that contains of all the valid members but with .SCX exten. -LIBYES2 open &MEMBERS as #1 for input open &USERPATH.XYZMEMBR.DAT as #2 for output loop FILESWAP * read file #1 &LINE1 if not found close #1 then close #2; then goto LIBYES if (&substr(&LINE1,1,1)="*") then goto FILESWAP argstring &LINE1 &LINE1=&trim(&1) if (&LINE1="") then goto FILESWAP ;* skip blank lines &LINE1 = &fname(&LINE1) ;* capture just filename - no extension write file #2 &LINE1..SCX -FILESWAP -LIBYES * If no drive/path spec provided, then use same spec as member list if (&instr(&OUTLIB,"\")=0) and (&instr(&OUTLIB,":")=0) then &OUTLIB=&USERPATH.&OUTLIB quiet execute LIBRARY.SCR &OUTLIB &USERPATH.XYZMEMBR.DAT &HRC = &retcode if (&HRC > 0) display dialogbox OK "Strip Script Utility" "LIBRARY.SCR could not be run!" quiet erase &USERPATH.XYZMEMBR.DAT quiet stop * * If library already exists, prompt user for overtype instructions. * -OVERTYP display dialogbox OKCANCEL "Strip Script Utility" "Library already exists. Select OK to overwrite, CANCEL to exit." if (&rc = 2) goto LIBNAME goto LIBYES2 -NOLIB display dialogbox ERRORM "Strip Script Utility" "LIBRARY.SCR not in current directory - Cannot create library." quiet stop