#aopen - open function for ratfor. # jl - 9/30/82 include the option open for append define(APPEND,3) include ratdef integer function aopen (name, mode) character name(ARB) integer mode include channel integer temp integer string(40), ch # build a proper filename in string temp=mode for (i = 1; name(i) == BLANK; i = i+1) ; # get rid of leading blanks for (j = 1; name(i) ^= EOS; i = i+1) { # copy to packed string byte(string,j) = name(i); j = j+1 } byte(string,j) = NULL # terminate with null # find a free channel number for (ch = 0; ch <= MAXCHNL; ch = ch+1) if (channel(ch) == ERR) break if (ch > MAXCHNL) ier = ERR # open the file in the proper mode else if(mode == APPEND){ call CFILW(string,2,ier) call OPEN(ch,string,0,ier) } else if (mode == READ) call OPEN (ch, string, 1, ier) else if (mode == WRITE | mode == READWRITE) { call CFILW (string, 2, ier) call OPEN (ch, string, 3, ier) } if(temp==APPEND)temp=WRITE if (ier ^= 1) { ch = ERR } else channel(ch) = temp return(ch) end