$! sysuaf_to_names.com $! David Mathog, Biology Division, Caltech 03-MAR-1997 $! $! Convert the contents from SYSUAF.DAT $! to name space database format. Typically you must run this from the $! system or other priv'd account that can READ the sysuaf $! $! $ @sysuaf_to_names $! $! P1 is the name of the input file, defaults to SYS$SYSTEM:SYSUAF.DAT $! P2 is the name of the output file, otherwise defaults to output.dat $! P3 if set, output is in database format, if not set, output is in format $! for submission through the Web based multi input page. (You would $! have to make special arrangments to get database format records into $! the database - the multiple submission page will not work with them.) $! $! Fields extracted (each is terminated by a space) $! $! Full Username, start 85, length 32 (Compress and Trim) $! Account name (Short), start 4, length 12 (Compress and Trim) $! Division, start 52, length 32 (Compress and Trim, later do $! search and replace $! Status, defaults to "Unclassified" $! Operator, defaults to "Operator" $! Date, from date of this conversion $ if(P1 .nes. "") $ then $ inname = P1 $ else $ inname = SYS$SYSTEM:SYSUAF.DAT $ endif $ if(P2 .nes. "") $ then $ outname = P2 $ else $ outname = "output.dat" $ write sys$output "The output file will be called output.dat" $ endif $ if(P3 .eqs. "") $ then $ fstring="!AS,!AS,!AS,!AS,!AS,!AS,!AS" $ else $ fstring="S:!AS,L:!AS,N:!AS,V:!AS,T:!AS,O:!AS,D:!AS" $ endif $! $ Operator = "Operator" $ Status = "Unclassified" $ Date = f$cvtime("") $! $ open/read/share/error=oops ifil: 'inname' $ open/write/error=oops2 ofil: 'outname' $ top: $ read/end=byebye/error=byebye ifil: string $ username = f$extract(85,31,string) $ username = f$edit(username,"TRIM,COMPRESS") $ long = username $! $! short might be longer than 8, but if so, truncate it $! $ short = f$extract(4,8,string) $ short = f$edit(short,"COLLAPSE,LOWERCASE") $ division = f$extract(52,31,string) $ division = f$edit(division,"TRIM,COMPRESS") $! $! Long might hold garbage, like commas or "(", if it does, just use short $! $ if(f$locate(",",long) .ne. f$length(long)) $ then $ long = short $ goto spit $ endif $ if(f$locate("(",long) .ne. f$length(long)) $ then $ long = short $ goto spit $ endif $ if(f$locate(")",long) .ne. f$length(long)) $ then $ long = short $ goto spit $ endif $! $! Long might be too big $! $ if(f$length(long) .ge. 20) $ then $! $! Ok, first try eliminating the middle name $! $ icount = 0 $elim: $ frag = f$element(icount," ",long) $ icount = icount + 1 $ if(frag .nes. " ") $ then $ if(icount .eq. 1)then first = frag $ last = frag $ goto elim $ endif $ if(icount .eq. 1)then last = "" $! $ if(f$length(first) + f$length(last) + 1 .gt. 20) $ then $! $! reduce first name to an initial and try again $! $ first = f$extract(0,1,first) $ if(f$length(first) + f$length(last) + 2 .gt. 20) $ then $! $! rats!, just use the short name $! $ long = short $ else $ long = first + ". " + last $ endif $ else $ long = first + " " + last $ endif $! $! $ endif $spit: $ ostring = f$fao(fstring,short,long,username,division,status,operator,date) $ write ofil: ostring $ goto top $ byebye: $ close ofil: $ close ifil: $ write sys$output "Done." $ exit $ oops: $ write sys$output "Sorry could not open input file: ''inname'" $ exit $ oops2: $ write sys$output "Sorry could not open output file ''outname'" $ close ifil: $ exit