home *** CD-ROM | disk | FTP | other *** search
- /*********************************************************/
- /* LIBADD - Add a directory entry to LIBPATH. */
- /* */
- /* Syntax: LIBADD dir */
- /* */
- /* Purpose: Add a specified directory to the beginning */
- /* of the LIBPATH statement of C:\CONFIG.SYS. */
- /* */
- /* If the specified entry is already in the */
- /* LIBPATH it will be moved to the beginning. */
- /* */
- /* The original CONFIG.SYS will be backed up */
- /* as C:\CONFIG.BAK. */
- /* */
- /* Note: This program deliberately avoids RXUTILS */
- /* functions as the sole purpose of this prog- */
- /* ram is to add the current directory entry */
- /* to the LIBPATH so that RXUTILS may be */
- /* loaded upon the next reboot. */
- /* */
- /* */
- /* (C) Copyright IBM Corp. 1994 */
- /*********************************************************/
- '@echo off'
- trace 'o'
- parse arg dir file
-
-
- /****************/
- /* Check syntax */
- /****************/
- if dir='' then do
- say 'Syntax: LIBADD dir file'
- say
- say 'Purpose: Add a specified directory to the beginning'
- say ' of the LIBPATH statement of CONFIG.SYS.'
- exit 2
- end
-
-
- /**************************************/
- /* Reset counters and setup variables */
- /**************************************/
- i=0
- LibLine=0
- Dirty=0
-
-
- /*****************/
- /* Read the file */
- /*****************/
- i=0
- do while lines(file)
- i=i+1
- stem.i = linein(file)
- str=translate(strip(space(stem.i)))
- if abbrev(str, 'LIBPATH ') | abbrev(str, 'LIBPATH=') then LibLine=i
- end
- call stream file, 'c', 'close'
- stem.0 = i
-
- /*****************************************/
- /* Insert new directory if LibPath found */
- /*****************************************/
- if LibLine<>0 then do
- oldstuff=strip(substr(stem.LibLine, pos('LIBPATH', translate(stem.LibLine))+8))
- if left(oldstuff,1)='=' then oldstuff=strip(substr(oldstuff, 2))
- pos = pos(translate(dir), translate(oldstuff))
- /*********************************/
- /* If not found add to beginning */
- /*********************************/
- if pos=0 then do
- stem.LibLine='LIBPATH='dir';'oldstuff
- Dirty=1
- end
- else
- /*******************************************/
- /* If found and not at beginning then move */
- /*******************************************/
- if pos<>1 then do
- pre=left(oldstuff, pos-1)
- post=substr(oldstuff, pos+length(dir))
- if right(pre,1)=';' & left(post,1)=';' then post=substr(post,2)
- stem.LibLine='LIBPATH='dir';'pre||post
- Dirty=1
- end
- end
-
-
- /********************************/
- /* Write the new file if needed */
- /********************************/
- if Dirty<>0 then do
- 'COPY C:\CONFIG.SYS C:\CONFIG.BAK>nul 2>&1'
- if RC=0 then do
- 'DEL C:\CONFIG.SYS>nul 2>&1'
- if RC=0 then
- do i=1 to stem.0
- call lineout file, stem.i
- end
- else
- do
- say 'Old CONFIG.SYS could not be updated.'
- say 'The file might be READ-ONLY.'
- exit 2
- end
- end
- else do
- say 'Old CONFIG.SYS could not be backed up.'
- exit 2
- end
- end
- call stream file, 'c', 'close'
- exit 0
-