PK.LABMKEY
A^prefix,
@OPEN.LAB,
@PATS,
END;

OPEN.LAB
@admdir,
O(&,@misdict),
O(:,@admdata),
@labdir,
O(\,@labdict),
@labdir,
O(*,@labdata),
O(\,@labdict),
@pkdir

PATS
/ARGV[1]^DT,
2^nr,
DO{nr</ARGC 1,
   /ARGV[nr]^ACT,
   :AAAI[ACT]^aa,
   @BBK,
   nr+1^nr}

BBK
""^Q,
DO{@NEXT.SPEC @SEND}

NEXT.SPEC
>(*SBSP[aa,Q],sbs)^Q

SEND
IF{*SBS[sms]|3<DT;
   "<Document>"^!,
   "<InstanceMnemonic>"_prefix_sbs_"</InstanceMnemonic>"^!,
   "append x to key because t0 may be empty",
   "<Key>"_"x"_*SBS[sbs]|23_"</Key>"^!,
   "<PersonMnemonic>"_:AA[aa]|3_"</PersonMnemonic>"^!,
   "<EventEndDateTime>"^!,
   IF{*SBS[sbs]|13_.'=. *SBS[sbs]|3_*SBS[sbs]|4;
      *SBS[sbs]|14_.'=. *SBS[sbs]|9_*SBS[sbs]|10}^!,
   "</EventEndDateTime>"^!,
   "<EventSetMnemonic>BBK</EventSetMnemonic>"^!,
   "</Document>"^!}
