ON ERROR GOTO handle
CLS
dim o3st(4),o3ln(4),o3dc(4)
dim chst(15),chln(15),chdc(15)

data 28,4,0,32,4,2,36,5,3,58,3,2 '03 record
for i = 1 to 4
read o3st(i),o3ln(i),o3dc(i)
next i
data 28,4,0,32,4,2,36,4,2,40,3,2,43,3,2,46,3,2,49,3,1 '76 record
data 52,3,1,55,3,2,58,3,1,61,3,1,64,3,1,67,3,2,70,4,3,74,3,1
for i = 1 to 15
read chst(i),chln(i),chdc(i)
next i

LOCATE 2, 10
PRINT "****PARSEP*****"
PRINT
PRINT "Pulls out stations only with specific parameters"
PRINT

INPUT "Enter file name of ICES data records "; b$
OPEN b$ FOR INPUT AS #1

i = INSTR(b$, ".")
IF i = 0 THEN
bout$ = b$ + ".PAR"
ELSE
b02$ = LEFT$(b$, i - 1) + ".PAR"

END IF
PRINT "Parameter file is "; b02$
OPEN b02$ FOR OUTPUT AS #2
input "Enter 3 for Hydro; 6 for chemistry record ";rec$
select case rec$
case ="3"
print "Select parameter:"

print "<1> is Temperature, <2> is salinity, <3> is oxygen ";
input sel
if sel <1 or sel>3 then
print "Incorrect selection- run aborted - tough!":end
end if
fldst=o3st(sel+1):fldln=o3ln(sel+1)

case = "6"
print "<4> is phosphate; <5> is Total Phosphate; <6> is Silicate  "
print "<7> is nitrate; <8> is nitrite; <9> is ammonium"
print "<10> is Total Nitrogen; <11> is H2s; <12> IS Ph"
print "<13> is alkalinity; <14> is chlorophyll"
input sel
if sel <4 or sel> 14 then
print "Incorrect selection - run aborted - tough!":end
end if
fldst=chst(sel+1):fldln=chln(sel+1)

case else
print "Incorrect selection":end
end select

WHILE NOT EOF(1)
LINE INPUT #1, a$
r$=mid$(a$,80,1)
IF MID$(a$, 80, 1) = "J" OR MID$(a$, 80, 1) = "1" THEN
LOCATE 17, 5: PRINT "Stations ";
stn = stn + 1: PRINT stn
mast$=a$:gon=0
END IF

IF MID$(a$, 80, 1) = rec$ and mid$(a$,fldst,fldln)<>string$(fldln,32) THEN
  if gon=0 then
     print #2,mast$
     gon=1
     LOCATE 18, 5: PRINT "Stations with parameter ";sel;
     sur = sur + 1: PRINT sur
   end if
PRINT #2, a$
END IF

WEND

END

handle:
IF ERR = 53 THEN PRINT "Input file not available": END
PRINT "error is "; ERR
END

