#!../src/tops -i -s ../sys  -u ../usr 

# Scan a Nastran OUTPUT2 file

# Infix version of scanop2, July 2007

#-----------------------------------------------------------------------

script_name = "scanop2_infix";
usage = "Usage: scanop2 <Nastran OUTPUT2 filename>";

# At least 2 command line argvs (script name and file name):
if(rows(ARGV) < 2) halt(nl(dot(usage)));

# Next-to-last argv is script name:
script_arg = (ARGV[rows(ARGV)-1], << -path >>);
if(!(script_arg == script_name)) halt(nl(dot(usage)));

# Last argv is the input file name:
Infile = vol2str(ARGV[rows(ARGV)]);
if(!file?(Infile)) halt(nl(dot(" file not found: " + Infile)));

file(Infile, old, binary, "BIN"); # open file, make handle called BIN

#-----------------------------------------------------------------------

source("nas.v"); # include Nastran utilities
op2file(BIN);    # map the OP2 file
cr0(out);        # clear the "Mapping ..." comment from screen

# Column titles:
HEAD = "Name Rec Titles: Cols Rows Form Type Nzwd %Dens*100";

# Run toc2 on BIN with output table to stk rather than to the display:
T = neat([HEAD ; [<< BIN "toc2" >stk asciify left justify >>]]);

FOOT = "Trailer titles apply to matrices, not tables"; # footnote
nl(dot([T ; FOOT]));

fclose(BIN);
