*----------------------------------------------------------------------*(c) 2005 Kevin G. Rhoads. All rights reserved.

* Watcom specific stuff for command lines *----------------------------------------------------------------------integer function nargs() include 'fsublib.fi' *---nargs = iargc() return end *----------------------------------------------------------------------subroutine getarg(which,arg,status) include 'fsublib.fi' integer*2 which,status character*128 arg integer arglen,iwhich *---iwhich = which arglen = igetarg(iwhich,arg) status = arglen return end *----------------------------------------------------------------------*(c) 1996 Kevin G. Rhoads. All rights reserved. *portions (c) 1995 Kevin G. Rhoads. All rights reserved. *portions (c) 1993 Kevin G. Rhoads. All rights reserved. *----------------------------------------------------------------------subroutine fnsep(fn,drive,path,file,ext) character*(*) fn character drive*1,path*63,file*8,ext*3,copr*63 integer*4 bslash,dot,i,ij,iend,max,next,len intrinsic len *------copr = 'Copyright (c) 1996 Kevin G. Rhoads. '// & 'All rights reserved.' drive = ' '

path = ' ' file = ' ' ext = ' ' do 1000 i = 1,len(fn) next = i if (fn(i:i).ne.' ') goto 1001 if (fn(i:i).eq.'@') then goto 1001 endif 1000 continue return 1001 continue * if ((next+1).gt.len(fn)) return if ((next+1).gt.len(fn)) print *,'fnsep: DUH' if (fn(next+1:next+1).eq.':') then drive = fn(next:next) next = next + 2 else drive = ' ' endif * write (*,*) ' fnsep: drive = ',drive max = min(127,len(fn)) bslash = 0 * if ((next).gt.len(fn)) return do 1 i = next,max if (fn(i:i).eq.'\') bslash = i 1 continue if (bslash.eq.0) then path = ' ' else path = fn(next:bslash) next = bslash + 1 endif iend = min(max,next+8) dot = 0 * write (*,*) ' fnsep: path = ',path

2 3

* 9000 *

10 9001 *

11

do 2 i = next,iend if (fn(i:i).eq.'.') then dot = i goto 3 endif continue continue if (dot.eq.0) then file = fn(next:iend) ext = ' ' goto 9000 else file = fn(next:dot-1) next = dot + 1 endif write (*,*) ' fnsep: file =',file iend = min(max,next+2) ext = fn(next:iend) continue write (*,*) ' fnsep: ext =',ext do 10 i = 1,63 ij = ichar(path(i:i)) if (ij.le.32) then path(i:63) = ' ' goto 9001 endif continue continue write (*,*) ' fnsep: path = ',path do 11 i = 1,8 ij = ichar(file(i:i)) if (ij.le.32) then file(i:8) = ' ' goto 9002 endif continue

continue * write (*,*) ' fnsep: file =',file do 12 i = 1,3 ij = ichar(ext(i:i)) if (ij.le.32) then ext(i:3) = ' ' goto 9003 endif 12 continue 9003 continue * write (*,*) ' fnsep: ext =',ext return * 4444 copr = '(c) 1996, 93 Kevin G. Rhoads. All rights reserved.' end *----------------------------------------------------------------------subroutine fnsepc(fn,drive,path,file,ext) character*128 fn character drive*1,path*63,file*8,ext*3,copr*63 integer*4 bslash,dot,i,ij,iend,max,next,len intrinsic len *------copr = 'Copyright (c) 1996 Kevin G. Rhoads. '// & 'All rights reserved.' drive = ' ' path = ' ' file = ' ' ext = ' ' do 1000 i = 1,128 next = i if (fn(i:i).ne.' ') goto 1001 if (fn(i:i).eq.'@') then goto 1001 endif 1000 continue 1001 continue if ((next+1).gt.len(fn)) return

9002

*

*

if (fn(next+1:next+1).eq.':') then drive = fn(next:next) next = next + 2 else drive = ' ' endif write (*,*) ' fnsep: drive = ',drive max = 127 bslash = 0 do 1 i = next,max if (fn(i:i).eq.'\') bslash = i 1 continue if (bslash.eq.0) then path = ' ' else path = fn(next:bslash) next = bslash + 1 endif iend = min(max,next+8) dot = 0 write (*,*) ' fnsep: path = ',path do 2 i = next,iend if (fn(i:i).eq.'.') then dot = i goto 3 endif 2 continue 3 continue if (dot.eq.0) then file = fn(next:iend) ext = ' ' goto 9000 else file = fn(next:dot-1) next = dot + 1 endif

*

write (*,*) ' fnsep: file =',file iend = min(max,next+2) ext = fn(next:iend) 9000 continue * write (*,*) ' fnsep: ext =',ext do 10 i = 1,63 ij = ichar(path(i:i)) if (ij.le.32) then path(i:63) = ' ' goto 9001 endif 10 continue 9001 continue * write (*,*) ' fnsep: path = ',path do 11 i = 1,8 ij = ichar(file(i:i)) if (ij.le.32) then file(i:8) = ' ' goto 9002 endif 11 continue 9002 continue * write (*,*) ' fnsep: file =',file do 12 i = 1,3 ij = ichar(ext(i:i)) if (ij.le.32) then ext(i:3) = ' ' goto 9003 endif 12 continue 9003 continue * write (*,*) ' fnsep: ext =',ext return * 4444 copr = '(c) 1996, 93 Kevin G. Rhoads. All rights reserved.' end *-----------------------------------------------------------------------

subroutine fnjoin(fn,drive,path,file,ext) character*(*) fn character drive*1,path*63,file*8,ext*3,copr*63 integer*4 max,next,ij,iabs,i,iend intrinsic iabs *------& copr = 'Copyright (c) 1996 Kevin G. Rhoads. '// 'All rights reserved.' max = 127 fn = ' ' if (drive.eq.' ') then next = 1 else fn(1:1) = drive fn(2:2) = ':' next = 3 endif do 1 i = 1,63 ij = ichar(path(i:i)) if (ij.le.32) then if (i.eq.1) goto 2 iend = next + i - 2 iend = min(max,iend) fn(next:iend) = path(1:i-1) next = iend + 1 goto 2 endif continue iend = min(max,next+62) fn(next:iend) = path next = iend + 1 continue if (next.gt.max) return if (next.gt.1) then if (next.gt.3.or.fn(next-1:next-1).ne.':') then if (fn(next-1:next-1).ne.'\') then

1

2

fn(next:next) = '\' next = next + 1 endif endif endif if (next.gt.max) return do 3 i = 1,8 ij = ichar(file(i:i)) if (ij.le.32) then if (i.eq.1) then iend = next iend = min(max,iend) fn(next:iend) = file(1:1) else iend = next + i - 2 iend = min(max,iend) fn(next:iend) = file(1:i-1) endif next = iend + 1 goto 4 endif 3 continue iend = min(max,next+7) fn(next:iend) = file next = next + 8 4 continue if (next.gt.max) return fn (next:next) = '.' iend = min(max,next+3) if (ext.ne.' ') fn(next+1:iend) = ext return * 4444 copr = '(c) 1996, 93 Kevin G. Rhoads. All rights reserved.' end *----------------------------------------------------------------------subroutine fnjoic(fn,drive,path,file,ext) character*128 fn

character drive*1,path*63,file*8,ext*3,copr*63 integer*4 max,next,ij,iabs,i,iend intrinsic iabs *------& copr = 'Copyright (c) 1996 Kevin G. Rhoads. '// 'All rights reserved.' max = 127 fn = ' ' if (drive.eq.' ') then next = 1 else fn(1:1) = drive fn(2:2) = ':' next = 3 endif do 1 i = 1,63 ij = ichar(path(i:i)) if (ij.le.32) then if (i.eq.1) goto 2 iend = next + i - 2 iend = min(max,iend) fn(next:iend) = path(1:i-1) next = iend + 1 goto 2 endif continue iend = min(max,next+62) fn(next:iend) = path next = iend + 1 continue if (next.gt.max) return if (next.gt.1) then if (next.gt.3.or.fn(next-1:next-1).ne.':') then if (fn(next-1:next-1).ne.'\') then fn(next:next) = '\' next = next + 1

1

2

endif endif endif if (next.gt.max) return do 3 i = 1,8 ij = ichar(file(i:i)) if (ij.le.32) then if (i.eq.1) then iend = next iend = min(max,iend) fn(next:iend) = file(1:1) else iend = next + i - 2 iend = min(max,iend) fn(next:iend) = file(1:i-1) endif next = iend + 1 goto 4 endif 3 continue iend = min(max,next+7) fn(next:iend) = file next = next + 8 4 continue if (next.gt.max) return fn (next:next) = '.' iend = min(max,next+3) if (ext.ne.' ') fn(next+1:iend) = ext return * 4444 copr = '(c) 1996, 93 Kevin G. Rhoads. All rights reserved.' end *----------------------------------------------------------------------subroutine fnchk(infn,outfn,ddrive,dpath,dfile,dext) character*(*) infn,outfn character ddrive*1,dpath*63,dfile*8,dext*3 character drive*1,path*63,file*8,ext*3,copr*63

equivalence (path,copr) *------copr = 'Copyright (c) 1996 Kevin G. Rhoads. '// & 'All rights reserved.' call fnsep(infn,drive,path,file,ext) if (drive.eq.' ') drive = ddrive if (path.eq.' ') path = dpath if (file.eq.' ') file = dfile if (ext.eq.' ') ext = dext call fnjoin(outfn,drive,path,file,ext) return * 4444 copr = '(c) 1996, 93 Kevin G. Rhoads. All rights reserved.' end *----------------------------------------------------------------------subroutine fnchkc(infn,outfn,ddrive,dpath,dfile,dext) character*128 infn,outfn character ddrive*1,dpath*63,dfile*8,dext*3 character drive*1,path*63,file*8,ext*3,copr*63 equivalence (path,copr) *------copr = 'Copyright (c) 1996 Kevin G. Rhoads. '// & 'All rights reserved.' call fnsepc(infn,drive,path,file,ext) if (drive.eq.' ') drive = ddrive if (path.eq.' ') path = dpath if (file.eq.' ') file = dfile if (ext.eq.' ') ext = dext call fnjoic(outfn,drive,path,file,ext) return * 4444 copr = '(c) 1996, 93 Kevin G. Rhoads. All rights reserved.' end *----------------------------------------------------------------------subroutine fnovr(infn,outfn,ddrive,dpath,dfile,dext) character*(*) infn,outfn character ddrive*1,dpath*63,dfile*8,dext*3 character drive*1,path*63,file*8,ext*3,copr*63

equivalence (path,copr) *------copr = 'Copyright (c) 1996 Kevin G. Rhoads. '// & 'All rights reserved.' call fnsep(infn,drive,path,file,ext) if (ddrive.ne.' ') drive = ddrive if (dpath.ne.' ') path = dpath if (dfile.ne.' ') file = dfile if (dext.ne.' ') ext = dext call fnjoin(outfn,drive,path,file,ext) return * 4444 copr = '(c) 1996, 93 Kevin G. Rhoads. All rights reserved.' end *----------------------------------------------------------------------subroutine fnovrc(infn,outfn,ddrive,dpath,dfile,dext) character*128 infn,outfn character ddrive*1,dpath*63,dfile*8,dext*3 character drive*1,path*63,file*8,ext*3,copr*63 equivalence (path,copr) *------copr = 'Copyright (c) 1996 Kevin G. Rhoads. '// & 'All rights reserved.' call fnsepc(infn,drive,path,file,ext) if (ddrive.ne.' ') drive = ddrive if (dpath.ne.' ') path = dpath if (dfile.ne.' ') file = dfile if (dext.ne.' ') ext = dext call fnjoic(outfn,drive,path,file,ext) return * 4444 copr = '(c) 1996, 93 Kevin G. Rhoads. All rights reserved.' end *----------------------------------------------------------------------subroutine fname1(infile,outfil,it) character infile*8,outfil*8,it*1,copr*63 integer i *-------

copr = 'Copyright (c) 1996 Kevin G. Rhoads. '// & 'All rights reserved.' outfil(8:8) = it do 1 i = 7,1,-1 if (infile(i:i).ne.' ') then outfil(i:i) = infile(i:i) else outfil(i:8) = it//' ' endif 1 continue return * 4444 copr = '(c) 1996, 93 Kevin G. Rhoads. All rights reserved.' end *----------------------------------------------------------------------subroutine fname2(infile,outfil,it) character infile*8,outfil*8,it*4,copr*63 integer i *------copr = 'Copyright (c) 1996 Kevin G. Rhoads. '// & 'All rights reserved.' outfil(7:8) = it do 1 i = 6,1,-1 if (infile(i:i).ne.' ') then outfil(i:i) = infile(i:i) else outfil(i:8) = it//' ' endif 1 continue return * 4444 copr = '(c) 1996, 93 Kevin G. Rhoads. All rights reserved.' end *-----------------------------------------------------------------------------character*8 function bumpfilename(filename) character*8 filename,pre,num,post,it*1,format*6,copr*63 integer*4 prebeg,preend,numbeg,numend,postbeg,postend integer*4 i,iit

integer len intrinsic len *----bumpfilename = filename iit = len(bumpfilename) * * * & print *,' BumpFileName entered.' copr = 'Copyright (c) 1996 Kevin G. Rhoads. '// 'All rights reserved.'

prebeg = 8 preend = 0 numbeg = 0 numend = 0 postbeg = 0 postend = 0 do 1 i = 1,8 it = filename(i:i) iit = ichar(it) if (iit.ge.65.and.iit.le.90) then prebeg = min(i,prebeg) preend = max(preend,i) elseif (iit.ge.97.and.iit.le.122) then prebeg = min(i,prebeg) preend = max(preend,i) elseif (it.eq.'_'.or.it.eq.'$') then prebeg = min(i,prebeg) preend = max(preend,i) elseif (iit.ge.48.and.iit.le.57) then preend = max(preend,i - 1) numbeg = i goto 2 elseif (it.eq.' ') then preend = max(preend,i - 1) goto 9999

endif 1 continue goto 9999 * * found beginning of numeric part 2 continue do 3 i = preend+1,8 it = filename(i:i) iit = ichar(it) if (iit.ge.65.and.iit.le.90) then numend = max(numend,i - 1) postbeg = i postend = i goto 4 elseif (iit.ge.97.and.iit.le.122) then numend = max(numend,i - 1) postbeg = i postend = i goto 4 elseif (it.eq.'_'.or.it.eq.'$') then numend = max(numend,i - 1) postbeg = i postend = i goto 4 elseif (iit.ge.48.and.iit.le.57) then numend = max(numend,i) elseif (it.eq.' ') then numend = max(numend,i - 1) goto 9998 endif 3 continue goto 9998 4 continue do 5 i = postbeg+1,8 it = filename(i:i) iit = ichar(it)

if (iit.ge.65.and.iit.le.90) then postend = i elseif (iit.ge.97.and.iit.le.122) then postend = i elseif (it.eq.'_'.or.it.eq.'$') then postend = i elseif (iit.ge.48.and.iit.le.57) then numbeg = i preend = i - 1 postbeg = 0 postend = 0 goto 2 elseif (it.eq.' ') then postend = i - 1 goto 6 endif 5 continue 6 continue 9998 continue if (prebeg.ne.0.and.preend.ne.0) then if (preend.lt.prebeg) preend = prebeg pre = filename(prebeg:preend) else pre = ' ' endif * print *,prebeg,' ',preend,' ',pre num = filename(numbeg:numend) * print *,numbeg,' ',numend,' ',num if (postbeg.ne.0) then post = filename(postbeg:postend) else post = ' ' endif * print *,postbeg,' ',postend,' ',post iit = numend - numbeg + 1 write (unit=format,fmt='(''(i'',i1.1,''.'',i1.1,'')'')') iit,iit

*

* * *

print *,' format = ',format read (unit=num,fmt='(i8)') iit iit = iit + 1 write (unit=num,fmt=format) iit print *,' num = ',num print *,' num(1:(numend-numbeg+1)) = ',num(1:(numend-numbeg+1)) print *,' num((numbeg+8-numend):8) = ',num((numbeg+8-numend):8) if (prebeg.ne.0.and.preend.ne.0.and. & numbeg.ne.0.and.numend.ne.0.and. & postbeg.ne.0.and.postend.ne.0) then bumpfilename = pre(1:(preend-prebeg+1)) // & num(1:(numend-numbeg+1)) // & post(1:(postend-postbeg+1)) iit = preend - prebeg + 1 iit = numend - numbeg + 1 + iit iit = postend - postbeg + 1 + iit elseif (prebeg.eq.0.and. & numbeg.ne.0.and.numend.ne.0.and. & postend.ne.0) then bumpfilename = num(1:(numend-numbeg+1)) // & post(1:(postend-postbeg+1)) iit = numend - numbeg + 1 iit = postend - postbeg + 1 + iit elseif (prebeg.ne.0.and. & numbeg.ne.0.and.numend.ne.0.and. & postend.eq.0) then bumpfilename = pre(1:(preend-prebeg+1)) // & num(1:(numend-numbeg+1)) iit = preend - prebeg + 1 iit = numend - numbeg + 1 + iit elseif (numbeg.ne.0.and.numend.ne.0) then iit = numend - numbeg + 1 bumpfilename = num & elseif (prebeg.ne.0.and.preend.ne.0.and. postbeg.ne.0.and.postend.ne.0) then

bumpfilename = pre(1:(preend-prebeg+1)) // & post(1:(postend-postbeg+1)) iit = preend - prebeg + 1 iit = postend - postbeg + 1 + iit elseif (prebeg.eq.0.and. & postend.ne.0) then bumpfilename = post(1:(postend-postbeg+1)) iit = postend - postbeg + 1 elseif (prebeg.ne.0.and. & postend.eq.0) then bumpfilename = pre(1:(preend-prebeg+1)) // & num(1:(numend-numbeg+1)) iit = preend - prebeg + 1 else bumpfilename = filename iit = len(bumpfilename) endif * print *,bumpfilename if (iit.lt.8) bumpfilename((iit+1):8) = ' ' * print *,bumpfilename 9997 continue return * *-----9999 continue bumpfilename = filename goto 9997 * 4444 copr = '(c) 1996, 95 Kevin G. Rhoads. All rights reserved.' 4444 copr = 'Copyright (c) 1996 Kevin G. Rhoads. '// & 'All rights reserved.' end *----------------------------------------------------------------------character*127 function ltrim(fn) character*(*) fn integer*4 i,j,len intrinsic len

*------j = 1 do 1 i = 127,1,-1 ltrim(i:i) = ' ' 1 continue do 1000 i = 1,len(fn) if ( fn(i:i).ne.' '.and.fn(i:i).ne.char(9) & .and.fn(i:i).ne.char(0) ) then ltrim(j:j) = fn(i:i) j = j + 1 endif 1000 continue return * 4444 copr = '(c) 1996 Kevin G. Rhoads. All rights reserved.' end *-----------------------------------------------------------------------------character*8 function basefilename(filename) character*8 filename,pre,num,post,it*1,format*6,copr*63 integer*4 prebeg,preend,numbeg,numend,postbeg,postend integer*4 i,iit *----copr = 'Copyright (c) 1996 Kevin G. Rhoads. '// & 'All rights reserved.' prebeg = 8 preend = 0 numbeg = 0 numend = 0 postbeg = 0 postend = 0 do 1 i = 1,8 it = filename(i:i) iit = ichar(it) if (iit.ge.65.and.iit.le.90) then prebeg = min(i,prebeg) preend = max(preend,i) elseif (iit.ge.97.and.iit.le.122) then

prebeg = min(i,prebeg) preend = max(preend,i) elseif (it.eq.'_'.or.it.eq.'$') then prebeg = min(i,prebeg) preend = max(preend,i) elseif (iit.ge.48.and.iit.le.57) then preend = max(preend,i - 1) numbeg = i goto 2 elseif (it.eq.' ') then preend = max(preend,i - 1) goto 9999 endif 1 continue goto 9999 * * found beginning of numeric part 2 continue do 3 i = preend+1,8 it = filename(i:i) iit = ichar(it) if (iit.ge.65.and.iit.le.90) then numend = max(numend,i - 1) postbeg = i postend = i goto 4 elseif (iit.ge.97.and.iit.le.122) then numend = max(numend,i - 1) postbeg = i postend = i goto 4 elseif (it.eq.'_'.or.it.eq.'$') then numend = max(numend,i - 1) postbeg = i postend = i goto 4

3 4

5 6 9998

elseif (iit.ge.48.and.iit.le.57) then numend = max(numend,i) elseif (it.eq.' ') then numend = max(numend,i - 1) goto 9998 endif continue goto 9998 continue do 5 i = postbeg+1,8 it = filename(i:i) iit = ichar(it) if (iit.ge.65.and.iit.le.90) then postend = i elseif (iit.ge.97.and.iit.le.122) then postend = i elseif (it.eq.'_'.or.it.eq.'$') then postend = i elseif (iit.ge.48.and.iit.le.57) then numbeg = i preend = i - 1 postbeg = 0 postend = 0 goto 2 elseif (it.eq.' ') then postend = i - 1 goto 6 endif continue continue continue if (prebeg.ne.0) then pre = filename(prebeg:preend) else pre = ' ' endif

* *

* *

* * *

print *,prebeg,' ',preend,' ',pre num = filename(numbeg:numend) print *,numbeg,' ',numend,' ',num if (postbeg.ne.0) then post = filename(postbeg:postend) else post = ' ' endif print *,postbeg,' ',postend,' ',post iit = numend - numbeg + 1 write (unit=format,fmt='(''(i'',i1.1,''.'',i1.1,'')'')') iit,iit print *,' format = ',format read (unit=num,fmt='(i8)') iit iit = 0 write (unit=num,fmt=format) iit print *,' num = ',num print *,' num(1:(numend-numbeg+1)) = ',num(1:(numend-numbeg+1)) print *,' num((numbeg+8-numend):8) = ',num((numbeg+8-numend):8) if (prebeg.ne.0.and.postend.ne.0) then basefilename = pre(1:(preend-prebeg+1)) // & num(1:(numend-numbeg+1)) // & post(1:(postend-postbeg+1)) iit = preend - prebeg + 1 iit = numend - numbeg + 1 + iit iit = postend - postbeg + 1 + iit elseif (prebeg.eq.0.and.postend.ne.0) then basefilename = num(1:(numend-numbeg+1)) // & post(1:(postend-postbeg+1)) iit = numend - numbeg + 1 iit = postend - postbeg + 1 + iit elseif (prebeg.ne.0.and.postend.eq.0) then basefilename = pre(1:(preend-prebeg+1)) // & num(1:(numend-numbeg+1)) iit = preend - prebeg + 1 iit = numend - numbeg + 1 + iit else

iit = numend - numbeg + 1 basefilename = num endif if (iit.lt.8) basefilename((iit+1):8) = ' ' * print *,basefilename 9997 continue return *-----9999 continue basefilename = filename goto 9997 * 4444 copr = '(c) 1996, 95 Kevin G. Rhoads. All rights reserved.' end

Sign up to vote on this title
UsefulNot useful