PARM file=./@, rtnvar="", entry=main # Usage: numsects [fileset] [rtnvar] # # This command file returns the computed number of sectors in "file" by doing # a LISTFILE file,2 redirected to disk. If "rtnvar" is passed then it is # set to the number of sectors, else the number of sectors is displayed to # $STDLIST. # Note on wildcarding: if "file" is wildcarded and "rtnvar" is passed it is # set to the largest number of sectors found across all matching files. If # "file" is wildcarded and "rtnvar" is not passed then the number of # sectors for the largest matching file is displayed to $STDLIST. In case # of ties the first matching file is used. if '!entry' = 'main' then errclear continue listfile !file,2 >lfsects if hpcierr <> 0 then echo Error !hpcierr on LISTFILE !file,2 echo !hpcierrmsg return endif xeq !hpfile !file, !rtnvar, entry=get_sectors "//" do # this record contains the ACCOUNT= or PATH= line # find out the column for SECTORS (MPE and HFS have different postions) if word(_lfsects_buf," ") = "PATH=" then setvar _lfsects_posix TRUE setvar _lfsects_sect_word -4 setvar _lfsects_file_word -1 # use words -4 and -1 since word 1 (fcode) may be blank # qualify with "/path/" setvar _lfsects_path word(_lfsects_buf,,2) else setvar _lfsects_posix FALSE setvar _lfsects_sect_word -3 # use word -3 since word 2 (fcode) may be blank setvar _lfsects_file_word 1 # qualify with ".GROUP.ACCOUNT" setvar _lfsects_path "." + word(_lfsects_buf,,-1) + "." + & word(_lfsects_buf,,2) endif # skip next 4 header lines input _lfsects_buf input _lfsects_buf input _lfsects_buf input _lfsects_buf setvar _lfsects_i _lfsects_i + 4 # inner while: # read each record, extract num_sectors, keep track of largest number of # sectors and matching qualified filename while setvar(_lfsects_i, _lfsects_i+1) <= _lfsects_eof and & setvar(_lfsects_buf,input()) <> "" do setvar _lfsects_num_sectors ![word(_lfsects_buf,,_lfsects_sect_word)] if _lfsects_num_sectors > _lfsects_max_sects then setvar _lfsects_max_sects _lfsects_num_sectors setvar _lfsects_max_file word(_lfsects_buf,,_lfsects_file_word) # qualify filename if _lfsects_posix then setvar _lfsects_max_file _lfsects_path+_lfsects_max_file else setvar _lfsects_max_file _lfsects_max_file+_lfsects_path endif endif endwhile endwhile return endif