!BONTEX2.IPF - taking a fresh look at matching - have table of texas taxa !fide bonap - BONTX96A.ITB, full BONAP nomenclatural table - BONAP96A.ITB !in Kcode order and a file for tagging Texas, and the same table with family !and genus records [rankcode=0, 1] removed and sorted by genus/species. So, !will walk through BONTX96A.ITB and take all match strings as vars - then will !use genus string to pluck from BONAP96B.ITB with a walk through all records !carrying that genus name looking for records that FULLY match the name !strings taken from BONTX96A.ITB. Will check full match using breakup of !origina name string to determine rankcode and also check hybrid - will track !matches initially in a 'gotit' field in BONTX96A.ITB - 11/7/96 - !advanced this to bontex2-14/7/96 copying this to BONTAES1.IPF for adaptation !from bontx96a as souce table to taesall5.itb as source of names to be matched finish all !TABLES use bonap96b with bon96bge use bonap96a with bon96ana use bontx96a;default bontx96a !VARIABLES moveit=0;qrank1="";qrank2="";haverank=0;hybrid=false;qhybrid=" ";qinfra1="" qspecies="";qnameid=" ";qtaxid=" ";qtexcode=" " spelen=0;inf1len=0;strlen=0;qinfra2="";qinf2len=0;x=0;y=0;getit=0;passit=0 texcheck=0 !ENVIRONMENT e.supd=true;e.deci=0;e.lnum=9 !START default bontx96a clear @6,2?"Current record - BONTX96A.ITB:" @8,2?"Current record - BONAP96A.ITB:" @10,2?"Current record - BONAP96B.ITB:" while moveit=0 do !ACTION if texcheck=0 then !STARTING RUN default bontx96a;obtain 2 texcheck=1 else !HAVE CHECK RESULTS FROM BONAP96B default bontx96a !ADD BONAP96B DATA TO BONTX96A AND GET TAG FOR TRANSFER TO BONAP96A bontx96a.nameid96=qnameid;bontx96a.taxoid96=qtaxid;qtexcode=bontx96a.texcode !TAG APPROPRIATE RECORD IN BONAP96A if substr(qnameid,1,1)="k" then !BY-PASS 'NO MATCH' RECORDS default bonap96a;pluck qnameid if #found=false then clear;@10,2?"Can't find ",qnameid," in BONAP96A" wait else @8,33?CURREC(BONAP96a) bonap96a.texas=qtexcode endif endif default bontx96a;obtain next texcheck=texcheck+1 !CLEAR MATCH VARS qrank1="";qrank2="";hybrid=false;qhybrid=" ";qinfra1="";qinfra2="";qspecies="" qgenus="";spelen=0;inf1len=0;inf2len=0;genlen=0;x=0;y=0;getit=0;passit=0 qnameid=" ";qtaxid=" ";qtexcode=" " !CLEAR COUNTERS, LENGTHS haverank=0;strlen=0; if pastend(bontx96a)=true then;moveit=1;endif !if currec(bontx96a)=500 then;moveit=1;endif if moveit ne 0 then;break;endif endif !DETERMINE RANK if match(bontx96a.fullname,"var.") ne 0 and match(bontx96a.fullname,"ssp.") ne 0 then qrank1="ssp";qrank2="var";haverank=4 endif if haverank = 0 then if match(bontx96a.fullname,"var.") ne 0 then qrank1="var";haverank=3 endif if match(bontx96a.fullname,"ssp.") ne 0 then qrank1="ssp";haverank=3 endif endif qgenus=substr(bontx96a.fullname,1,match(bontx96a.fullname," ")) !CHECK FOR HYBRID - ALL ARE INTERSPECIFIC if match(bontx96a.fullname," X ") ne 0 then hybrid=true;qhybrid="X " else hybrid=false;qhybrid=" " endif !GET FULL LENGTH OF TRIMMED FULLNAME strlen=len(trim(bontx96a.fullname)) !GET SPECIES NAME if haverank lt 3 then if hybrid=true then qspecies=substr(bontx96a.fullname,match(bontx96a.fullname," x ")+3,strlen) else qspecies=substr(bontx96a.fullname,match(bontx96a.fullname," ")+1,strlen) endif endif !GET SPECIES/INFRA NAME FOR RANK 3 if haverank = 3 then if qrank1="var" then !SET LENGTHS FOR SUBSTRINGS spelen=strlen-match(bontx96a.fullname," ")-1 !TAKE OUT GENUS NAME inf1len=strlen-match(bontx96a.fullname," var.") !GET LENGTH OF INFRA spelen=spelen-inf1len !TAKE OUT INFRA qspecies=substr(bontx96a.fullname,match(bontx96a.fullname," ")+1,spelen) qinfra1=substr(bontx96a.fullname,match(bontx96a.fullname,"var.")+5,inf1len) endif if qrank1="ssp" then !SET LENGTHS FOR SUBSTRINGS spelen=strlen-match(bontx96a.fullname," ")-1 !TAKE OUT GENUS NAME inf1len=strlen-match(bontx96a.fullname," ssp.") !GET LENGTH OF INFRA spelen=spelen-inf1len !TAKE OUT INFRA qspecies=substr(bontx96a.fullname,match(bontx96a.fullname," ")+1,spelen) qinfra1=substr(bontx96a.fullname,match(bontx96a.fullname,"ssp.")+5,inf1len) endif endif !GET SPECIES/INFRAS NAME FOR RANK 4-ALL ARE SSP. THEN VAR. if haverank = 4 then !SET LENGTHS FOR SUBSTRINGS strlen=len(trim(bontx96a.fullname)) genlen=match(bontx96a.fullname," ") spelen=match(bontx96a.fullname,"ssp.")-genlen !TAKE OUT GENUS NAME qinfra2=substr(fullname,match(fullname,"var."),strlen) !INITIAL STRING inf2len=len(trim(qinfra2)) x=match(fullname,"ssp.");y=match(fullname,"var.") inf1len=(y-x)-6 !FILL VARIABLES qspecies=ltrim(substr(bontx96a.fullname,genlen,spelen-1)) qinfra1=substr(bontx96a.fullname,match(bontx96a.fullname,"ssp.")+5,inf1len) qinfra2=substr(bontx96a.fullname,match(bontx96a.fullname,"var.")+5,inf2len) endif !HAVE SEARCH VARIABLES FROM BONTX96A - NOW FIND IN BONAP96A !GENUS=qgenus-HYBRID2=qhybrid-SPECIES=qspecies-INRANK1=qrank1 !INRANK2=qrank2-INNAME1=qinfra1-INNAME2=qinfra2-RANKCODE=haverank @6,33?CURREC(BONTX96A) default bonap96b pluck qgenus @10,33?CURREC(BONAP96B) if #found=false then @20,2?"No match for genus: ",qgenus qnameid="no";qtaxid="genus";passit=1 endif if passit=0 then !HAVE MATCHING GENUS GET OTHER DATA default bonap96b obtain prior;getit=0 while getit=0 do @10,33?CURREC(BONAP96B) !GET RECORD FOR RANK LT 3 - NORMAL AND HYBRIDS if haverank lt 3 then obtain next if bonap96b.genus ne qgenus then !CHECK ALL WITH RELEVANT GENUS NAME getit=1 qnameid="no-2";qtaxid="species" endif if getit ne 0 then;break;endif if bonap96b.species=qspecies and bonap96b.hybrid2=qhybrid and bonap96b.rankcode=2 then qnameid=bonap96b.nameid;qtaxid=bonap96b.taxonid;getit=1 @10,33?CURREC(BONAP96B) endif endif if getit ne 0 then;break;endif !GET RECORD FOR RANK = 3 - SSP OR VAR WITH 1 INFRA NAME if haverank = 3 then obtain next if bonap96b.genus ne qgenus then !CHECK ALL WITH RELEVANT GENUS NAME getit=1 qnameid="no-3";qtaxid="species" endif if getit ne 0 then;break;endif if bonap96b.species=qspecies and bonap96b.inrank1=qrank1 and bonap96b.inname1=qinfra1 and bonap96b.rankcode=3 then qnameid=bonap96b.nameid;qtaxid=bonap96b.taxonid;getit=1 @10,33?CURREC(BONAP96B) endif endif if getit ne 0 then;break;endif !GET RECORD FOR RANK = 4 - SSP and VAR WITH 2 INFRA NAMES if haverank = 4 then obtain next if bonap96b.genus ne qgenus then !CHECK ALL WITH RELEVANT GENUS NAME getit=1 qnameid="no-4";qtaxid="species" endif if getit ne 0 then;break;endif if bonap96b.species=qspecies and bonap96b.inrank1=qrank1\ and bonap96b.inname1=qinfra1 and bonap96b.inrank2=qrank2\ and bonap96b.inname2=qinfra2 and bonap96b.rankcode=4 then qnameid=bonap96b.nameid;qtaxid=bonap96b.taxonid;getit=1 @10,33?CURREC(BONAP96B) endif endif if getit ne 0 then;break;endif endwhile !END OF GETIT LOOP endif !END OF PASSIT CLAUSE (NO GENUS) endwhile !OUT release moveit,qrank1,qrank2,haverank,hybrid,qhybrid,qinfra1 release qspecies,spelen,inf1len,strlen,qinfra2,inf2len,x,y,texcheck release getit,passit,qnameid,qtaxid,qtexcode,genlen,qgenus finish all e.supd=false return