A code sequence might be as follows:
SEL COVER.PAT RES AREA > 0 &r cursor declare master cover.pat &rv [index] &while &ne [index] -1 &do CALC [val] = R_ITEM SEL COVER.RELATE RES R_ITEM = [val] &r cursor declare relate cover.relate ... examine related records ... &r cursor relate remove &r cursor master next &rv [index] &end &r cursor master remove
additem veg.pat veg.pat spp 5 5 C additem veg.pat veg.pat pct 8 8 N 2The following routine will set the species and percent in VEG.PAT equal to that of the highest percent species in VEG.SPECIES:
&routine spcalc &define muntnumb -9 &var &define i -10 &var &define j -11 &var &define val -12 &var &define spp -13 &var &define pct -14 &var &define tmp -15 &var &sv [muntnumb] "257 279 290 672" &sv [i] 1 &while &rn [i] 1 4 &do &extract [val] [muntnumb] [i] SEL VEG.SPECIES RES MUNTNUMB = [val] &r cursor declare relate veg.species &rv [j] &sv [spp] &sv [pct] 0 &while &ne [j] -1 &do CALC [tmp] = PCT &if &eq %<[pct] max [tmp]> [tmp] &do MOVE SPP TO [spp] &sv [pct] [tmp] &end &r cursor relate next &rv [j] &end &r cursor relate remove SEL VEG.PAT RES MUNTNUMB = [val] MOVE '%[spp]' to SPP CALC PCT = %[pct] &inc [i] &end ASEL &returnNote that because there are only four categories of MUNTNUMB in VEG, some time is saved by not scrolling through each record of VEG.PAT.
&routine tabcov &define intab -11 &var &define outcov -12 &var &define numrec -13 &var &define wksp -18 &var &define temp -19 &var &goto usage &if &eq "x%-1" "x/?" &goto usage &if &eq "x%-1" "x" &goto usage &if &eq "x%-2" "x" &if &fn %-2 &do &type "%-2 already exists." &return &end &value [intab] -1 &value [outcov] -2 &value [wksp] WKSP &rem **** get number of records &openw [wksp]tc_tab.sml &write "&openw [wksp]tc_dir.lis" &write "DIR [intab]" &write "&closew" &write "Q" &closew TABLES [wksp]tc_tab &open [wksp]tc_dir.lis error &read -1 error &read -1 error &close &extract [numrec] -1 2 &rem **** generate coverage &openw [wksp]tc_gen.sml &write "&sv -1 1" &write "POINTS" &write "&label do" &write " %%-1 -9999999 -9999999" &write " &cv -1 %%-1 + 1" &write " &goback do &if &rn %%-1 1 [numrec]" &write "&label end" &write "END" &write "Q" &closew GENERATE [outcov] [wksp]tc_gen BUILD [outcov] POINT &rem **** join table JOINITEM [outcov].pat [intab] [outcov].pat [outcov]-ID [outcov]-ID LINK & DEL [wksp]tc_*.* &return &label usage &delim < > &type "Usage: &r TABCOV [in_table] [out_cover]" &delim [ ] &return &label error &type "I/O ERROR" &return&r TABCOV [in_table] [out_cover]
&r tabcov veg.species speciesThe following routine, executed in ARCPLOTW, allows the user to pick a polygon in VEG, and then pops up (in Notepad) all species whose percentage is 10 or greater:
&routine spquery &define x -11 &var &define y -12 &var &define key -13 &var &define r -14 &var &define val -15 &var &define wksp -18 &var &define temp -19 &var &rem **** display VEG polys &rem **** DISP 4 must be active CLEAR MAPE VEG SHADESET COLOR255.SHD POLYGONSHADES VEG TYPE LUT.VEG LINESET COLOR.LIN LINESYMBOL 1 POLYS VEG &rem **** begin query loop SHOW SEARCHTOLERANCE [r] &type "Pick polygon to query (9 to quit)" &getxym [x] [y] [key] WIN FOCUS T &while &ne [key] 9 &do CLEARSELECT RES VEG POLY CIRCLE [x] [y] [r] &sv [temp] 0 SHOW RESELECT [temp] 0 &if &ne [temp] 0 &do CALC VEG POLY [val] = MUNTNUMB RES SPECIES POINT MUNTNUMB = [val] RES SPECIES POINT PCT >= 10 SHOW RESELECT [temp] 0 &if &eq [temp] 0 &do WIN MB 1 'No species >= 10 percent' &else &openw [wksp]t$temp.lis LIST SPECIES POINT MUNTCOMP SPP PCT &closew WIN RUNW notepad.exe [wksp]t$temp.lis & DEL [wksp]t$temp.lis &end &end &getxym [x] [y] [key] WIN FOCUS T &end CLEARSELECT &return