$set noverify $save_message = f$environment("MESSAGE") $set message/noidentification/notext/noseverity/nofacility $maxq = 400 ! maximum no. of lines per question $key = "H" $if P1 .nes. "" then key = P1+P2 $ass/nolog cdoc:ccp4.faq FILE $ass/nolog ccp4_scr:tmp.dat TMP $ass/nolog ccp4_scr:tmp1.dat TMP1 $ass/nolog ccp4_scr:tmp2.dat TMP2 $! $START: $if key .eqs. "" then inquire key "Which option do you want l/#/s/f/h/e" $opt = f$extract(0,1,key) $num = f$length(key) $opt2 = f$extract(1,num,key) $! $! END the interactive session $! $if opt .eqs. "E" then goto END $! $! HELP utility $! $if opt .eqs. "H" $ then $ write sys$output "l lists all questions" $ write sys$output "# number shows the question on the screen e.g. # 3" $ write sys$output "s query searches the question subjects for the string query" $ write sys$output "f query searches the whole FAQ file for the string query" $ write sys$output "e ends the interactive session" $ key = "" $ goto START $endif $! $! LIST the questions $! $if opt .eqs. "L" $ then $ search/output=TMP/match=AND/exact FILE "Q.","-" $ type/page TMP $ key = "" $ goto START $endif $! $! show the question number # $! $if opt .eqs. "#" $ then $ gosub NUMBER $ goto START $endif $! $! SUBJECT search for specified string $! $if opt .eqs. "S" $ then $ gosub SUBJECT $ goto START $endif $! $! FULL search for specified string $! $if opt .eqs. "F" $ then $ gosub FULLSEARCH $ goto START $endif $! $write sys$output "Invalid option" $key = "" $goto START $! $END: $deass FILE $deass TMP $deass TMP1 $deass TMP2 $delele/noconf ccp4_scr:tmp.dat.* $delele/noconf ccp4_scr:tmp1.dat.* $delele/noconf ccp4_scr:tmp2.dat.* $set message'save_message' $exit $! $! Subroutines $! $NUMBER: $ GETQ: $ if opt2 .eqs. "" $ then $ inquire opt2 " Question number" $ goto GETQ $ endif $ quest = f$fao("Q.!3ZL",(f$integer(opt2))) $ search/output=TMP/match=AND/window=(1,'maxq') FILE 'quest',"-" $ open/read infile TMP $ open/write outfile TMP1 $ READ_LOOP1: $ read/end_of_file=ERR infile line $ bit = f$extract(1,3,line) $ write outfile line $ if bit .eqs. "---" then goto CNT $ goto READ_LOOP1 $ ERR: $ write sys$output " INVALID question number" $ close infile $ close outfile $ goto SKIP $ CNT: $ close infile $ close outfile $ type/page TMP1 $ SKIP: $ key = "" $return $! $SUBJECT: $ GETC: $ if opt2 .eqs. "" $ then $ inquire opt2 " Search string" $ goto GETC $ endif $ char = opt2 $ search/outp=TMP/match=AND/window=(0,1)/exact FILE "Q.","-" $ search/output=TMP1 TMP 'char' $ type/page TMP1 $ key = "" $return $! $FULLSEARCH: $ GETF: $ if opt2 .eqs. "" $ then $ inquire opt2 " Search string" $ goto GETF $ endif $ char = opt2 $ search/output=TMP2 FILE 'char' $ open/read infile2 TMP2 $ READ_LOOP2: $ read/end_of_file=SKIP1 infile2 line $ if f$extract(0,2,line) .eqs. "Q." .and. f$extract(6,1,line) .eqs. "-" $ then $ opt2 = f$extract(2,3,line) $ gosub NUMBER $ inquire dum " Press return to continue" $ endif $ goto READ_LOOP2 $ SKIP1: $ close infile2 $ key = "" $return