/************************************************************************ * openf -get arguments and open files, VMS version * * * * useage: if(openf())... * * where: openf =.true. if input and output files have * * been properly opened. * * =.false. if time to exit. * * HOW TO USE RATFOR UNDER VMS: * * * * $ rat {-pwv} filename * * This assumes that file "filename" has extention * * ".rat" and produces a file named "filename.for". * * * * p include profile information (currently unimplemented). * * w write out the longname file * * v write out the version of the preprocessor. * ************************************************************************/ logical function openf() include ratfor.def #why not logical getarg include getlin.cmm #has ptr include lineno.cmm #line numbers and names include flags.cmm character temp(80) #temporary string logical first data first/.true./ if(^first) { openf = .false. return } first = .false. call errset(29,.true.,.false.,.true.,.false.) #disable error messages call errset(30,.true.,.false.,.true.,.false.) ptr = INBUFSIZE + 1 #force call to getlin lun = 1 lineno(1) = 0 if(!getarg(1,temp)) { #get first argument write(ERRLUN,60) # if false then error, and exit 60 format(' useage: rat {-wpv} filename') call seterr(WARN_RET) call ratout } write_long_names = .false. include_profile = .false. print_version = .false. if(temp(1) == '-') { #some flags for(i = 1;temp(i) != EOS;i = i + 1) if(temp(i) == 'W') write_long_names = .true. else if(temp(i) == 'P') include_profile = .true. else if(temp(i) == 'V') print_version = .true. if(!getarg(2,temp)) { write(errlun,60) call seterr(WARN_RET) call ratout } } i = iindex(temp,period) #look for extention if(i == 0) #if no extention, add one call concat(temp,'.RAT') open(unit=1,name=temp,type='OLD',carriagecontrol='LIST',err=1,readonly) call scopy(temp,1,inname,1) #save name for error routines call scopy('for',1,temp,iindex(temp,period)+1) #change extention open(unit=OUTLUN,name=temp,carriagecontrol='LIST',err=1,type="new") if(write_long_names) open(unit=NAME_LUN,name="LONGNAMES.TMP",carriagecontrol='LIST', type="new",err=1) openf=.true. return 1 i = iindex(temp,0) write(ERRLUN,100)(temp(j),j=1,i-1) 100 format(' RATFOR: error in opening file ',80a1) close(unit=1) openf=.false. end /************************************************************************ * getarg - return the command line arguments * * * * usage: if(getarg(argn,buffer)) * * where: argn =the argument number to return * * buffer =the buffer to copy the argument into * * getarg =.true. if argument is found, .false. * * otherwise. * * note: The number of allowable arguments is limited by the * * DEFINED constant MAX_ARGS. The current limit is 64 * * arguments. * ************************************************************************/ define max_args 64 logical function getarg(argn,str) implicit integer(a-z) integer*2 argn byte str(255) #returned buffer integer dsw #Directive Status Word integer arg_ptr(MAX_ARGS) #offsets to beginning of arguments integer n_args #number of arguments found logical first integer descr(2) #descriptor for returned string byte buffer(256) data first/.true./ data descr(1)/255/ if(first) { first = .false. descr(2) = %%loc(buffer) if(!lib$get_foreign(descr)) n_args = 0 #no arguments found else { buffer(256) = 0 #mark end n_args = 0; i = 1 while(buffer(i) != 0) if(buffer(i) == ' ' | buffer(i) == ' ') i = i + 1 #skip white space else { n_args = n_args + 1 arg_ptr(n_args) = i #mark begining of arg while(buffer(i) != 0 & buffer(i) != ' ' & buffer(i) != ' ') i = i + 1 } } } if(argn <= 0 | argn > n_args) { getarg = .false. str(1) = 0 return } i = 1; j = arg_ptr(argn) #get arguments while(buffer(j) != 0 & buffer(j) != ' ' & buffer(j) != ' ') { str(i) = buffer(j) i = i + 1; j = j + 1 } str(i) = 0 #append EOS getarg = .true. return end