/* combine tickets (each row points to several tickets) and ticket_vals (each row is a ticket with several values) to create an xml dataset */

t1='ers08_tickets.val';
t2='ers08_ticket_vals.val'

it1=stream(t1,'c','query size')
it2=stream(t2,'c','query size')
aidlist=''
stuff1=charin(t1,1,it1)
do until stuff1=''
   parse var stuff1 aline '0d0a'x stuff1
   aline=strip(aline)
   if abbrev(aline,';')=1 then iterate
   if aline='' then iterate
   parse var aline aid itick1 itick2 itick3 adog ; aid=strip(aid)
   aline.aid.T1=itick1
   aline.aid.T2=itick2
   aline.aid.T3=itick3
   aline.aid.DOGNAME=adog
   aidlist=aidlist||' 'aid
end


tickets.='.'
stuff1=charin(t2,1,it2)
do until stuff1=''
   parse var stuff1 aline '0d0a'x stuff1
   aline=strip(aline)
   if abbrev(aline,';')=1 then iterate
   if aline='' then iterate
   parse var aline atick agroup afee ; atick=strip(atick)
   tickets.atick.GROUP=strip(agroup)
   tickets.atick.FEE=strip(afee)
end

say '<rows>'
say ' <vars> RowID,Group1,Fee1,Group2,Fee2,Group3,Fee3,SillyName </vars>'
say ''
say ' <vals>'
do m=1 to words(aidlist)
   anid=strip(word(aidlist,m))
   itick1=aline.anid.T1
   itick2=aline.anid.T2
   itick3=aline.anid.T3
   nline=anid||' '||tickets.itick1.GROUP||' '||tickets.itick1.FEE||' '||tickets.itick2.GROUP||' '||tickets.itick2.FEE||' '||tickets.itick3.GROUP||' '||tickets.itick3.FEE||' '||aline.anid.DOGNAME||'0d0a'x

   nline='   <row id="'||anid||'">'||tickets.itick1.GROUP||' '||tickets.itick1.FEE||' '||tickets.itick2.GROUP||' '||tickets.itick2.FEE||' '||tickets.itick3.GROUP||' '||tickets.itick3.FEE||' '||aline.anid.DOGNAME||'</row>'||'0d0a'x

  say nline
end /* do */
say
say ' </vals>'
say '</rows>'

