PARM file=./@, rtnvar="", entry=main comment -- Usage: numsects [fileset] [rtnvar] comment -- comment -- This command file returns the computed number of sectors in "file" comment -- by doing a LISTFILE file,2 redirected to disk. If "rtnvar" is comment -- passed then it is set to the number of sectors, else the number comment -- of sectors is displayed to $STDLIST. comment -- comment -- Note on wildcarding: if "file" is wildcarded and "rtnvar" is passed comment -- it is set to the largest number of sectors found across all comment -- matching files. If "file" is wildcarded and "rtnvar" is not comment -- passed then the number of sectors for the largest matching file comment -- is displayed to $STDLIST. In case of ties the first matching comment -- 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 comment -- this record contains the ACCOUNT= or PATH= line comment -- find out the column for SECTORS comment -- (MPE and HFS have different positions) if str( _lfsects_buf, 2, 5 ) = "PATH=" then setvar _lfsects_posix TRUE setvar _lfsects_sect_start 45 setvar _lfsects_sect_len 9 setvar _lfsects_file_start 62 setvar _lfsects_file_len 256 comment -- qualify with "/path/" setvar _lfsects_path rht( _lfsects_buf, len(_lfsects_buf)-7 ) else setvar _lfsects_posix FALSE setvar _lfsects_sect_start 54 setvar _lfsects_sect_len 9 setvar _lfsects_file_start 1 setvar _lfsects_file_len 8 comment -- qualify with ".GROUP.ACCOUNT" setvar _lfsects_path "." + rtrim( str(_lfsects_buf,31,8) ) & + "." + rtrim( str(_lfsects_buf,11,8) ) endif comment -- skip next 4 header lines input _lfsects_buf input _lfsects_buf input _lfsects_buf input _lfsects_buf setvar _lfsects_i _lfsects_i + 4 comment -- inner while: comment -- read each record, extract num_sectors, keep track of largest comment -- 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 & ![str(_lfsects_buf,_lfsects_sect_start,_lfsects_sect_len)] if _lfsects_num_sectors > _lfsects_max_sects then setvar _lfsects_max_sects _lfsects_num_sectors setvar _lfsects_max_file & rtrim(str(_lfsects_buf,_lfsects_file_start,_lfsects_file_len)) comment -- 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